All Projects → spiral → Roadrunner Laravel

spiral / Roadrunner Laravel

Licence: mit
RoadRunner ⇆ Laravel bridge

Projects that are alternatives of or similar to Roadrunner Laravel

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 (-41.92%)
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 (-27.54%)
Mutual labels:  laravel, package
Laravel Factory Prefill
Prefills factories with faker method suggestions to increase productivity
Stars: ✭ 104 (-37.72%)
Mutual labels:  laravel, package
Laravel Analytics
Analytics for the Laravel framework.
Stars: ✭ 91 (-45.51%)
Mutual labels:  laravel, package
Laravel Paket
Composer GUI. Manage Laravel dependencies from web interface without switching to command line!
Stars: ✭ 143 (-14.37%)
Mutual labels:  laravel, package
Laravel Likeable
Rate Eloquent models with Likes and Dislikes in Laravel. Development moved to Laravel Love package!
Stars: ✭ 95 (-43.11%)
Mutual labels:  laravel, package
Laravel Optimus
Transform your internal id's to obfuscated integers based on Knuth's integer hash. Laravel wrapper for the Optimus Library by Jens Segers with multiple connections support.
Stars: ✭ 119 (-28.74%)
Mutual labels:  laravel, package
Laravel Mixpanel
Intuitive drop-in analytics.
Stars: ✭ 80 (-52.1%)
Mutual labels:  laravel, package
Laravel Governor
Manage authorization with granular role-based permissions in your Laravel Apps.
Stars: ✭ 131 (-21.56%)
Mutual labels:  laravel, package
Laravel Short Url
A Laravel package to shorten urls
Stars: ✭ 127 (-23.95%)
Mutual labels:  laravel, package
Laravel Totem
Manage Your Laravel Schedule From A Web Dashboard
Stars: ✭ 1,299 (+677.84%)
Mutual labels:  laravel, package
Nova Cashier Manager
Managing Stripe subscriptions inside the incredible Laravel Nova admin panel.
Stars: ✭ 150 (-10.18%)
Mutual labels:  laravel, package
Laravel Package Maker
Get a 📦 skeleton and all other `make` commands from laravel base for package development.
Stars: ✭ 89 (-46.71%)
Mutual labels:  laravel, package
Flex Env
🌳 Manage your .env file in Laravel projects through artisan
Stars: ✭ 95 (-43.11%)
Mutual labels:  laravel, package
Laravel Nullable Fields
Handles saving empty fields as null for Eloquent models
Stars: ✭ 88 (-47.31%)
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 (-28.74%)
Mutual labels:  laravel, package
Manager
Implementation of the Manager pattern existing in Laravel framework
Stars: ✭ 74 (-55.69%)
Mutual labels:  laravel, package
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 (-52.69%)
Mutual labels:  laravel, package
Roadrunner Laravel
[ABANDONED] Moved to https://github.com/spiral/roadrunner-laravel
Stars: ✭ 124 (-25.75%)
Mutual labels:  laravel, package
Youtube
Upload a video to a single YouTube channel with Laravel 5.
Stars: ✭ 143 (-14.37%)
Mutual labels:  laravel, package

logo

RoadRunner ⇆ Laravel bridge

Version Version Build Status Coverage Downloads count License

Source code of this package was transferred from avto-dev/roadrunner-laravel package by its author. Release v3.3.0 are same in both packages. Any future releases will be published in this repository (previous package was abandoned).

Easy way for connecting RoadRunner and Laravel applications.

Installation

Make sure that RR binary file already installed on your system (or docker image). Require this package with composer using next command:

$ composer require spiral/roadrunner-laravel "^4.0"

Installed composer is required (how to install composer).

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

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

Important: despite the fact that worker allows you to refresh application instance on each HTTP request (if worker started with option --refresh-app, eg.: php ./vendor/bin/rr-worker start --refresh-app), we strongly recommend avoiding 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.

Upgrading guide (v3.xv4.x)

  • Update current package in your application:
    • composer remove spiral/roadrunner-laravel
    • composer require spiral/roadrunner-laravel "^4.0"
  • Update your .rr.yaml config (take a look for sample here) - a lot of options was changed
    • Optionally change relay to socket or TCP port:
      server:
        command: "php ./vendor/bin/rr-worker start --relay-dsn unix:///var/run/rr-rpc.sock"
        relay: "unix:///var/run/rr-rpc.sock"
      
  • Update RR binary file (using roadrunner-cli or download from binary releases page) up to v2.x
  • Update RoadRunner starting (rr serve ...) flags - -v and -d must be not used anymore
  • In your application code replace Spiral\RoadRunner\PSR7Client with Spiral\RoadRunner\Http\PSR7Worker

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 outgoing responses using laravel events system. Event 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 (full example can be found here):

For windows path must be full (eg.: php vendor/spiral/roadrunner-laravel/bin/rr-worker start)

server:
  command: "php ./vendor/bin/rr-worker start --relay-dsn unix:///var/run/rr-rpc.sock"
  relay: "unix:///var/run/rr-rpc.sock"

http:
  address: 0.0.0.0:8080
  middleware: ["headers", "static", "gzip"]
  pool:
    max_jobs: 64 # feel free to change this
    supervisor:
      exec_ttl: 60s
  headers:
    response:
      X-Powered-By: "RoadRunner"
  static:
    dir: "public"
    forbid: [".php"]

Socket or TCP port relay usage is strongly recommended for avoiding problems with dd(), dump(), echo() and other similar functions, that sends data to the IO pipes.

Roadrunner server starting:

$ rr serve -c ./.rr.yaml

Listeners

This package provides event listeners for resetting 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.

Known issues

Controller constructors

You should avoid to use HTTP controller constructors (created or resolved instances in a constructor can be shared between different requests). Use dependencies resolving in a 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 find any package errors, please, make an issue in a current repository.

License

MIT License (MIT). Please see LICENSE for more information. Maintained by tarampampam and Spiral Scout.

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].