LaravelFly is a safe solution to speeds up new or old Laravel 5.5+ projects, with preloading and coroutine, while without data pollution or memory leak

Overview

Would you like php 7.4 Preloading? Would you like php coroutine? Today you can use them with Laravel because of Swoole. With LaravalFly, Laravel will begin like Django 3.0 to be fully async-capable.

LaravelFly is a safe solution to speeds up new or old Laravel 5.5+ projects, with preloading and coroutine, while without data pollution or memory leak. And it makes Tinker available online (use tinker while Laravel is responding requests from browsers).

Thanks to Laravel, Swoole and PsySh.

Notice: Great News! Laravel is going to support Swoole offcially!

A simple ab test

ab -k -n 1000 -c 10 http://zc.test (21 sql statements were executed in single request)

. fpm Fly
Time taken ≈ 43.5 s 12.3 s
Requests per second 23 81.5
50% 303 ms 117 ms
80% 360 ms 153 ms
99% 1341 ms 239 ms
Test Env
  • env:
    • ubuntu 16.04 on VirtualBox ( 1 CPU: i7-7700HQ 2.80GHz ; Memory: 2G )
    • php7.2 + opcache + 5 workers for both fpm and laravelfly ( phpfpm : pm=static pm.max_children=5)
    • connection pool and coroutine mysql
  • Test date : 2018/10

Version Compatibility

  • Laravel 5.5 ~ 6.0
  • Swoole >4.2.13

Quick Start

1.pecl install swoole
Make sure extension=swoole.so in config file for php cli, not for fpm.
Suggest: pecl install inotify

2.composer require "scil/laravel-fly":"dev-master"

3.php vendor/scil/laravel-fly/bin/fly start
If you enable eval(tinker()) and see an error about mkdir, you can start LaravelFly with sudo.

Now, your project is flying and listening to port 9501. Enjoy yourself.

Docker-compose

composer require "scil/laravel-fly":"dev-master"

php artisan vendor:publish --tag=fly-server

# 127.0.0.1:8080
# you can edit this docker-compos file and use your own nginx conf
docker-compose -f vendor/scil/laravel-fly-local/docker/docker-compose.yml up -d

Doc

Configuration

Commands: Start, Reload & Debug

Coding Guideline

Events about LaravelFly

Using tinker when Laravel Working

For Dev

Recommended Packages

  • swlib/saber Coroutine HTTP client, based on Swoole\Coroutine\Http\Client.
    Browser-like cookie managment, multiple requests concurrent, request/response interceptors and so on.
    To ensure safety, set const LARAVELFLY_COROUTINE = true; in fly.conf.php.

Features and Behaviors

  • Same codes can run on PHP-FPM or LaravelFly. LaravelFly can be installed on your existing projects without affecting nginx/apache server, that's to say, you can run LaravelFly server and nginx/apache server simultaneously to run the same laravel project. The nginx conf swoole_fallback_to_phpfpm.conf allow you use LaravelFlyServer as the primary server, and the phpfpm as a backup server which will be passed requests when the LaravelFlyServer is unavailable. Another nginx conf use_swoole_or_fpm_depending_on_clients allows us use query string ?useserver= to select the server between swoole or fpm. That's wonderful for test, such as to use eval(tinker()) as a online debugger for your fpm-supported projects. Apache? There is a example Cooperate with Apache from laravel-s.

  • Moderate strategy: by default, each Third Party service provider is registered on server worker process (before the first request arrived at server) , booted in request.

  • By default, all Laravel official services are COROUTINE-FRIENDLY, including mysql and redis. You can make a service or object before any requests. There are two ways:

    • let the service or object live in multiple requests (only one instance of the service). LaravelFly named it WORKER SERVICE, WORKER OBJECT or COROUTINE-FRIENDLY SERVICE/OBJECT.
    • cloned the service or object in each request (one instance in one request).LaravelFly named it CLONE SERVICE or CLONE OBJECT. This way is simple, but often has the problem Stale Reference. This type is used widely by laravel-swoole and laravel-s, while used rarely by LaravelFly.
  • Extra speed improvements such as connection pool, middlewares cache, view path cache.

  • Check server info at /laravel-fly/info. (This feture is under dev and more infomations will be available.)

  • No support for static files any more, so use it with other servers. Conf examples: nginx or Apache

  • swoole-job,A Laravel job or event listener can be delivered into a swoole task process and executed at once artisan queue:work needless any more.

  • exit() or die() in an route action would output content to console or swoole log, and not make server die or reload. If you would like to change that behavior, fork LaravalFly and catch \Swoole\ExitException in LaravelFly\Map\Kernel::handle.

  • Support connection pool. There's only one connection available in each request.But if you use fly() or fly2(), you can use connections more than one.

  • functions fly() and fly2() which are like go() provided by golang or swoole, plus Laravel services can be used in fly() and fly2() without closure. The fly2() has the limited ability to change services in current request, e.g. registering a new event handler for current request. fly2() is not suggested.

A coroutine starting in a request, can still live when the request ends. What's the effect of following route?
It responds with 'coroutine1; outer1; coroutine2; outer2; outer3',
but it write log 'coroutine1; outer1; coroutine2; outer2; outer3; coroutine2.end; coroutine1.end'

// ensure ` const LARAVELFLY_COROUTINE = true;` in fly.conf.php

Route::get('/fly', function () {

    $a = [];
    
    fly(function () use (&$a) {
    
        $a[] = 'coroutine1';
        \co::sleep(2);
        $a[] = 'coroutine1.end';
        \Log::info(implode('; ', $a));
        
        // Eloquent can be used even if current request has ended.
        // $user = new User();
        // $user->name = implode('; ',$a);
        // $user->save();
        
    });

    $a[] = 'outer1';
    

    // go() can use laravel service  with closure
    $log = app('log');
    go(function () use (&$a, $log) {
        $a[] = 'coroutine2';
        \co::sleep(1.2);
        $a[] = 'coroutine2.end';
    });

    $a[] = 'outer2';

    \co::sleep(1);

    $a[] = 'outer3';

    return implode(';', $a);

});

