Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to execute Laravel artisan commands

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 

This triggers the following error:

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?

like image 710
Severin Avatar asked Feb 24 '14 17:02

Severin


People also ask

Why I cant run php artisan serve?

Reasons why php artisan serve not workingYou are running php artisan serve command in wrong directory. php artisan serve is laravel command only work with laravel project. Check project directory and run in root directory of your project. The requested host or port is not available.

How do I run an artisan command in Windows?

To be able to run php artisan <command> you must be in your project folder, so first move to that folder using the cd command, then you can execute the command. You haven't created a Laravel project in that folder. You must create one with Composer.


1 Answers

tl;dr

Run composer install in your project's root folder.

Explanation

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 

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.

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

Side note

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 
like image 192
totymedli Avatar answered Sep 23 '22 14:09

totymedli