Severin
Severin

Reputation: 8588

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?

Upvotes: 32

Views: 107279

Answers (7)

Muhammad Sajidul Islam
Muhammad Sajidul Islam

Reputation: 280

Run following composer command in your root folder

composer require "ext-gd:*" --ignore-platform-reqs

It will install gd extension and update the dependencies

Upvotes: 2

Happy Patel
Happy Patel

Reputation: 1688

i have same problem. you need to run composer update and then run composer install

Upvotes: 0

Zafar Ahmed
Zafar Ahmed

Reputation: 369

Run following composer command in your root folder

composer dump-autoload

Upvotes: 3

totymedli
totymedli

Reputation: 31162

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

Upvotes: 57

You don't have artisan. There are two reasons:

  1. 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.

  2. You haven't created a Laravel project in that folder. You must create one with Composer.

Upvotes: 12

Stranger
Stranger

Reputation: 10621

Laravel needs the PHP version 5.5.9. If you have some lower version, you may not get anything executed and it may not throw any error based on you settings.

Upvotes: 0

Miroslav Trninic
Miroslav Trninic

Reputation: 3451

In your root directory you have artisan.php file which is internally triggering Illuminate\Console\Application::start($app);

So follow that path and see what is happening. Do you have any output when you run php artisan ? That error is usually shown when artisan is not in your path (current directory).

Upvotes: 0

Related Questions