How to install Laravel's Artisan?
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:
Could not open input file: artisan
I wasn't able to find any guide in the documentation nor in Google. How can I install Artisan?
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
Now the php artisan list
command should work fine, because PHP runs the file called artisan
in the project's folder.
Install the framework
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:
Could not open input file: artisan
To solve this you have to install the framework itself by running composer install
in your project's root folder.
You just have to read the laravel installation page:
- Install Composer if not already installed
- Open a command line and do:
composer global require "laravel/installer"
Inside your htdocs or www directory, use either:
laravel new appName
(this can lead to an error on windows computers while using latest Laravel (1.3.2)) or:
composer create-project --prefer-dist laravel/laravel appName
(this works also on windows) to create a project called "appName".
To use "php artisan xyz" you have to be inside your project root! as artisan is a file php is going to use... Simple as that ;)
While you are working with Laravel you must be in root of laravel directory structure. There are App, route, public etc folders is root directory.
Just follow below step to fix issue.
check composer status using : composer -v
First, download the Laravel installer using Composer:
composer global require "laravel/installer"
Please check with below command:
php artisan serve
still not work then create new project with existing code. using LINK