Laravel php artisan produces error

Viewed 18718

I have integrated and working in a Laravel 5.4 project. I was actually configure this correctly and php artisan command was working perfectly before.But in between the development time(I have implemented the schedule task using laravel and not sure after that issue appear) it produces m error on php artisan commands. Can anybody help me on this.

The following is the error log for the command for any artisan command

PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Type error: Argument 2 passed to Illuminate\Routing\UrlGenerator::__construct() must be an instance of Illuminate\Http\Request, null given, called in /var/www/html/project/vendor/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php on line 60 in /var/www/html/project/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:103

Stack trace:
#0 /var/www/html/projrct/vendor/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php(60):

Illuminate\Routing\UrlGenerator->__construct(Object(Illuminate\Routing\RouteCollection), NULL) #1 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(290): Illuminate\Routing\RoutingServiceProvider->Illuminate\Routing{closure}(Object(Illuminate\Foundation\Application)) #2 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(746): Illuminate\Container\Container->Illuminate\Container{closur in /var/www/html/project/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php on line 103

6 Answers

Another alternative solution to commenting out the url() and asset() calls could be to check the environment at run time:

return [
    'URL' => app()->runningInConsole() ? '' : url(''),
    ...
];

If Really Need The Function To Be Inside Your Config, You Could use PHP_SAPI To Check Weather The App Is Running HTTP or CLI,

'redirect'  =>  PHP_SAPI === 'cli' ? false : url('synchronise')

I figured out the problem, when you are running any artisan command you should avoid using helper functions in any of your config files. Just comment those and try to run artisan command after running that uncomment your config files.

//in config/'any_file.php'
return [
   'name'   => 'Larvel',
   'url'    => url('/')
];

//just change and uncomment url() helper
return [
   'name'   => 'Larvel',
    //'url' => url('/')
];

Well I got stuck at same issue while I was using asset in config file (adminlte.php) of Admin LTE.

Please comment your asset, url while using artisan command in config files like this

[
    'type' => 'js',
    'asset' => false,
     // 'location' => asset('js/waitme/waitMe.min.js'),
],
Related