本文介绍了如何安装Laravel的Artisan?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Laravel中创建迁移,但是根据教程,我需要Artisan CLI. php命令工作正常,我在Windows上.输入php artisanphp artisan list时,出现以下错误:

I want to create migrations in Laravel but according to the tutorials I need the Artisan CLI. The php command works fine and I'm on Windows. I type in php artisan or php artisan list and I get the following error:

文档和Google中都找不到任何指南.如何安装Artisan?

I wasn't able to find any guide in the documentation nor in Google. How can I install Artisan?

推荐答案

使用项目的根文件夹

Artisan默认带有Laravel,如果您的php命令可以正常工作,那么您唯一需要做的就是导航到项目的根文件夹.根文件夹是 app文件夹的父文件夹.例如:

Use the project's root folder

Artisan comes with Laravel by default, if your php command works fine, then the only thing you need to do is to navigate to the project's root folder. The root folder is the parent folder of the app folder. For example:

cd c:\Program Files\xampp\htdocs\your-project-name

现在php artisan list命令应该可以正常工作,因为PHP在项目文件夹中运行名为artisan的文件.

Now the php artisan list command should work fine, because PHP runs the file called artisan in the project's folder.

请记住,Artisan将运行存储在vendor文件夹中的脚本,因此,如果您在没有Composer的情况下安装了Laravel,例如下载和提取 Laravel GitHub repo ,那么您就没有框架本身,尝试使用Artisan时可能会遇到以下错误:

Keep in mind that Artisan runs scripts stored in the vendor folder, so if you installed Laravel without Composer, like downloading and extracting the Laravel GitHub repo, then you don't have the framework itself and you may get the following error when you try to use Artisan:

要解决此问题,您必须通过在项目的根文件夹中运行composer install来安装框架本身.

To solve this you have to install the framework itself by running composer install in your project's root folder.

这篇关于如何安装Laravel的Artisan?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 18:28