Reputation: 4735
When trying to create a new laravel project, The following error appears on the CLI:
Could not open input file: artisan
Script php artisan clear-compiled handling the post-install-cmd event returned with an error
I am using the latest version of XAMPP v3.2.1 with PHP 5.5.15 and with mcrypt enabled (made sure of that by issuing the command php -m). And I am running windows 8.1
Upvotes: 400
Views: 935247
Reputation: 597
In my case, I was trying to run artisan with wrong user.
ex: the project was belonging to fooo
user but I was baaar
user when I run the command.
Simply changing the user or run with other user fix the problem.
sudo su - fooo
# then run the command
php artisan ...
sudo su - fooo php artisan ...
Upvotes: 1
Reputation: 391
I had the same issue. I have fixed it by doing the following steps:
rm -Rf vendor
composer install --no-dev
Worked!
Upvotes: 1
Reputation: 4445
None of the solution worked for me. You can use these commands for solving the issue:
Remove bootstrap/cache/config.php file then:
composer dumpautoload
composer update
Remove vendor folder then:
composer install
If still not solved, your last option maybe to create new Laravel project: With new folder:
composer create-project --force laravel/laravel my-joyful-project
Without new folder:
composer create-project --force laravel/laravel .
It should solve the issue. If still no, make sure you do not have older laravel version. And lastly, make sure that it is Laravel project you are working on, not Silverstripe. They are both using composer and have similar configuration files. Easy to mess up or maybe not :)
Upvotes: 1
Reputation: 93
Based on my experience, you must check if the artisan file is in your project folder. I had the same error, and when I check the artisan, it was not present. You can easily copy any artisan file from any existing or already working project and paste it into your new project.
Or you may download it here: artisan file
Upvotes: 1
Reputation: 125
Mainly this may happen because your Laravel project opens on the wrong path. Just open the folder again in your code editor. That's what happened to me when I got the same error.
Upvotes: 1
Reputation: 535
For those people that are having the same error on cPanel terminal specifically.
Now you need to enter into your project root or public_html folder in the terminal using the following command:
cd public_html
Now you will be able to run any artisan commands.
php artisan config:clear
Upvotes: 0
Reputation: 1688
f:demo> php artisan serve
Upvotes: 14
Reputation: 2197
I have the same issue. I am also in the laravel project directory. what works for me is just change the permission of the artisan file.
For linux
chmod 777 artisan
For windows
Upvotes: -1
Reputation: 884
Another thing to note that if you have a symbolic link from a non public location which hosts your project code to say public_html - running php artisan
in the symbolic link location (public_html) will result in this error.
You seem to need to be in the actual project directory for php artisan
to work.
Upvotes: 0
Reputation: 378
You need to first create Laravel project and if you already have one you need to go to this project dir using cd command in terminal for example cd myproject.
Example : C:\xampp new\htdocs\project laravel\LaravelProject>php artisan serve
Now you will be able to run any artisan commands, for example running php artisan will display you list of available commands.
Upvotes: 1
Reputation: 4171
if you re in say my-project/app/somefolder
run in terminal cd ..
two times to get in my-project/
folder
Upvotes: 0
Reputation: 1471
First create the project from the following link to create larave 7 project: Create Project
Now you need to enter your project folder using the following command:
cd myproject
Now try to run artisan
command, such as, php artisan
.
Or it may happen if you didn't install compose. So if you didn't install composer then run composer install
and try again artisan
command.
Upvotes: 6
Reputation: 429
This error happens because you didn't install composer on your project.
run composer install
command in your project path.
Upvotes: 1
Reputation: 41410
You cannot use php artisan
if you are not inside a laravel
project folder.
That is why it says 'Could not open input file - artisan'
.
Upvotes: 193
Reputation: 4154
What did the trick for me was to do cd src
from my project directoy, and then use the php artisan
command, since my artisan
file was in the src
folder. Here is my project structure:
project
|__ config
|__ src
|__ app
|__ ..
|__ artisan // hello there!
|__ ...
|__ ...
Upvotes: 0
Reputation: 81
After installing composer, you need to create the project:
composer create-project laravel/laravel /path/to/tour/project
You can see the documentation, for your php version the lastest Laravel you can install is 5.0.
Now days here is the lastest version and require > php7.0. Here is the documentation.
Upvotes: 0
Reputation: 502
First, be sure to be in the laravel project folder or else the terminal won't be able to locate the artisan
file in the project directory and any subsequent request you pulled to start a server would be rejected.
Let's say our laravel project name is blog
and located in C:\laravel
We then have: C:\laravel\blog
Navigate to the C:\laravel\blog
directory and open the command window (terminal). Input the code below:
php artisan serve --host 127.0.0.1
Upvotes: 11
Reputation: 305
After struggling with this issue, I found out that you need to find where artisan resides by running sudo find / -name artisan
,
and from there run the command php artisan ....
Upvotes: 2
Reputation: 1974
If it is your first install of laravel then create another directory/folder inside the laravel directory and then move to that empty folder and create another project using the command below:
composer create-project --prefer-dist laravel/laravel blog
This will create a new project named "blog", then go back to parent laravel directory and now you can run this command:
php artisan serve
You will receive the return such as:
laravel deployment server started: http://localhost:8000
Upvotes: 5
Reputation: 1613
If you're running your Laravel project in Vagrant and have just SSH-ed into the virtual machine, don't forget to cd /vagrant
before you try running artisan commands!
Upvotes: 3
Reputation: 58760
If you project is at /home/forge/laravel-project/
You can properly execute your artisan like this
php /home/forge/laravel-project/artisan ...
Upvotes: 33
Reputation: 1437
I checked out an existing Laravel project, which did not have this script. Even a find / -name 'artisan'
produced no results. The solution turned out to be simple, if a bit weird:
curl -L 'https://raw.githubusercontent.com/laravel/laravel/v4.2.11/artisan' > artisan
You probably want to choose a tagged version that matches your installed version of Laravel.
Upvotes: 4
Reputation: 2319
I just needed to make artisan
executable.
chmod +x artisan
...and it works without the php prefix then.
Upvotes: 16
Reputation: 111889
You need to first create Laravel project and if you already have one you need to go to this project dir using cd
command in terminal for example cd myproject
.
Now you will be able to run any artisan commands, for example running php artisan
will display you list of available commands.
Upvotes: 523