Similar projects that mix swoole and laravel

The main distinguishing feature of LaravalFly is refactoring Laravel, like what Django 3.0 does.

1. laravel-swoole

It is alse a safe sollution. It has supported Lumen and websocket. Its doc is great and also useful for LaravelFly.

The main difference is that in laravel-swoole user's code will be processed by a new app cloned from SwooleTW\Http\Server\Application::$application and laravel-swoole updates related container bindings to the new app. However in LaravelFly, the sandbox is not a new app, but an item in the $corDict of the unique application container.
In LaravelFly, most other objects such as app, event.... always keep one object in a worker process, clone is not used at all by default. LaravelFly makes most of laravel objects keep safe on their own. It's about high cohesion & low coupling and the granularity is at the level of app container or services/objects. For users of laravel-swoole, it's a big challenge to handle the relations of multiple packages and objects which to be booted before any requests. Read Stale Reference.

. technique work to maintaining relations of cloned objects to avoid Stale Reference
laravel-swoole clone app contaniner and objects to make them safe more work (as app,event...are cloned)
LaravelFly Mode Map refactor most official objects to make them safe on their own few work ( nothing is cloned by default)

In LaravelFly, another benefit of non-cloned objects is allowing some improvements, such as event listeners cache, route middlewares cache.

2. laravel-s

Many great features!

About data pollution? Same technique and problems as laravel-swoole. And neither support coroutine jumping (from one request to another request).

Todo About Improvement

  • Pre-include. Server configs 'pre_include' and 'pre_files'.
  • Server config 'early_laravel'
  • Cache for LaravelFly app config. laravelfly_ps_map.php or laravelfly_ps_simple.php located bootstrap/cache
  • Cache for Log. Server options 'log_cache'.
  • Watching maintenance mode using swoole_event_add. No need to check file storage/framework/down in every request.
  • Cache for kernel middlewares objects. Kernel::getParsedKernelMiddlewares, only when LARAVELFLY_SERVICES['kernel'] is true.
  • Cache for route middlewares. $cacheByRoute in Router::gatherRouteMiddleware, only useful when all route middleaes are reg on worker.
  • Cache for route middlewares objects. config('laravelfly.singleton_route_middlewares') and $cacheForObj in Router::gatherRouteMiddleware, avoid creating instances repeatly.
  • Cache for terminateMiddleware objects.
  • Cache for event listeners. $listenersStalbe in LaravelFly\Map\IlluminateBase\Dispatcher
  • Cache for view compiled path. LARAVELFLY_SERVICES['view.finder'] or App config 'view_compile_1'
  • Mysql coroutine. Old code dropped, laravel-s used.
  • db connection pool and redis connection pool. In fly() or fly2(), connections to be used would be fetched from pool, not inherit the same connections from request coroutine. code: $this->connections[$childId] = []; in ConnectionsTrait.php
  • swoole redis driver
  • swoole redis driver: how to use errMsg errCode
  • use hyperf/database to replace official version?
  • use swlib/swpdo to replace SwoolePDO?
  • Cache for HasRelationships. disable and experimental, not ready
  • Cache for RouteDependencyResolverTrait
  • Converting between swoole request/response and Laravel Request/Response
  • safe: auth, remove some props?
  • use: https://github.com/louislivi/smproxy
  • use: https://github.com/kcloze/swoole-jobs or https://github.com/osgochina/Donkey

Other Todo

  • add events
  • watch code changes and hot reload
  • supply server info. default url is: /laravel-fly/info
  • function fly()
  • job executed in task process. Related: vendor\scil\laravel-fly-files-local\src\Foundation\Bus\
  • event listeners executed in task process. Related: LaravelFly\Map\IlluminateBase\Dispatcher and vendor\scil\laravel-fly-files\src\Foundation\Support\Providers\EventServiceProvider.php
  • use $this->output instead of echo() in Common.php
  • bootstrap all service providers in task process
  • try ocramius/generated-hydrator for laravel-fly/info when its version 3 is ready (it will require nikic/php-parser v4 which is needed by others) // or Zend\Hydrator\Reflection?
  • add tests about auth SessionGuard: Illuminate/Auth/SessionGuard.php with uses Request::createFromGlobals
  • add tests about uploaded file, related symfony/http-foundation files: File/UploadedFile.php and FileBag.php(fixPhpFilesArray)
  • websocket
  • send file
  • travis, static analyze like phan, phpstan or https://github.com/exakat/php-static-analysis-tools
  • cache fly
