Skip to main content

If like me you tried the command

php artisan

However, you had the following “Could not open input file: artisan” error when starting the Laravel service using the above command.

 

How come “Could not open input file: artisan” error is showing up in Laravel

There are a few causes behind this error.

  1. File doesn't exist
  2. Incorrect console location
  3. Missing correct permission for artisan
  4. Composer install

 

File doesn't exist

Yep - I know, I shouldn't have to reference this one, but it's amazing how common this is overlooked.  Check does artisan exist?  Doesn't exist, first step install.

 

Incorrect console location

There is a chance of getting this error when you are running the “php artisan” command outside the Laravel project folder.

To resolve this, you need to run the “php artisan” command inside the Laravel project location.

cd my_laravel_project/
php artisan

You can replace the “my_laravel_project/” with your Laravel project location.

 

Missing correct permission for artisan

Otherwise there is a possibility of the artisan not being executable.  In this situation the artisan command cannot able to access and it will throw this error.

So you need to confirm that artisan is executable.

chmod +x artisan

 

Composer install

OK, so you have reached here as the above two options didn't work.

Now you need to try and run

composer install

When I initially ran this command, I received an awesome list of errors

  Problem 1
    - astrotomic/laravel-translatable is locked to version v11.10.0 and an update of this package was not requested.
    - astrotomic/laravel-translatable v11.10.0 requires php ^8.0 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 2
    - cartalyst/tags is locked to version v12.0.0 and an update of this package was not requested.
    - cartalyst/tags v12.0.0 requires php ^8.0 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 3
    - fruitcake/php-cors is locked to version v1.2.0 and an update of this package was not requested.
    - fruitcake/php-cors v1.2.0 requires php ^7.4|^8.0 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 4
    - laravel/framework is locked to version v9.3.0 and an update of this package was not requested.
    - laravel/framework v9.3.0 requires php ^8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 5
    - league/commonmark is locked to version 2.2.3 and an update of this package was not requested.
    - league/commonmark 2.2.3 requires php ^7.4 || ^8.0 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 6
    - league/config is locked to version v1.1.1 and an update of this package was not requested.
    - league/config v1.1.1 requires php ^7.4 || ^8.0 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 7
    - league/flysystem is locked to version 3.0.10 and an update of this package was not requested.
    - league/flysystem 3.0.10 requires php ^8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 8
    - league/flysystem-aws-s3-v3 is locked to version 3.0.10 and an update of this package was not requested.
    - league/flysystem-aws-s3-v3 3.0.10 requires php ^8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 9
    - league/flysystem-azure-blob-storage is locked to version 3.0.9 and an update of this package was not requested.
    - league/flysystem-azure-blob-storage 3.0.9 requires php ^8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 10
    - psr/cache is locked to version 2.0.0 and an update of this package was not requested.
    - psr/cache 2.0.0 requires php >=8.0.0 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 11
    - psr/container is locked to version 2.0.2 and an update of this package was not requested.
    - psr/container 2.0.2 requires php >=7.4.0 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 12
    - psr/log is locked to version 3.0.0 and an update of this package was not requested.
    - psr/log 3.0.0 requires php >=8.0.0 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 13
    - psr/simple-cache is locked to version 3.0.0 and an update of this package was not requested.
    - psr/simple-cache 3.0.0 requires php >=8.0.0 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 14
    - spatie/laravel-activitylog is locked to version 4.4.0 and an update of this package was not requested.
    - spatie/laravel-activitylog 4.4.0 requires php ^8.0 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 15
    - spatie/laravel-analytics is locked to version 4.1.0 and an update of this package was not requested.
    - spatie/laravel-analytics 4.1.0 requires php ^8.0 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 16
    - spatie/laravel-package-tools is locked to version 1.11.2 and an update of this package was not requested.
    - spatie/laravel-package-tools 1.11.2 requires php ^7.4|^8.0 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 17
    - spatie/once is locked to version 3.0.2 and an update of this package was not requested.
    - spatie/once 3.0.2 requires php ^8.0 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 18
    - symfony/cache is locked to version v6.0.5 and an update of this package was not requested.
    - symfony/cache v6.0.5 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 19
    - symfony/console is locked to version v6.0.5 and an update of this package was not requested.
    - symfony/console v6.0.5 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 20
    - symfony/css-selector is locked to version v6.0.3 and an update of this package was not requested.
    - symfony/css-selector v6.0.3 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 21
    - symfony/deprecation-contracts is locked to version v3.0.0 and an update of this package was not requested.
    - symfony/deprecation-contracts v3.0.0 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 22
    - symfony/error-handler is locked to version v6.0.3 and an update of this package was not requested.
    - symfony/error-handler v6.0.3 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 23
    - symfony/event-dispatcher is locked to version v6.0.3 and an update of this package was not requested.
    - symfony/event-dispatcher v6.0.3 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 24
    - symfony/event-dispatcher-contracts is locked to version v3.0.0 and an update of this package was not requested.
    - symfony/event-dispatcher-contracts v3.0.0 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 25
    - symfony/finder is locked to version v6.0.3 and an update of this package was not requested.
    - symfony/finder v6.0.3 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 26
    - symfony/http-foundation is locked to version v6.0.5 and an update of this package was not requested.
    - symfony/http-foundation v6.0.5 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 27
    - symfony/http-kernel is locked to version v6.0.5 and an update of this package was not requested.
    - symfony/http-kernel v6.0.5 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 28
    - symfony/mailer is locked to version v6.0.5 and an update of this package was not requested.
    - symfony/mailer v6.0.5 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 29
    - symfony/mime is locked to version v6.0.3 and an update of this package was not requested.
    - symfony/mime v6.0.3 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 30
    - symfony/process is locked to version v6.0.5 and an update of this package was not requested.
    - symfony/process v6.0.5 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 31
    - symfony/routing is locked to version v6.0.5 and an update of this package was not requested.
    - symfony/routing v6.0.5 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 32
    - symfony/service-contracts is locked to version v3.0.0 and an update of this package was not requested.
    - symfony/service-contracts v3.0.0 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 33
    - symfony/string is locked to version v6.0.3 and an update of this package was not requested.
    - symfony/string v6.0.3 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 34
    - symfony/translation is locked to version v6.0.5 and an update of this package was not requested.
    - symfony/translation v6.0.5 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 35
    - symfony/translation-contracts is locked to version v3.0.0 and an update of this package was not requested.
    - symfony/translation-contracts v3.0.0 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 36
    - symfony/var-dumper is locked to version v6.0.5 and an update of this package was not requested.
    - symfony/var-dumper v6.0.5 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 37
    - symfony/var-exporter is locked to version v6.0.3 and an update of this package was not requested.
    - symfony/var-exporter v6.0.3 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 38
    - chillerlan/php-qrcode is locked to version 4.3.3 and an update of this package was not requested.
    - chillerlan/php-qrcode 4.3.3 requires php ^7.4 || ^8.0 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 39
    - chillerlan/php-settings-container is locked to version 2.1.2 and an update of this package was not requested.
    - chillerlan/php-settings-container 2.1.2 requires php ^7.4 || ^8.0 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 40
    - composer/pcre is locked to version 3.0.0 and an update of this package was not requested.
    - composer/pcre 3.0.0 requires php ^7.4 || ^8.0 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 41
    - friendsofphp/php-cs-fixer is locked to version v3.6.0 and an update of this package was not requested.
    - friendsofphp/php-cs-fixer v3.6.0 requires php ^7.4 || ^8.0 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 42
    - nunomaduro/collision is locked to version v6.1.0 and an update of this package was not requested.
    - nunomaduro/collision v6.1.0 requires php ^8.0.0 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 43
    - orchestra/testbench is locked to version v7.1.0 and an update of this package was not requested.
    - orchestra/testbench v7.1.0 requires php ^8.0 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 44
    - orchestra/testbench-core is locked to version v7.1.0 and an update of this package was not requested.
    - orchestra/testbench-core v7.1.0 requires php ^8.0 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 45
    - spatie/macroable is locked to version 2.0.0 and an update of this package was not requested.
    - spatie/macroable 2.0.0 requires php ^8.0 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 46
    - symfony/filesystem is locked to version v6.0.5 and an update of this package was not requested.
    - symfony/filesystem v6.0.5 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 47
    - symfony/options-resolver is locked to version v6.0.3 and an update of this package was not requested.
    - symfony/options-resolver v6.0.3 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 48
    - symfony/stopwatch is locked to version v6.0.5 and an update of this package was not requested.
    - symfony/stopwatch v6.0.5 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 49
    - symfony/yaml is locked to version v6.0.3 and an update of this package was not requested.
    - symfony/yaml v6.0.3 requires php >=8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
  Problem 50
    - laravel/framework v9.3.0 requires php ^8.0.2 -> your php version (7.3.33) does not satisfy that requirement.
    - spatie/laravel-ray 1.29.4 requires illuminate/contracts ^7.20|^8.19|^9.0 -> satisfiable by laravel/framework[v9.3.0].
    - spatie/laravel-ray is locked to version 1.29.4 and an update of this package was not requested.

Yeah, I know awesome right.  But they all point to the same issue.  PHP version conflict.

 

For me, the usual fix is to run

export PATH=/opt/plesk/php/8.0/bin:$PATH;

However, on running this command and then testing the PHP version I was going nowhere

php -v

PHP 7.4.28 (cli) (built: Feb 18 2022 15:48:26) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with the ionCube PHP Loader + ionCube24 v11.0.1, Copyright (c) 2002-2022, by ionCube Ltd.
    with Zend OPcache v7.4.28, Copyright (c), by Zend Technologies

The resolution was to run the command

alias php='/opt/plesk/php/8.0/bin/php'

 

How did I know that the solution above would work?  When I ran the command

which PHP

The response was

alias php='/opt/plesk/php/7.4/bin/php'
    /opt/plesk/php/7.4/bin/php

Whereas, I had been anticipating the following response

/usr/bin/php

 

Post running the command

alias php='/opt/plesk/php/8.0/bin/php'

A PHP version check

php -v

Produced the following response

PHP 8.0.16 (cli) (built: Feb 18 2022 15:47:57) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.16, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.16, Copyright (c), by Zend Technologies

 

Attempting to run composer install command again

composer install

Response

Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on the current platform.
Nothing to install, update or remove
Generating autoload files

 

Attempting PHP artisan command again

Now that composer is friendly, PHP is running off 8.x, will the command PHP artisan work or produce the same error?

PHP artisan

Response

Could not open input file: artisan

 

 

Installing laravel

When installing Laravel, take note of the path when using the following command

composer global require laravel/installer

The response I had was

/Users/{name}/.composer

 

Related articles

Andrew Fletcher12 Apr 2022
Mapping out your Laravel project
Every project has to kick off somewhere.  Yep well that's a no brainer.  However, the number of projects that I've seen where the planning step has been omitted is too high.  A throughly planned out project with as many features scoped before you start coding is critical in completing...
Andrew Fletcher17 Mar 2022
lando PHP version issue 7.4.x instead wanting >= 8.0.2
I installed Lando 3.6.2 and Laravel 9.  When I visit the web page, I getting Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.2". You are running 7.4.28. in /app/vendor/composer/platform_check.php on line...