Laravel locally run artisan commands effect VM environment

点点圈 提交于 2019-12-12 01:56:16

问题


I am looking for a solution that will allow me to run artisan commands from my local machine and for them to take effect on my homestead VM.

For example, when running php artisan migrate the command is run using the information stored in the .env file points to the VM, but my terminal is trying to run them locally.

The majority of the commands run successfully because they do not need drivers from the remote machine. Running php artisan route:list works fine.

How can I run artisan commands using a local terminal?


回答1:


You need to change the following files:

.env

DB_HOST=127.0.0.1
DB_HOST_PORT=:33060

homestead.yaml

variables:
    - key: APP_ENV
      value: local
    - key: DB_HOST_PORT
      value: ":3306"

config/database.php

'mysql' => [
    // ...
    'driver' => 'mysql',
    'host'   => env('DB_HOST') . env('DB_HOST_PORT'),
    // ...
]


来源:https://stackoverflow.com/questions/36594474/laravel-locally-run-artisan-commands-effect-vm-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!