简体   繁体   English

无法在Laravel Homestead中运行工匠命令

[英]Cannot run artisan command in Laravel Homestead

After setting up Homestead for 1 specific project only , I want to run the Artisan CLI for database migrations. 仅为1个特定项目设置Homestead之后,我想运行Artisan CLI进行数据库迁移。 I tried to follow this tutorial and I keep getting this error: 我尝试按照本教程进行操作 ,但不断出现此错误:

Could not open input file: artisan

I set up the project by running these commands (Windows): 我通过运行以下命令来设置项目(Windows):

composer require laravel/homestead --dev
vendor\\bin\\homestead make
vagrant up

And then I made sure to be in the root project directory and then run php artisan list , which gives the error above. 然后,我确保将其放在根项目目录中,然后运行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. 我还尝试通过ssh进入Homestead VM,并导航到code文件夹(我的项目所在的位置)并运行php artisan list ,该脚本给出了相同的错误。

Attached is my working directory where I run the artisan command, as requested: 附件是我按照要求运行artisan命令的工作目录:

工作目录

I have tried running it in root dir and in vendor\\\\laravel to no avail. 我试过在根目录和vendor\\\\laravel运行它无济于事。

So how would one run the artisan CLI in a Laravel Homestead project? 那么,如何在Laravel Homestead项目中运行手工艺CLI?

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. 问题是我还没有使用composer设置Laravel项目,而是跳过了为该项目安装Laravel Homestead的工作。

So to make a Laravel project named eg quickstart , one should first create the project by running 因此,要制作一个名为例如quickstart的Laravel项目,首先应通过运行来创建项目

composer create-project laravel/laravel quickstart --prefer-dist

(see https://laravel.com/docs/5.1/quickstart#installation for more details) (有关更多详细信息,请参见https://laravel.com/docs/5.1/quickstart#installation

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. 现在,该项目应完全初始化。

Refs: https://laravel.com/docs/5.7/homestead#per-project-installation 参考: https : //laravel.com/docs/5.7/homestead#per-project-installation

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM