简体   繁体   中英

Laravel artisan command not working

I've created my laravel project with create-project beacause composer install didn't work.

cd to my project and then, when I try to use php artisan list or any artisan command it just says:

Could not open input file: artisan

How do I fix this? the vendor file is in the project

My composer.json:

{
  "name": "vendor_name/package_name",
  "description": "description_text",
  "minimum-stability": "stable",
  "license": "proprietary",
  "authors": [
    {
      "name": "author's name",
      "email": "email@example.com"
    }
  ],
  "require": {
    "barryvdh/laravel-ide-helper": "^2.0"
  }
}

path to my project:

c:\wamp\www\project1

Inside vendor, no folder named artisan is showed

Use the project's root folder

Artisan comes with Laravel by default, if your php command works fine, then the only thing you need to do is to navigate to the project's root folder. The root folder is the parent folder of the app folder. For example:

cd c:\Program Files\xampp\htdocs\your-project-name

Now the php artisan list command should work fine, because PHP runs the file called artisan in the project's folder.

Now install the laravel framework

Keep in mind that Artisan runs scripts stored in the vendor folder, so if you installed Laravel without Composer, like downloading and extracting the Laravel GitHub repo for laravel , then you don't have the framework itself and you may get the following error when you try to use Artisan:

Could not open input file: artisan

To solve this you have to install the framework itself by running composer install in your project's root folder.

Have you tried to do a "ls" (linux) or a "dir" (win) to make sure you are in the correct folder?

Check if you have correctly installed php.

Run cmd or shell and try to run

php -v

I'm going to assume you have Windows as your OS.

Go to Control Panel -> System and Security -> System -> Advanced system settings.

Then go to Environment Variables, find "Path" and add

;your/path/to/php.exe

at the end.

Replace "your/path/to/" with your current php.exe directory (including C:\\ )

EDIT Try with this one:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "laravel/framework": "5.0.*",
        "barryvdh/laravel-ide-helper": "^2.0"           
    },
    "require-dev": {
        "phpunit/phpunit": "~4.0",
        "phpspec/phpspec": "~2.1"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-create-project-cmd": [
            "php -r \"copy('.env.example', '.env');\"",
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

I'm using windows 10, today is 31st dec, 2016.

I had the same issue, did a bit of a research and solved it.
First go to vendor directory from your laravel project directory and run this command:

composer install

if it further shows an error and asks for the composer.json file missing then:

cd ../ 
composer install

This fixed my issue!

I don't know if this has been solved, but I found this to be useful:

   composer require laravel/passport --ignore-platform-req=ext-fileinfo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM