All Projects → avto-dev → Roadrunner Laravel

avto-dev / Roadrunner Laravel

Licence: mit
[ABANDONED] Moved to https://github.com/spiral/roadrunner-laravel

Projects that are alternatives of or similar to Roadrunner Laravel

Laravel Pdf
A Simple package for easily generating PDF documents from HTML. This package is specially for laravel but you can use this without laravel.
Stars: ✭ 79 (-36.29%)
Mutual labels:  laravel, package
Laravel Totem
Manage Your Laravel Schedule From A Web Dashboard
Stars: ✭ 1,299 (+947.58%)
Mutual labels:  laravel, package
Laravel Mixpanel
Intuitive drop-in analytics.
Stars: ✭ 80 (-35.48%)
Mutual labels:  laravel, package
Env Providers
👷 Load Laravel service providers based on your application's environment.
Stars: ✭ 73 (-41.13%)
Mutual labels:  laravel, package
Laravel Google Translate
This package makes using the Google Translate API in your laravel app a breeze with minimum to no configuration, clean syntax and a consistent package API.
Stars: ✭ 97 (-21.77%)
Mutual labels:  laravel, package
Manager
Implementation of the Manager pattern existing in Laravel framework
Stars: ✭ 74 (-40.32%)
Mutual labels:  laravel, package
Laravel Package Maker
Get a 📦 skeleton and all other `make` commands from laravel base for package development.
Stars: ✭ 89 (-28.23%)
Mutual labels:  laravel, package
Watchable
Enable users to watch various models in your application.
Stars: ✭ 65 (-47.58%)
Mutual labels:  laravel, package
Flex Env
🌳 Manage your .env file in Laravel projects through artisan
Stars: ✭ 95 (-23.39%)
Mutual labels:  laravel, package
Laravel Likeable
Rate Eloquent models with Likes and Dislikes in Laravel. Development moved to Laravel Love package!
Stars: ✭ 95 (-23.39%)
Mutual labels:  laravel, package
Laravel Ownership
Laravel Ownership simplify management of Eloquent model's owner.
Stars: ✭ 71 (-42.74%)
Mutual labels:  laravel, package
Laravel Natural Language
This package makes using the Google Natural API in your laravel app a breeze with minimum to no configuration, clean syntax and a consistent package API.
Stars: ✭ 119 (-4.03%)
Mutual labels:  laravel, package
Picasso
Laravel Image Management and Optimization Package
Stars: ✭ 70 (-43.55%)
Mutual labels:  laravel, package
Guardian
Eloquent Guardian is a simple permissions system for your users. While there are many other packages for permissions, this one solves everything in the most eloquent way.
Stars: ✭ 121 (-2.42%)
Mutual labels:  laravel, package
Laravel Mentions
End-to-end mentions in Laravel 5.
Stars: ✭ 68 (-45.16%)
Mutual labels:  laravel, package
Laravel Nullable Fields
Handles saving empty fields as null for Eloquent models
Stars: ✭ 88 (-29.03%)
Mutual labels:  laravel, package
Shield
The core shield package.
Stars: ✭ 60 (-51.61%)
Mutual labels:  laravel, package
Laravel Packme
A CLI starter pack for developing a package with Laravel 5
Stars: ✭ 64 (-48.39%)
Mutual labels:  laravel, package
Laravel Analytics
Analytics for the Laravel framework.
Stars: ✭ 91 (-26.61%)
Mutual labels:  laravel, package
Laravel Factory Prefill
Prefills factories with faker method suggestions to increase productivity
Stars: ✭ 104 (-16.13%)
Mutual labels:  laravel, package

This package is abandoned and no longer maintained
We suggests using the spiral/roadrunner-laravel package instead

RoadRunner ⇆ Laravel bridge

Version Version Build Status Coverage Downloads count License

Easy way for connecting RoadRunner and Laravel applications.

Installation

Require this package with composer using next command:

$ composer require avto-dev/roadrunner-laravel "^3.3"

Installed composer is required (how to install composer).

You need to fix the major version of package.

Previous major versions still available, but it's development is abandoned. Use only latest major version!

After that you can "publish" package configuration file (./config/roadrunner.php) using next command:

$ php ./artisan vendor:publish --provider='AvtoDev\RoadRunnerLaravel\ServiceProvider' --tag=config

And basic RoadRunner configuration file (./.rr.yaml.dist):

$ php ./artisan vendor:publish --provider='AvtoDev\RoadRunnerLaravel\ServiceProvider' --tag=rr-config

After that you can modify configuration files as you wish.

Important: despite the fact that worker allows you to refresh application instance on each HTTP request (if environment variable APP_REFRESH set to true), we strongly recommend to avoid this for performance reasons. Large applications can be hard to integrate with RoadRunner (you must decide which of service providers must be reloaded on each request, avoid "static optimization" in some cases), but it's worth it.

Usage

After package installation you can use provided "binary" file as RoadRunner worker: ./vendor/bin/rr-worker. This worker allows you to interact with incoming requests and outcoming responses using laravel events system. Also events contains:

Event classname Application object HTTP server request HTTP request HTTP response Exception
BeforeLoopStartedEvent
BeforeLoopIterationEvent
BeforeRequestHandlingEvent
AfterRequestHandlingEvent
AfterLoopIterationEvent
AfterLoopStoppedEvent
LoopErrorOccurredEvent

Simple .rr.yaml config example:

env:
  #APP_REFRESH: true

http:
  address: 0.0.0.0:8080
  workers:
    command: 'php ./vendor/bin/rr-worker'

static:
  dir: 'public'

Roadrunner server starting:

$ rr -c ./.rr.yaml serve -d

Listeners

This package provides event listeners for resetings application state without full application reload (like cookies, HTTP request, application instance, service-providers and other). Some of them already declared in configuration file, but you can declare own without any limitations.

Environment variables

You can use the following environment variables:

Variable name Description
APP_FORCE_HTTPS (declared in configuration file) Forces application HTTPS schema usage
APP_REFRESH Refresh application instance on every request

Known issues

Controller constructors

You should avoid to use HTTP controller constructors (created or resolved instances in constructor can be shared between different requests). Use dependencies resolving in controller methods instead.

Bad:

<?php

use Illuminate\Http\Request;
use Illuminate\Http\Response;
use App\Http\Controllers\Controller;

class UserController extends Controller
{
    /**
     * The user repository instance.
     */
    protected $users;
    
    /**
     * @var Request
     */
    protected $request;

    /**
     * @param UserRepository $users
     * @param Request        $request
     */
    public function __construct(UserRepository $users, Request $request)
    {
        $this->users   = $users;
        $this->request = $request;
    }
    
    /**
     * @return Response
     */
    public function store(): Response
    {
        $user = $this->users->getById($this->request->id);
        
        // ...
    }
}

Good:

<?php

use Illuminate\Http\Request;
use Illuminate\Http\Response;
use App\Http\Controllers\Controller;

class UserController extends Controller
{
    /**
     * @param  Request        $request
     * @param  UserRepository $users
     *
     * @return Response
     */
    public function store(Request $request, UserRepository $users): Response
    {
        $user = $users->getById($request->id);
        
        // ...
    }
}

Middleware constructors

You should never to use middleware constructor for session, session.store, auth or auth Guard instances resolving and storing in properties (for example). Use method-injection or access them through Request instance.

Bad:

<?php

use Illuminate\Http\Request;
use Illuminate\Session\Store;

class Middleware
{
    /**
     * @var Store
     */
    protected $session;

    /**
     * @param Store $session
     */
    public function __construct(Store $session)
    {
        $this->session = $session;
    }
    
    /**
     * Handle an incoming request.
     *
     * @param Request  $request
     * @param \Closure $next
     *
     * @return mixed
     */
    public function handle(Request $request, Closure $next)
    {
        $name = $this->session->getName();
        
        // ...
        
        return $next($request);
    }
}

Good:

<?php

use Illuminate\Http\Request;

class Middleware
{
    /**
     * Handle an incoming request.
     *
     * @param Request  $request
     * @param \Closure $next
     *
     * @return mixed
     */
    public function handle(Request $request, Closure $next)
    {
        $name = $request->session()->getName();
        // $name = resolve('session')->getName();
        
        // ...
        
        return $next($request);
    }
}

Testing

For package testing we use phpunit framework and docker-ce + docker-compose as develop environment. So, just write into your terminal after repository cloning:

$ make build
$ make latest # or 'make lowest'
$ make test

Changes log

Release date Commits since latest release

Changes log can be found here.

Support

Issues Issues

If you will find any package errors, please, make an issue in current repository.

License

This is open-sourced software licensed under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].