laravel调用未定义的函数get()

时间:2016-06-03 06:37:23

标签: laravel composer-php

当我在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:       

php artisan clear-compiled


[Symfony\Component\Debug\Exception\FatalErrorException]  
Call to undefined function get()            

php artisan optimize --force


[Symfony\Component\Debug\Exception\FatalErrorException]  
Call to undefined function get()  

{     作曲家更新      使用包信息加载composer存储库     更新依赖项(包括require-dev)       - 删除barryvdh / laravel-ide-helper(v2.1.4)       - 删除symfony / class-loader(v3.1.0)      写锁文件      生成自动加载文件

  

照亮\基金会\ ComposerScripts :: postUpdate   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:                   

}

我的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"
}

}

所以,它有什么不对,我该如何解决?感谢?

2 个答案:

答案 0 :(得分:4)

创建路径时出错时也会出现此错误。 您可以放置​​Route::get(...),而不是Route:get(...),所以只需检查您的路线或控制器文件

答案 1 :(得分:1)

你在app(模型或控制器)的某个地方以错误的方式使用get()方法。修复它,所有命令都会再次运行。

如果您需要更多帮助,请发布最近添加的使用get()方法的代码。