Laravel在本地运行artisan命令会影响VM环境 [英] Laravel locally run artisan commands effect VM environment

查看:40
本文介绍了Laravel在本地运行artisan命令会影响VM环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种解决方案,该解决方案将允许我从本地计算机上运行artisan命令,并使它们在我的homestead VM上生效.

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.

例如,在运行php artisan migrate时,将使用存储在.env文件中的信息指向虚拟机来运行命令,但是我的终端正在尝试在本地运行它们.

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.

大多数命令成功运行,因为它们不需要远程计算机上的驱动程序.运行php artisan route:list可以正常工作.

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

如何使用本地终端运行artisan命令?

How can I run artisan commands using a local terminal?

推荐答案

您需要更改以下文件:

.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'),
    // ...
]

这篇关于Laravel在本地运行artisan命令会影响VM环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