Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

php artisan says it could not open the input file

ErrorCould not open input file: artisan

Short answer

PHP was asked to run a file called artisan and found nothing at that path. Artisan is a script at the root of every Laravel project, so either the shell is in the wrong folder or the file is missing from the copy you have. Change into the project root, or restore the file.

  • Applies to Laravel 12, PHP 8.4, Sail 1.x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print the folder you are in and look for the artisan file there.

    pwd
    ls -l artisan
  2. 2Match what you see, then jump to its fix

    1. 1ls: artisan: No such file or directory, while the project exists in a parent or sibling folderThe shell is in a folder that is not the project rootFix
    2. 2ls shows composer.json and app/ but no artisan fileThe artisan file is missing from this copy of the projectFix

What does the error look like?

  • Could not open input file: artisan

Cause 1 of 2

The shell is in a folder that is not the project root

1Check

PHP opens the script name you give it. The command php artisan means a file called artisan in the current folder, and Laravel keeps it at the application root, not inside app/ or public/.

pwd
ls ..

2Fix

Go to the folder that holds artisan, composer.json and the app directory, then run the command.

cd /path/to/my-app
php artisan list

3Verify

The command list prints.

php artisan --version

Confirmed by laravel.com

Did this fix it?

Cause 2 of 2

The artisan file is missing from this copy of the project

1Check

Every Laravel application has an artisan script at its root. If it is absent, the copy is incomplete, for example after a partial upload or a download that lost the file.

ls composer.json app
git status --short artisan 2>/dev/null

2Fix

Restore the file from version control. If the project is not under Git, copy artisan from a fresh Laravel project of the same major version.

git checkout -- artisan

3Verify

The file exists and runs.

ls -l artisan
php artisan list

Confirmed by laravel.com

Did this fix it?

How do I stop it coming back?

  • Open new terminals in the project folder, or use your editor's integrated terminal.
  • Keep the artisan file committed and do not exclude it in deployment scripts.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

composer require maatwebsite/excel fails to install

Composer says the package needs an older PHP than the one installed

Composer refuses maatwebsite/excel when the PHP version or a PHP extension does not match what the package and PhpSpreadsheet need.

3 causes, each with a fix

Back end

composer require laravel/horizon fails: ext-pcntl is missing

laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system

Horizon needs the pcntl extension, and Composer refuses to install it where PHP lacks that extension.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.