问题描述
设置Homestead 仅针对1个特定项目后,我想要运行Artisan CLI进行数据库迁移.我试图遵循本教程,但我不断遇到此错误:
After setting up Homestead for 1 specific project only, I want to run the Artisan CLI for database migrations. I tried to follow this tutorial and I keep getting this error:
Could not open input file: artisan
我通过运行以下命令来设置项目(Windows):
I set up the project by running these commands (Windows):
composer require laravel/homestead --dev
vendor\\bin\\homestead make
vagrant up
然后我确定要放在根项目目录中,然后运行php artisan list
,它给出上面的错误.
And then I made sure to be in the root project directory and then run php artisan list
, which gives the error above.
我还尝试通过ssh进入Homestead VM,并导航到code
文件夹(我的项目所在的文件夹)并运行php artisan list
,它会给出相同的错误.
I also tried to ssh into the Homestead VM and navigated to the code
folder (where my project resides) and run php artisan list
, to which it gives the same error.
已附上我的工作目录,可根据要求在其中运行artisan命令:
Attached is my working directory where I run the artisan command, as requested:
我尝试在根目录和vendor\\laravel
中运行它,但无济于事.
I have tried running it in root dir and in vendor\\laravel
to no avail.
那么如何在Laravel Homestead项目中运行artisan CLI?
So how would one run the artisan CLI in a Laravel Homestead project?
推荐答案
我想我已经解决了.问题是我还没有使用composer
设置Laravel项目,而是跳过了为该项目安装Laravel Homestead的工作.
I think I've figured it out. The problem was that I haven't set up a Laravel project using composer
yet, and skipped to install Laravel Homestead for this project.
因此要创建一个名为例如的Laravel项目quickstart
,应该首先通过运行
创建项目
So to make a Laravel project named e.g. quickstart
, one should first create the project by running
composer create-project laravel/laravel quickstart --prefer-dist
(请参见 https://laravel.com/docs/5.1/quickstart#installation有关更多详细信息)
(see https://laravel.com/docs/5.1/quickstart#installation for more details)
只有在那之后,通过运行为项目设置宅基
Only after that, set up homestead for the project by running
composer require laravel/homestead --dev
vendor\bin\homestead make
现在应该完全初始化项目.
And now the project should be fully initialized.
引用: https://laravel.com/docs/5.7/homestead #per-project-installation
这篇关于无法在Laravel Homestead中运行工匠命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!