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-c
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
You must must be in your Laravel Project Folder
When creating a new project with laravel new project-name
, a folder will be created with your project name as name. You must get in that folder before using any php artisan
command like php artisan serve
because the artisan file is in that folder
The very first thing you have to check in this error is whether you are in the right folder. Direct the command prompt inside the project folder where all the Laravel package is existing.
I think you are not into laravel project directory please simply go to laravel project directory by using following command
cd projectName
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.
Most probably you are not in the right directory!