laravel 调用未定义的函数 get()
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37607508/
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 Call to undefined function get()
提问by edwin Yuan
when i run a command in laravel project :
当我在 laravel 项目中运行命令时:
php artisan optimize
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined function get()
Script php artisan optimize handling the post-update-cmd event returned with an error
[RuntimeException]
Error Output:
and
和
php artisan clear-compiled
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined function get()
and
和
php artisan optimize --force
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined function get()
and
和
{ composer update Loading composer repositories with package information Updating dependencies (including require-dev) - Removing barryvdh/laravel-ide-helper (v2.1.4) - Removing symfony/class-loader (v3.1.0) Writing lock file Generating autoload files
{ composer update 使用包信息加载 composer 存储库 更新依赖项(包括 require-dev) - 删除 barryvdh/laravel-ide-helper (v2.1.4) - 删除 symfony/class-loader (v3.1.0) 写入锁定文件 生成自动加载文件
Illuminate\Foundation\ComposerScripts::postUpdate php artisan optimize
Illuminate\Foundation\ComposerScripts::postUpdate php artisan 优化
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined function get()
Script php artisan optimize handling the post-update-cmd event returned with an error
[RuntimeException]
Error Output:
}
}
and my composer.json is
我的 composer.json 是
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"laravelcollective/html": "5.2.*"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"symfony/css-selector": "2.8.*|3.0.*",
"symfony/dom-crawler": "2.8.*|3.0.*"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\Foundation\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\Foundation\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
}
}
}
so, what's wrong is it,and how can i fix it? thanks?
那么,出了什么问题,我该如何解决?谢谢?
采纳答案by Alexey Mezenin
You're using get()
method in a wrong way somewhere in your app (model or controller). Fix it and all commands will work again.
您get()
在应用程序(模型或控制器)的某处以错误的方式使用方法。修复它,所有命令将再次起作用。
If you want more help, please post your recently added code which uses get()
method.
如果您需要更多帮助,请发布您最近添加的使用get()
方法的代码。
回答by Nathan Teyou
This error also comes when you did an error in creating a route.
Instead of Route::get(...)
you may have put Route:get(...)
, So just check in your route or Controllers files
当您在创建路由时出错时也会出现此错误。而不是Route::get(...)
你可能已经 put Route:get(...)
,所以只需检查你的路由或控制器文件