Can't use shell_exec for laravel artisan command in live server

Viewed 5444

I am using shell_exec command to run my artisan commands in the background. But when I run shell_exec in production server.

The route code as follows

Route::get('/test/exec', function () {
    echo shell_exec('php ../artisan migrate:status 2>&1; echo $?');
});

it throws me error as follows.

PHP Fatal error: Cannot redeclare class Illuminate\Support\Traits\Macroable in /var/www/production/bootstrap/cache/compiled.php on line 6109 255

But when I run the same command in my local I got the output.

  • Laravel versin - 5.1.46
  • php version - PHP 5.5.9
  • os version - ubuntu 14.04

These are same on both servers. Where things went wrong. Please, some one helps me with this.

2 Answers

The error

% Cannot redeclare class %

also occurs when you inject a class that has the same name as the one you are actively editing/modifying.

In your case, please make sure that you have not injected a class with the name "Macroable" elsewhere. If you have, make sure that the namespace is unique.

Related