Search code examples
phplaravelfortrabbit

fortrabbit new apps and laravel artisan


I just started a new L5.1 app wit fortrabbit new app features,but I couldn't find the way how can use artisan commands, in old apps I used ssh,but now it is not accesible. I need "php artisan migrate" and "php artisan db:seed " commands,how can I do without ssh access?


Solution

  • Add a new database configuration to config/database.php:

    // ..
    'connections' => [
        // ..
        'mysql-tunnel' => [
            'driver'    => 'mysql',
            'host'      => '127.0.0.1',
            'port'      => '13306',
            'database'  => 'my-app',
            'username'  => 'my-app',
            // don't save the password with your code
            'password'  => env('DB_PASSWORD', ''),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],
    ],
    

    Then setup a tunnel:

    $ ssh -N -L 13306:my-app.mysql.eu2.frbit.com:3306 tunnel@tunnel.eu2.frbit.com
    

    Now you can run locally (in another terminal window):

    $ DB_PASSWORD="your-password" php artisan migrate --database=mysql-tunnel
    $ DB_PASSWORD="your-password" php artisan db:seed --database=mysql-tunnel