无法执行Laravel工匠命令 [英] Unable to execute Laravel artisan commands

查看:92
本文介绍了无法执行Laravel工匠命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了最新版本的Laravel,并尝试从我的Git Bash中运行以下命令:

I just installed the latest version of Laravel and tried to run the following command from my Git Bash:

php artisan migrate:make create_users_table --table=users --create

这会触发以下错误:

Could not open input file: artisan

我已经尝试了一些在此站点上找到的方法,但是似乎没有任何效果.关于如何使其工作有任何建议吗?

I have tried a number of things I found here on this site, but nothing seems to work. Any suggestions on how to make it work?

推荐答案

tl; dr

在项目的根文件夹中运行composer install.

当您通过从GitHub下载而不是从 laravel/laravel 存储库中提取并提取文件来创建项目时,会发生这种情况通过使用Composer命令:

This happens when you create a project by downloading and extracting the laravel/laravel repo from GitHub, not by using the Composer command:

composer create-project laravel/laravel your-project-name

在这种情况下,没有安装依赖项,因此包含Artisan的vendor文件夹不存在.在项目的根文件夹中运行composer install将安装依赖项vendor文件夹.

In this case the dependencies are not installed, so the vendor folder that contains Artisan doesn't exist. Running composer install in your project's root folder will install the dependencies vendor folder.

有关更多信息,请参阅我的其他有关如何安装Artisan的答案.

For more, see my other answer on how to install Artisan.

这与您的问题无关,但是您的Artisan命令有点不足.您从末尾忘记了=users(表名).另外,如果您创建表,则不必使用--table选项再次指定表名,因此此命令就足够了:

This is independent from your problem but your Artisan command is a bit deficient. You forgot =users (the table name) from the end. Also if you create a table you dont have to specify the table name again with the --table option so this command would be enough:

php artisan migrate:make create_users_table --create=users

这篇关于无法执行Laravel工匠命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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