18
votes

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

9
Please do not include screenshots of your error messages! Copy and paste them into your question with proper formatting.milo526
@milo526 thanks for quick reply and i have done the changes.anoop
i its not an artisan error, i think you have error syntax somewhere in you routes or controllers filesomadonex
Whether you created any CommandController(Used for schedule task) file for schedule task?Mohammad Alfaz
@Mohammad Alfaz Yes i am. I have created a scheduled task and created command class under app/Console/Commands/Sample.phpanoop

9 Answers

38
votes

I my case url() helper function in my filesystem.php is causing the issue. I removed it and every thing works fine.

59
votes

Please make sure that you are not using any url() or asset() or other helpers functions inside your configuration files

5
votes

Another alternative solution could be for example:

'URL' => app()->runningInConsole() ? '' : url('')
3
votes

Check your config file and remove/fix the url() or asset() helper function.

2
votes

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')
1
votes

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('/')
];
1
votes

On My custom config file I used url(). That was causing this issue. When I commented out the url() line, everything worked fine.

1
votes

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'),
],
0
votes

copy folder config of one project that work well and paste to your project