Laravel php artisan 产生错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45152585/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel php artisan produces error
提问by anoop
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.
我已经集成并在 Laravel 5.4 项目中工作。我实际上正确地配置了这个并且php artisan
命令之前运行良好。但是在开发时间之间(我已经使用laravel实现了计划任务并且不确定在出现该问题之后)它在php artisan命令上产生m错误。任何人都可以帮助我。
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
PHP 致命错误:未捕获的 Symfony\Component\Debug\Exception\FatalThrowableError:类型错误:传递给 Illuminate\Routing\UrlGenerator::__construct() 的参数 2 必须是 Illuminate\Http\Request 的实例,给定 null,在 /var 中调用/www/html/project/vendor/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php 在 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php 中的第 60 行: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 在线 103
回答by Ahmed Abu Eldahab
Please make sure that you are not using any url() or asset() or other helpers functions inside your configuration files
请确保您没有在配置文件中使用任何 url() 或 asset() 或其他帮助函数
回答by Awais Jameel
I my case url() helper function in my filesystem.php is causing the issue. I removed it and every thing works fine.
我的 filesystem.php 中的 url() 辅助函数导致了这个问题。我删除了它,一切正常。
回答by Hamza Zymawy
回答by Alberto Costa
Another alternative solution could be for example:
例如,另一种替代解决方案可能是:
'URL' => app()->runningInConsole() ? '' : url('')
回答by PHP Worm...
Check your config file and remove/fix the url()
or asset()
helper function.
检查您的配置文件并删除/修复url()
或asset()
帮助函数。
回答by Shahrukh Anwar
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.
我发现了这个问题,当你运行任何 artisan 命令时,你应该避免helper
在任何config
文件中使用函数。只需评论这些并在运行取消注释config
文件后尝试运行 artisan 命令。
//in config/'any_file.php'
return [
'name' => 'Larvel',
'url' => url('/')
];
//just change and uncomment url() helper
return [
'name' => 'Larvel',
//'url' => url('/')
];
回答by Ariful Haque
On My custom config
file I used url()
. That was causing this issue. When I commented out the url()
line, everything worked fine.
在我的自定义config
文件中,我使用了url()
. 这导致了这个问题。当我注释掉该url()
行时,一切正常。
回答by nayan verma
Well I got stuck at same issue while I was using asset in config file (adminlte.php) of Admin LTE.
好吧,当我在 Admin LTE 的配置文件 (adminlte.php) 中使用资产时,我遇到了同样的问题。
Please comment your asset, url while using artisan command in config files like this
请在这样的配置文件中使用 artisan 命令时评论您的资产、url
[
'type' => 'js',
'asset' => false,
// 'location' => asset('js/waitme/waitMe.min.js'),
],