Could not open input file: artisan

595,620

Solution 1

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.

Solution 2

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

Solution 3

If you project is at /home/forge/laravel-project/

You can properly execute your artisan like this

php /home/forge/laravel-project/artisan ...

Solution 4

Most probably you are not in the right directory!

Solution 5

I just needed to make artisan executable.

chmod +x artisan

...and it works without the php prefix then.

Share:
595,620
wessodesigner
Author by

wessodesigner

Updated on February 18, 2022

Comments

  • wessodesigner
    wessodesigner about 2 years

    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

  • wessodesigner
    wessodesigner over 9 years
    This error appears when I am attempting to create a new laravel project: cd xampp/htdocs then composer create-project laravel/laravel newLaravelProject It starts to download all the required dependencies, and suddenly this error appears.
  • Eranda
    Eranda almost 9 years
    If you have moved your app folder with .env, vendor folder, config folder...etc to some where else, you may have to change directory root to this location.
  • Chad
    Chad over 5 years
    This should be the selected answer. Worked perfectly!
  • Admin
    Admin over 5 years
    of course you have to do a composer install almost one time
  • Dmitry
    Dmitry almost 4 years
    In Windows you can do php 'E:\path\to_your_domain\artisan' october:up
  • Yvon Huynh
    Yvon Huynh over 3 years
    I tried to make a migration from the migration folders, I hasd this message, you've got to be at the root of your application (where composer.json resides) to make it work
  • raw-bin hood
    raw-bin hood over 3 years
    Agreed. correct answer here. I didn't know that it only worked from the project root folder.
  • Monir alhussini
    Monir alhussini over 3 years
    I am facing an issue like this one if anyone ca help with it stackoverflow.com/questions/64983129/…