Skip to content
scil edited this page Sep 14, 2018 · 35 revisions

Config

  1. Publish server config file
    php artisan vendor:publish --tag=fly-server .

  2. Edit server config file
    <project_root_dir>/fly.conf.php.

  3. Publish app config file
    php artisan vendor:publish --tag=fly-app .

  4. Edit app config file <project_root_dir>/config/laravelfly.php.
    Note: items prefixed with "/** depends " deverve your consideration.

Two optional steps to allow you use same code for LaravelFly and PHP-FPM

  1. Edit <project_root_dir>/app/Http/Kernel.php, change class Kernel extends HttpKernel to
if (defined('LARAVELFLY_MODE')) {
    if (LARAVELFLY_MODE == 'Map') {
        class WhichKernel extends \LaravelFly\Map\Kernel { }
    }elseif (LARAVELFLY_MODE == 'Backup') {
        class WhichKernel extends \LaravelFly\Backup\Kernel { }
    } elseif (LARAVELFLY_MODE == 'FpmLike') {
        class WhichKernel extends HttpKernel{}
    } 
} else {
    class WhichKernel extends HttpKernel { }
}

class Kernel extends WhichKernel
  1. If you use tinker(), put this line at the top of public/index.php :
    function tinker(){ return '';}

This line avoids error Call to undefined function tinker() when you use php-fpm with tinker() left in your code.

Optional Config

  • composer require --dev "eaglewu/swoole-ide-helper:dev-master" , which is useful in IDE development.

  • Config and restart nginx: swoole http server lacks some http functions, so it's better to use swoole with other http servers like nginx. There is a nginx site conf example at vendor/scil/laravel-fly/config/nginx+swoole.conf.

  • if you want to use mysql persistent, add following to config/database.php

'options' => [
    PDO::ATTR_PERSISTENT => true,
],
  • In Mode Map, MySql coroutine can be used. Ensure const LARAVELFLY_COROUTINE = true; in fly.conf.php, then add 'coroutine' => true, to config/database. This feature is still under dev.
'mysql' => [
    'driver' => 'mysql',
    'coroutine' => true,
    ...
],

This feature depends on laravel-s and still under dev.

Config examples for Third Party Serivce