Laravel - Artisan not working

2020-06-01 07:18发布

I'm aware of the other questions out there, but they are different to my situation.

I installed a fresh copy of my own laravel, and I tried running php artisan list, which works.

Now, I have a colleague who has installed a copy of laravel himself, and he pushes his entire directory onto a git repository. I pulled the entire branch off the repository, and tried running php artisan list, but nothing happens this time. I mean, literally, nothing happens.

Any ideas as to why this is happening?

6条回答
Animai°情兽
2楼-- · 2020-06-01 07:57

Just to point out some thing to anyone struggling with artisan, as this answer is 1st link in google to artisan CLI empty line:

It will print blank line whenever some error happens, even if you have all dependencies installed with composer install. And it won't tell you exactly what is wrong. I couldn't figure it out until I put into artisan file in the root directory this:

ini_set('display_errors',1);
error_reporting(-1);

That forced artisan CLI to show error message and therefore I was able to fix it (my .env file was broken).

Hope this helps someone.

查看更多
倾城 Initia
3楼-- · 2020-06-01 08:00

In my case problem was to connect artisan with database (migrates) i.e. the command

$php artisan migrate

was not working.

I was running laravel project on 8888 port. In this case I updated .env file as: DB_HOST=localhost to DB_HOST=localhost to DB_HOST=127.0.0.1 and DB_PORT=3306 to DB_PORT=8889

Cleared cache by running artisan command and run the migrates:

php artisan config:clear
php artisan migrate
查看更多
forever°为你锁心
4楼-- · 2020-06-01 08:10

Generally speaking, the vendor directory is not committed to VCS, as such, doing a clone on a standard Laravel app won't include all its dependencies.

Once you have cloned, doing composer install (or composer update if you want the latest packages as a developer) will fetch the dependencies and allow your app to work.

查看更多
甜甜的少女心
5楼-- · 2020-06-01 08:16

You need to run composer install, so the composer refresh all dependencies, artisan's begin on the middle. That should do the job!

查看更多
贼婆χ
6楼-- · 2020-06-01 08:19

delete the your php at your system , and install it again or if you run the app, move project folder at htdocs in xampp folder and type address in browser , localhost/your project name and your app is run on localhost

查看更多
祖国的老花朵
7楼-- · 2020-06-01 08:21

My artisan was not working because i had the following lines in my routes.php

if(!isset($_SESSION['c_id'])) {
    header("Location: /login_page.php");
    exit();
}

I simply commented the exit(). So my code becomes as follows

if(!isset($_SESSION['c_id'])) {
    header("Location: /login_page.php");
//    exit();
}
查看更多
登录 后发表回答