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
Check the directory in CMD console, it should be the same as the project .
C:\...project directory
or
D:\...project directory
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!
|__ ...
|__ ...
If you project is at /home/forge/laravel-project/
You can properly execute your artisan like this
php /home/forge/laravel-project/artisan ...
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.
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.
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'
.