Comments
  • 修改建议

    修改建议

    wiki说明修改

    https://github.com/scil/LaravelFly/wiki/Configuration 修改

    class WhichKernel extends \LaravelFly\MidKernel{}
    

    class WhichKernel extends \LaravelFly\Kernel{}
    

    代码修改

    src/LaravelFly/Map/Util/Dict.php中,修改if (static::$normalAttriForObj ?? false) {if (isset(static::$normalAttriForObj)) {

    类似的还有static::$arrayAttriForObj, static::$arrayStaticAttri

    opened by zhenyangze 17
  • Function name must be a string

    Function name must be a string

    in my laravel 5.6 application I am getting a strange error on every request.

    What is possibaly going wrong here?

    Symfony\Component\Debug\Exception\FatalThrowableError thrown with message "Function name must be a string"
    
    Stacktrace:
    #6 Symfony\Component\Debug\Exception\FatalThrowableError in /srv/site-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:152
    #5 LaravelFly\Server\HttpServer:onRequest in /srv/site-laravel/vendor/scil/laravel-fly/src/LaravelFly/Server/HttpServer.php:0
    #4 Swoole\Http\Server:start in /srv/site-laravel/vendor/scil/laravel-fly/src/LaravelFly/Server/Common.php:273
    #3 LaravelFly\Server\HttpServer:start in /srv/site-laravel/vendor/scil/laravel-fly/src/LaravelFly/Server/HttpServer.php:26
    #2 LaravelFly\Server\HttpServer:start in /srv/site-laravel/vendor/scil/laravel-fly/src/LaravelFly/Fly.php:70
    #1 LaravelFly\Fly:start in /srv/site-laravel/vendor/scil/laravel-fly/bin/fly:78
    #0 {main} in /srv/site-laravel/vendor/scil/laravel-fly/bin/fly:0
    
    opened by aftabnaveed 8
  • 启动报错,#21 {main}[FLY ERROR] bootstrap: Class xxxx does not exist

    启动报错,#21 {main}[FLY ERROR] bootstrap: Class xxxx does not exist

    1. laravel5.6最基本的版本中,是没有问题的。
    2. 迁移到项目上后,开始报错了。
    3. 提示找不到files方法,修改后会提示找不到Auth方法。

    provider

        'providers' => [
    
            /*
             * Laravel Framework Service Providers...
             */
            Illuminate\Auth\AuthServiceProvider::class,
            Illuminate\Broadcasting\BroadcastServiceProvider::class,
            Illuminate\Bus\BusServiceProvider::class,
            Illuminate\Cache\CacheServiceProvider::class,
            Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
            Illuminate\Cookie\CookieServiceProvider::class,
            Illuminate\Database\DatabaseServiceProvider::class,
            Illuminate\Encryption\EncryptionServiceProvider::class,
            Illuminate\Filesystem\FilesystemServiceProvider::class,
            Illuminate\Foundation\Providers\FoundationServiceProvider::class,
            Illuminate\Hashing\HashServiceProvider::class,
            Illuminate\Mail\MailServiceProvider::class,
            Illuminate\Notifications\NotificationServiceProvider::class,
            Illuminate\Pagination\PaginationServiceProvider::class,
            Illuminate\Pipeline\PipelineServiceProvider::class,
            Illuminate\Queue\QueueServiceProvider::class,
            Illuminate\Redis\RedisServiceProvider::class,
            Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
            Illuminate\Session\SessionServiceProvider::class,
            Illuminate\Translation\TranslationServiceProvider::class,
            Illuminate\Validation\ValidationServiceProvider::class,
            Illuminate\View\ViewServiceProvider::class,
    
            /*
             * Package Service Providers...
             */
    
            /*
             * Application Service Providers...
             */
            App\Providers\AppServiceProvider::class,
            App\Providers\AuthServiceProvider::class,
            // App\Providers\BroadcastServiceProvider::class,
            App\Providers\EventServiceProvider::class,
            App\Providers\RouteServiceProvider::class,
            Laravel\Passport\PassportServiceProvider::class,
            SimpleSoftwareIO\QrCode\QrCodeServiceProvider::class,
    
            Intervention\Image\ImageServiceProvider::class,
            \Yangyifan\Upload\UploadServiceProvider::class,
            \App\Providers\Cee\Volunteer\VolunteerProvider::class,
            App\Providers\Cee\Major\EvaluationProvider::class,
            App\Providers\Im\TimProvider::class,
            //Hhxsv5\LaravelS\Illuminate\LaravelSServiceProvider::class,
            Silber\PageCache\LaravelServiceProvider::class,
        ],
    

    错误代码

    #0 /www/htdocs/vendor/scil/laravel-fly-files/src/Container.php(701): ReflectionClass->__construct('files')
    #1 /www/htdocs/vendor/scil/laravel-fly-files/src/Container.php(578): Illuminate\Container\Container->build('files')
    #2 /www/htdocs/vendor/scil/laravel-fly-files/src/Container.php(533): Illuminate\Container\Container->resolve('files', -1, Array)
    #3 /www/htdocs/vendor/scil/laravel-fly-files/src/Application.php(697): Illuminate\Container\Container->make('files', Array)
    #4 /www/htdocs/vendor/scil/laravel-fly-files/src/Container.php(1154): Illuminate\Foundation\Application->make('files')
    #5 /www/htdocs/vendor/barryvdh/laravel-ide-helper/src/IdeHelperServiceProvider.php(118): Illuminate\Container\Container->offsetGet('files')
    #6 /www/htdocs/vendor/barryvdh/laravel-ide-he#0 /www/htdocs/vendor/scil/laravel-fly-files/src/Container.php(701): ReflectionClass->__construct('files')
    #1 /www/htdocs/vendor/scil/laravel-fly-files/src/Container.php(578): Illuminate\Container\Container->build('files')
    #2 /www/htdocs/vendor/scil/laravel-fly-files/src/Container.php(533): Illuminate\Container\Container->resolve('files', -1, Array)
    #3 /www/htdocs/vendor/scil/laravel-fly-files/src/Application.php(697): Illuminate\Container\Container->make('files', Array)
    #4 /www/htdocs/vendor/scil/laravel-fly-files/src/Container.php(1154): Illuminate\Foundation\Application->make('files')
    #5 /www/htdocs/vendor/barryvdh/laravel-ide-helper/src/IdeHelperServiceProvider.php(118): Illuminate\Container\Container->offsetGet('files')
    #6 /www/htdocs/vendor/barryvdh/laravel-ide-helper/src/IdeHelperServiceProvider.php(61): Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider->createLocalViewFactory()
    #7 /www/htdocs/vendor/scil/laravel-fly-files/src/Application.php(546): Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider->register()
    #8 /www/htdocs/app/Providers/AppServiceProvider.php(53): Illuminate\Foundation\Application->register(Object(Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider))
    #9 /www/htdocs/vendor/scil/laravel-fly-files/src/Application.php(546): App\Providers\AppServiceProvider->register()
    #10 /www/htdocs/vendor/scil/laravel-fly/src/LaravelFly/Backup/ProviderRepository.php(28): Illuminate\Foundation\Application->register(Object(App\Providers\AppServiceProvider))
    #11 /www/htdocs/vendor/scil/laravel-fly/src/LaravelFly/Map/Application.php(242): LaravelFly\Backup\ProviderRepository->load(Array)
    #12 /www/htdocs/vendor/scil/laravel-fly/src/LaravelFly/Map/Bootstrap/RegisterAcrossProviders.php(10): LaravelFly\Map\Application->registerAcrossProviders()
    #13 /www/htdocs/vendor/scil/laravel-fly-files/src/Application.php(172): LaravelFly\Map\Bootstrap\RegisterAcrossProviders->bootstrap(Object(LaravelFly\Map\Application))
    #14 /www/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(162): Illuminate\Foundation\Application->bootstrapWith(Array)
    #15 /www/htdocs/vendor/scil/laravel-fly/src/LaravelFly/Server/Traits/Laravel.php(90): Illuminate\Foundation\Http\Kernel->bootstrap()
    #16 /www/htdocs/vendor/scil/laravel-fly/src/LaravelFly/Server/HttpServer.php(32): LaravelFly\Server\Common->startLaravel()
    #17 [internal function]: LaravelFly\Server\HttpServer->onWorkerStart(Object(Swoole\Http\Server), 3)
    #18 /www/htdocs/vendor/scil/laravel-fly/src/LaravelFly/Server/Common.php(311): Swoole\Http\Server->start()
    #19 /www/htdocs/vendor/scil/laravel-fly/src/LaravelFly/Server/HttpServer.php(23): LaravelFly\Server\Common->start()
    #20 /www/htdocs/vendor/scil/laravel-fly/bin/fly(84): LaravelFly\Server\HttpServer->start()
    #21 {main}[FLY ERROR] bootstrap: Class files does not exist
    
    opened by zhenyangze 6
  • Version compatibility issue with laravel 5.7.27

    Version compatibility issue with laravel 5.7.27

    Laravel Version: 5.7.27 I ran the following command: composer require "scil/laravel-fly":"dev-master" I got the following error: Problem 1 - scil/laravel-fly-files v5.6.39.4 requires laravel/framework 5.6.39 -> satisfiable by laravel/framework[v5.6.39] but these conflict with your requirements or minimum-stability. - scil/laravel-fly-files v5.6.39.3 requires laravel/framework 5.6.39 -> satisfiable by laravel/framework[v5.6.39] but these conflict with your requirements or minimum-stability. - scil/laravel-fly-files v5.6.39.2 requires laravel/framework 5.6.39 -> satisfiable by laravel/framework[v5.6.39] but these conflict with your requirements or minimum-stability. - scil/laravel-fly-files v5.6.39.1 requires laravel/framework 5.6.39 -> satisfiable by laravel/framework[v5.6.39] but these conflict with your requirements or minimum-stability. - scil/laravel-fly-files v5.6.38.7 requires laravel/framework 5.6.38 -> satisfiable by laravel/framework[v5.6.38] but these conflict with your requirements or minimum-stability. - scil/laravel-fly-files v5.6.38.6 requires laravel/framework 5.6.38 -> satisfiable by laravel/framework[v5.6.38] but these conflict with your requirements or minimum-stability. - scil/laravel-fly-files v5.6.38.5 requires laravel/framework 5.6.38 -> satisfiable by laravel/framework[v5.6.38] but these conflict with your requirements or minimum-stability. - scil/laravel-fly-files v5.6.38.4 requires laravel/framework 5.6.38 -> satisfiable by laravel/framework[v5.6.38] but these conflict with your requirements or minimum-stability. - scil/laravel-fly-files v5.6.38.3 requires laravel/framework 5.6.38 -> satisfiable by laravel/framework[v5.6.38] but these conflict with your requirements or minimum-stability. - scil/laravel-fly-files v5.6.38.2 requires laravel/framework 5.6.38 -> satisfiable by laravel/framework[v5.6.38] but these conflict with your requirements or minimum-stability. - scil/laravel-fly-files v5.6.38.1 requires laravel/framework 5.6.38 -> satisfiable by laravel/framework[v5.6.38] but these conflict with your requirements or minimum-stability. - scil/laravel-fly-files v5.5.4402 requires laravel/framework 5.5.44 -> satisfiable by laravel/framework[v5.5.44] but these conflict with your requirements or minimum-stability. - scil/laravel-fly-files v5.5.4401 requires laravel/framework 5.5.44 -> satisfiable by laravel/framework[v5.5.44] but these conflict with your requirements or minimum-stability. - scil/laravel-fly-files v5.5.4307 requires laravel/framework 5.5.43 -> satisfiable by laravel/framework[v5.5.43] but these conflict with your requirements or minimum-stability. - scil/laravel-fly-files v5.5.4306 requires laravel/framework 5.5.43 -> satisfiable by laravel/framework[v5.5.43] but these conflict with your requirements or minimum-stability. - scil/laravel-fly-files v5.5.4305 requires laravel/framework 5.5.43 -> satisfiable by laravel/framework[v5.5.43] but these conflict with your requirements or minimum-stability. - scil/laravel-fly-files v5.5.4304 requires laravel/framework 5.5.43 -> satisfiable by laravel/framework[v5.5.43] but these conflict with your requirements or minimum-stability. - scil/laravel-fly-files v5.5.4303 requires laravel/framework 5.5.43 -> satisfiable by laravel/framework[v5.5.43] but these conflict with your requirements or minimum-stability. - scil/laravel-fly-files v5.5.4302 requires laravel/framework 5.5.43 -> satisfiable by laravel/framework[v5.5.43] but these conflict with your requirements or minimum-stability. - scil/laravel-fly-files v5.5.4301 requires laravel/framework 5.5.43 -> satisfiable by laravel/framework[v5.5.43] but these conflict with your requirements or minimum-stability. - scil/laravel-fly-files v5.5.43 requires laravel/framework 5.5.43 -> satisfiable by laravel/framework[v5.5.43] but these conflict with your requirements or minimum-stability. - scil/laravel-fly-files v5.5.4001 requires laravel/framework 5.5.40 -> satisfiable by laravel/framework[v5.5.40] but these conflict with your requirements or minimum-stability. - scil/laravel-fly-files 5.6.x-dev requires laravel/framework 5.6.39 -> satisfiable by laravel/framework[v5.6.39] but these conflict with your requirements or minimum-stability. - scil/laravel-fly-files 5.5.x-dev requires laravel/framework 5.5.44 -> satisfiable by laravel/framework[v5.5.44] but these conflict with your requirements or minimum-stability. - scil/laravel-fly dev-master requires scil/laravel-fly-files 5.5.* || 5.6.* || 5.7.* -> satisfiable by scil/laravel-fly-files[5.5.x-dev, 5.6.x-dev, v5.5.4001, v5.5.43, v5.5.4301, v5.5.4302, v5.5.4303, v5.5.4304, v5.5.4305, v5.5.4306, v5.5.4307, v5.5.4401, v5.5.4402, v5.6.38.1, v5.6.38.2, v5.6.38.3, v5.6.38.4, v5.6.38.5, v5.6.38.6, v5.6.38.7, v5.6.39.1, v5.6.39.2, v5.6.39.3, v5.6.39.4]. - Installation request for scil/laravel-fly dev-master -> satisfiable by scil/laravel-fly[dev-master].

    Installation failed, reverting ./composer.json to its original content.

    opened by harishdurga 5
  • Database refactor & Postgresql support

    Database refactor & Postgresql support

    Is there any plans to add support for Postgresql?

    Currently I see for mysql using SwooleMySQLConnection & CoroutineMySQLConnector from Hhxsv5\LaravelS\Illuminate\Database

    Coroutine Postgresql also supported in Swoole since > 6 months ago: https://github.com/swoole/swoole-src/blob/master/examples/postgresql/postgresql_coro.php

    I can make a PR to add it, if you like?

    opened by tamer-hassan 5
  • Can't find fly executable

    Can't find fly executable

    I successfully installed the LaravelFly via composer require "scil/laravel-fly":"dev-master"

    But when when I goto vendor/bin/ folder I don't see

    the fly executable there What could I be doing wrong here?

    opened by aftabnaveed 5
  • i got  504 error when i followed your config steps

    i got 504 error when i followed your config steps

    nginx: server { listen 80; error_log /usr/local/nginx/logs/error.log; charset utf-8; root /Users/liufa/Documents/www/laravel_blog/public; server_name www.laravel_blogfly.com;

    # useful when debug
    #504 Gateway timeout error http://stackoverflow.com/questions/18229757/nginx-php-fpm-xdebug-netbeans-can-start-only-one-debug-session
    
    # for firefox, otherwise firefox may dowload some page; default file type is: octet-stream
    include /usr/local/nginx/mime.types; default_type text/html; 
    location / {
        # you can place index.html on document root dir
        index  index.php index.html;
        try_files $uri $uri/ @other;
    }
    
    location = / {
        proxy_http_version 1.1;
        proxy_set_header Connection "keep-alive";
        proxy_pass http://127.0.0.1:9501;
        proxy_set_header    X-Real-IP        $remote_addr;
        proxy_set_header    X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header    Host             $http_host;
    }
    location @other {
        proxy_http_version 1.1;
        proxy_set_header Connection "keep-alive";
        proxy_pass http://127.0.0.1:9501;
        proxy_set_header    X-Real-IP        $remote_addr; 
        proxy_set_header    X-Forwarded-For  $proxy_add_x_forwarded_for; 
        proxy_set_header    Host             $http_host;
     }
    

    }

    opened by jonny77 5
  • LaravelFly\Kernel path

    LaravelFly\Kernel path

    https://github.com/scil/LaravelFly/blob/b19aa94240640d55d17efea81dee999d20d257be/src/LaravelFly/Server/Common.php#L74

    'Http/Kernel.php' should now be just 'Kernel.php' ? since you moved the kernel a directory up before.

    opened by tamer-hassan 4
  • laravel 5.6 无法正常运行

    laravel 5.6 无法正常运行

    使用默认配置 start后报错

    [INFO] conf: /opt/www/laravel-test/fly.conf.php
    [INFO] server dispatcher created
    [INFO] event server.config
    [INFO] include: /opt/www/laravel-test/bootstrap/cache/laravelfly_preload.php
    [WARN] kernel: LaravelFly\Kernel
    [INFO] event server.created for LaravelFly\Server\HttpServer
    [INFO] event worker.starting for 0 (pid 24042)
    [INFO] event worker.starting for 1 (pid 24043)
    [INFO] event worker.starting for 2 (pid 24044)
    [INFO] event worker.starting for 3 (pid 24045)
    [INFO] event worker.starting for 4 (pid 24046)
    [INFO] event app.created for \LaravelFly\Simple\Application (pid 24043)
    [INFO] event app.created for \LaravelFly\Simple\Application (pid 24044)
    [INFO] event app.created for \LaravelFly\Simple\Application (pid 24045)
    [INFO] event app.created for \LaravelFly\Simple\Application (pid 24042)
    [INFO] event app.created for \LaravelFly\Simple\Application (pid 24046)
    [ERROR] bootstrap: Whoops\Exception\ErrorException: array_diff(): Argument #2 is not an array in /opt/www/laravel-test/vendor/scil/laravel-fly/src/LaravelFly/Simple/Bootstrap/LoadConfiguration.php:39
    Stack trace:
    #0 [internal function]: Whoops\Run->handleError(2, 'array_diff(): A...', '/opt/www/larave...', 39, Array)
    #1 /opt/www/laravel-test/vendor/scil/laravel-fly/src/LaravelFly/Simple/Bootstrap/LoadConfiguration.php(39): array_diff(Array, NULL, NULL)
    #2 /opt/www/laravel-test/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(206): LaravelFly\Simple\Bootstrap\LoadConfiguration->bootstrap(Object(LaravelFly\Simple\Application))
    #3 /opt/www/laravel-test/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(162): Illuminate\Foundation\Application->bootstrapWith(Array)
    #4 /opt/www/laravel-test/vendor/scil/laravel-fly/src/LaravelFly/Server/HttpServer.php(59): Illuminate\Foundation\Http\Kernel->bootstrap()
    #5 {main}
    [ERROR] bootstrap: Whoops\Exception\ErrorException: array_diff(): Argument #2 is not an array in /opt/www/laravel-test/vendor/scil/laravel-fly/src/LaravelFly/Simple/Bootstrap/LoadConfiguration.php:39
    Stack trace:
    #0 [internal function]: Whoops\Run->handleError(2, 'array_diff(): A...', '/opt/www/larave...', 39, Array)
    #1 /opt/www/laravel-test/vendor/scil/laravel-fly/src/LaravelFly/Simple/Bootstrap/LoadConfiguration.php(39): array_diff(Array, NULL, NULL)
    #2 /opt/www/laravel-test/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(206): LaravelFly\Simple\Bootstrap\LoadConfiguration->bootstrap(Object(LaravelFly\Simple\Application))
    #3 /opt/www/laravel-test/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(162): Illuminate\Foundation\Application->bootstrapWith(Array)
    #4 /opt/www/laravel-test/vendor/scil/laravel-fly/src/LaravelFly/Server/HttpServer.php(59): Illuminate\Foundation\Http\Kernel->bootstrap()
    #5 {main}
    [INFO] event worker.ready for id 1
    [INFO] event worker.ready for id 2
    [ERROR] bootstrap: Whoops\Exception\ErrorException: array_diff(): Argument #2 is not an array in /opt/www/laravel-test/vendor/scil/laravel-fly/src/LaravelFly/Simple/Bootstrap/LoadConfiguration.php:39
    Stack trace:
    #0 [internal function]: Whoops\Run->handleError(2, 'array_diff(): A...', '/opt/www/larave...', 39, Array)
    #1 /opt/www/laravel-test/vendor/scil/laravel-fly/src/LaravelFly/Simple/Bootstrap/LoadConfiguration.php(39): array_diff(Array, NULL, NULL)
    #2 /opt/www/laravel-test/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(206): LaravelFly\Simple\Bootstrap\LoadConfiguration->bootstrap(Object(LaravelFly\Simple\Application))
    #3 /opt/www/laravel-test/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(162): Illuminate\Foundation\Application->bootstrapWith(Array)
    #4 /opt/www/laravel-test/vendor/scil/laravel-fly/src/LaravelFly/Server/HttpServer.php(59): Illuminate\Foundation\Http\Kernel->bootstrap()
    #5 {main}
    [INFO] event worker.ready for id 3
    [2018-05-22 15:34:04 #24034.5]  NOTICE  Server is shutdown now.
    [INFO] event worker.stopped for id 2
    [INFO] event worker.stopped for id 1
    [INFO] event worker.stopped for id 3
    
    
    opened by hooklife 4
  • preload error: the name is already in use

    preload error: the name is already in use

    `[INFO] include: /project/bootstrap/cache/laravelfly_preload.php

    Fatal error: Cannot declare class Monolog\Handler\AbstractHandler, because the name is already in use in /project/bootstrap/\cache/laravelfly_preload.php on line 16140`

    opened by stevenyangecho 4
  • support laravel5.6 5.7

    support laravel5.6 5.7

    composer require scil/laravel-fly

    Using version ^0.9.2 for scil/laravel-fly ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages.

    Problem 1

    - scil/laravel-fly-files v5.5.4302 requires laravel/framework 5.5.43 -> satisfiable by laravel/framework[v5.5.43] but these conflict with your requirements or minimum-stability.
    - scil/laravel-fly-files v5.5.4301 requires laravel/framework 5.5.43 -> satisfiable by laravel/framework[v5.5.43] but these conflict with your requirements or minimum-stability.
    - scil/laravel-fly-files v5.5.43 requires laravel/framework 5.5.43 -> satisfiable by laravel/framework[v5.5.43] but these conflict with your requirements or minimum-stability.
    - scil/laravel-fly-files v5.5.4001 requires laravel/framework 5.5.40 -> satisfiable by laravel/framework[v5.5.40] but these conflict with your requirements or minimum-stability.
    - scil/laravel-fly-files 5.5.x-dev requires laravel/framework 5.5.43 -> satisfiable by laravel/framework[v5.5.43] but these conflict with your requirements or minimum-stability.
    - Installation request for scil/laravel-fly ^0.9.2 -> satisfiable by scil/laravel-fly[v0.9.2].
    - Can only install one of: laravel/framework[v5.6.35, v5.6.28].
    - Can only install one of: laravel/framework[v5.6.28, v5.6.35].
    - Can only install one of: laravel/framework[v5.6.28, v5.6.35].
    - scil/laravel-fly-files 5.6.x-dev requires laravel/framework 5.6.28 -> satisfiable by laravel/framework[v5.6.28].
    - scil/laravel-fly v0.9.2 requires scil/laravel-fly-files 5.5.* || 5.6.* -> satisfiable by scil/laravel-fly-files[5.5.x-dev, 5.6.x-dev, v5.5.4001, v5.5.43, v5.5.4301, v5.5.4302, v5.6.38.1, v5.6.38.2].
    - scil/laravel-fly-files v5.6.38.1 requires laravel/framework 5.6.38 -> satisfiable by laravel/framework[v5.6.38].
    - scil/laravel-fly-files v5.6.38.2 requires laravel/framework 5.6.38 -> satisfiable by laravel/framework[v5.6.38].
    - Conclusion: don't install laravel/framework v5.6.38
    - Installation request for laravel/framework (locked at v5.6.35, required as 5.6.*) -> satisfiable by laravel/framework[v5.6.35].
    

    Installation failed, reverting ./composer.json to its original content.

    opened by zhenyangze 3
  • docker fpm fallback 502 bad gateway

    docker fpm fallback 502 bad gateway

    My docker-compose

    #Docker Networks
    networks:
      app-network:
        driver: bridge
    services:
      app:
        build: php-fpm
        container_name: app
        restart: always
        ports:
          - "9501:9501"
        #      - "9000:9000"
        #      - "81:81"
        expose:
          - 80
          - 9501
          - 9000
        #    entrypoint: "php vendor/scil/laravel-fly/bin/fly start"
        entrypoint: "php-fpm"
        environment:
          SERVICE_NAME: app
          SERVICE_TAGS: dev
        volumes:
          - ${APP_PATH_HOST}:${APP_PATH_CONTAINER}
          - ./php-fpm/config:/usr/local/etc/php
        working_dir: ${APP_PATH_CONTAINER}
        networks:
          - app-network
    
      #Nginx Service
      nginx:
        build: nginx
        restart: always
        ports:
          - "80:80"
          - "443:443"
        networks:
          - app-network
        working_dir: /app
        volumes:
          - ${APP_PATH_HOST}/public:/usr/share/nginx/html
          - ./nginx/conf.d/app.conf:/etc/nginx/nginx.conf
        command: [nginx-debug, '-g', 'daemon off;']
    
      db:
        image: mysql
        restart: always
        environment:
          MYSQL_ROOT_PASSWORD: 123456
        volumes:
          - ${DB_PATH_HOST}:/var/lib/mysql
        command: --default-authentication-plugin=mysql_native_password
        ports:
          - "3306:3306"
        networks:
          - app-network
    
      adminer:
        image: adminer
        restart: always
        ports:
          - "6080:8080"
        networks:
          - app-network
    

    My nginx app.conf

     user              www-data  www-data;
     worker_processes  5;
     
     pid        /var/run/nginx.pid;
     
     worker_rlimit_nofile 1024;
     
     # include /etc/nginx/modules-enabled/*.conf;
     
     events {
             worker_connections 512;
     }
     
     http {
     
             include /etc/nginx/mime.types;
             default_type application/octet-stream;
             sendfile off;
             tcp_nopush on;
             access_log /var/log/nginx/access.log;
            error_log /var/log/nginx/error.log warn;
     
     
     
     
             upstream default {
                 server app:9501  weight=1 max_fails=1 fail_timeout=10 ;
                 server app:81  backup;
     
                 # The connections parameter sets the maximum number of idle keepalive connections to upstream servers that are preserved in the cache of each worker process. When this number is exceeded, the least recently used connections are closed.
                 # It does not limit the total number of connections to upstream servers that an nginx worker process can open. The connections parameter should be set to a number small enough to let upstream servers process new incoming connections as well.
                 # https://gist.github.com/magnetikonline/4a2e68b2ce94bd0c945e
                 # https://ma.ttias.be/enable-keepalive-connections-in-nginx-upstream-proxy-configurations/
                 keepalive 8;
             }
             upstream swoole {
                 server app:9501;
             }
             upstream fpm {
                 server app:81;
             }
     
             # map to different upstream backends based on query parameter 'useserver'
             # visit http://fly.test/?useserver=swoole to use server swoole
             # visit http://fly.test to use upstream default
             map $arg_useserver $pool {
                  default "default";
                  swoole "swoole";
                  fpm "fpm";
             }
     
             log_format my_upstream '$remote_addr|$time_local|$request_time|$upstream_response_time|$status '
                                      '$upstream_addr|$request';
     
             server {
               server_name fly.test;
                listen 80;
                root /usr/share/nginx/html;
                index index.html;
               charset utf-8;
     
                 location = / {
                     # if you have a static home page , try this one:
                     # try_files index.html @other;
                     try_files '' @php;
                 }
     
                 location / {
                     try_files $uri $uri/ @php;
                 }
     
                location @php {
                     proxy_pass http://$pool;
     
                     # Default is HTTP/1, keepalive is only enabled in HTTP/1.1
                     proxy_http_version 1.1;
                     # Remove the Connection header if the client sends it,
                     # it could be "close" to close a keepalive connection
                     proxy_set_header Connection "";
     
                     # proxy_connect_timeout 60s;
                     # proxy_send_timeout 60s;
                     # proxy_read_timeout 120s;
     
                     proxy_set_header    X-Real-IP        $remote_addr;
                     proxy_set_header    X-Forwarded-For  $proxy_add_x_forwarded_for;
                     proxy_set_header    Host             $http_host;
     
                     # proxy_set_header X-Real-PORT $remote_port;
                     # proxy_set_header Scheme $scheme;
                     # proxy_set_header Server-Protocol $server_protocol;
                     # proxy_set_header Server-Name $server_name;
                     # proxy_set_header Server-Addr $server_addr;
                     # proxy_set_header Server-Port $server_port;
     
                     # just a mark for different upstream server, you can disable it
                     add_header X-Upstream $upstream_addr;
                     # log
                     access_log /var/log/nginx/upstream.log my_upstream;
     
                }
     
             #    # only for Let's Encrypt
             #    location ~ /.well-known {
             #        allow all;
             #        # set root is necessage, otherwise "Invalid response from domain..."
             #        # https://www.digitalocean.com/community/questions/letsencrypt-problem-renewing-certs-invalid-response-from-domain
             #        root  {{ doc_root }};
             #    }
     
             }
     
     
             server {
                server_name fly.test;
                listen 81;
                root /usr/share/nginx/html;
                index index.html index.php;
                charset utf-8;
     
                location / {
                     try_files '' /index.php?$query_string;
                 }
     
                 location /index.php {
                    fastcgi_pass app:9000;
                    fastcgi_index index.php;
                    include fastcgi.conf;
                }
     
           }
         }
    

    Swoole works well, but php-fpm always get 502 bad gateway

    opened by fannyfan414 1
Owner
null
Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups, previously github.com/hyn/multi-tenant

The unobtrusive Laravel package that makes your app multi tenant. Serving multiple websites, each with one or more hostnames from the same codebase. B

Tenancy 2.4k Jan 3, 2023
Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups.

Tenancy for Laravel Enabling awesome Software as a Service with the Laravel framework. This is the successor of hyn/multi-tenant. Feel free to show su

Tenancy 1.1k Dec 30, 2022
Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups, previously

Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups, previously

Tenancy 2.4k Jan 3, 2023
Chrome extension to generate Laravel integration tests while using your app.

Laravel TestTools Check out the introduction post about the chrome extension. Installation git clone [email protected]:mpociot/laravel-testtools.git # i

Marcel Pociot 473 Nov 1, 2022
Smeify is a Stable Automated Solution for Airtime and Data businesses in Nigeria, this package helps you integrate smeify easily into your laravel application.

Smeify is a Stable Automated Solution for Airtime and Data businesses in Nigeria, this package helps you integrate smeify easily into your laravel application.

Ogundiran Adewale Charles 2 Jul 27, 2022
Livewire component that provides you with a modal that supports multiple child modals while maintaining state.

About LivewireUI Modal LivewireUI Modal is a Livewire component that provides you with a modal that supports multiple child modals while maintaining s

Livewire UI 806 Jan 6, 2023
Livewire component that provides you with a modal that supports multiple child modals while maintaining state.

About Wire Elements Modal Wire Elements Modal is a Livewire component that provides you with a modal that supports multiple child modals while maintai

Wire Elements 806 Jan 6, 2023
Html-sanitizer - The HtmlSanitizer component provides an object-oriented API to sanitize untrusted HTML input for safe insertion into a document's DOM.

HtmlSanitizer Component The HtmlSanitizer component provides an object-oriented API to sanitize untrusted HTML input for safe insertion into a documen

Symfony 201 Dec 23, 2022
Save Model is a Laravel package that allows you to save data in the database in a new way.

Save Model is a Laravel package that allows you to save data in the database in a new way. No need to worry about $guarded and $fillable properties in the model anymore. Just relax an use Save Model package.

Laratips 27 Mar 2, 2022
A flexible, seamless and easy to use multitenancy solution for Laravel

Main: Develop: Tenanted Laravel A flexible, seamless and easy to use multitenancy solution for Laravel This package is currently under development. Ch

Tenanted Laravel 12 May 29, 2023
Jumpstart your web development journey with the HALT Stack Starter Kit, a one-command solution for creating dynamic, scalable, and clean web applications.

Welcome to the HALT Stack Starter Kit! This kit is designed to help you kickstart your web development projects using the HALT Stack, a powerful combi

HALT Stack 6 Jun 7, 2023
A modern solution for running Laravel Horizon with a CRON-based supervisor.

A modern solution for running Laravel Horizon with a cron-based supervisor This Laravel package automatically checks every three minutes if your Larav

Ralph J. Smit 31 Dec 9, 2022
Hcaptcha & Google ReCaptcha Solution for Laravel Framework

Laravel Captcha is a wrapper around HCaptcha & Google Recaptcha. It provides very easy-to-use Facade, Validation Rule, and blade directives.

Rahul Dey 47 Oct 27, 2022
Laravel blade directives and php helpers for serverside rendered content, based on browser window size WITHOUT css. Requires Livewire and AlpineJS.

Laravel Livewire Window Size and Breakpoints Laravel blade directives and php helpers for server side rendered content, based on browser window size W

Tina Hammar 15 Oct 6, 2022
A Laravel Wrapper for the CoinDCX API. Now easily connect and consume the CoinDCX Public API in your Laravel apps without any hassle.

This package provides a Laravel Wrapper for the CoinDCX API and allows you to easily communicate with it. Important Note This package is in early deve

Moinuddin S. Khaja 2 Feb 16, 2022
A simple drop-in solution for providing UUID support for the IDs of your Eloquent models.

Introduction A simple drop-in solution for providing UUID support for the IDs of your Eloquent models. Both v1 and v4 IDs are supported out of the box

GoldSpec Digital 501 Jan 4, 2023
This is a solution implementation for the coderbyte question, CLEAN GET REQUEST RESULT.

This is a solution implementation for the coderbyte question, CLEAN GET REQUEST RESULT. Two solutions are proposed, the first is a brute force approach while the other is an improved time complexity solution.

null 3 May 23, 2022
Open Source Invoicing Solution for Individuals & Businesses

Introduction Crater is an open-source web & mobile app that helps you track expenses, payments & create professional invoices & estimates. Web Applica

Crater Invoice 6.7k Jan 4, 2023
Simple solution for form request validation on lumen.

Form Request Validation for Lumen This small package contains a laravel-like solution for request form validation. Contents Form Request Validation fo

Samuel Nunes de Souza 5 Nov 4, 2022