Build a CMS with Laravel and (Homestead/VM)

Assuming that you have a locally installed version of PHP, composer and node you should be able to run artisan commands straight from your cli(command prompt).

However, in order for your local environment to have access to your databases in the VM you will need to make a minor modification to you config/database.php file.

Simply add a “port” parameter to your database driver array like shown below.

For MYSQL and PGSQL:

'mysql' => [
        'driver'    => 'mysql',
        'host'      => env('DB_HOST', 'localhost'),
        'database'  => env('DB_DATABASE', 'forge'),
        'username'  => env('DB_USERNAME', 'forge'),
        'password'  => env('DB_PASSWORD', ''),
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
        'port'     => 'local' === env('APP_ENV') ? 33060 : 3306,
        'strict'    => false,
    ],

'pgsql' => [
        'driver'   => 'pgsql',
        'host'     => env('DB_HOST', 'localhost'),
        'database' => env('DB_DATABASE', 'forge'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'charset'  => 'utf8',
        'prefix'   => '',
        'port'     => 'local' === env('APP_ENV') ? 54320 : 5432,
        'schema'   => 'public',
    ],

With this setup, you will rarely if ever ssh into your development outside of creating a new host record.

Hope this helps some of you…

Vic