供应商更新通过“在非对象上调用成员函数has()"破坏了FOS用户捆绑包. [英] Vendor updates broke FOS User Bundle with "Call to a member function has() on a non-object"

查看:132
本文介绍了供应商更新通过“在非对象上调用成员函数has()"破坏了FOS用户捆绑包.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为Symfony 2.8项目更新了供应商,突然登录页面没有加载–相反,我得到了:

I updated my vendors for a Symfony 2.8 project and suddenly the login page isn't loading – instead I get this:

错误:在非对象中调用成员函数has() 供应商/symfony/symfony/src/Symfony/捆绑/FrameworkBundle/Controller/Controller.php 在第184行

Error: Call to a member function has() on a non-object in vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php at line 184

"name": "hazardlog",
"license": "proprietary",
"type": "project",
"autoload": {
    "psr-4": {
        "": "src/"
    },
    "classmap": [
        "app/AppKernel.php",
        "app/AppCache.php"
    ]
},
"repositories": [
    {
        "type": "package",
        "package": {
            "name": "jquery/jquery",
            "version": "1.11.1",
            "dist": {
                "url": "https://code.jquery.com/jquery-1.11.1.js",
                "type": "file"
            }
        }
    }
],
"require": {
    "php": ">=5.3.9",
    "symfony/symfony": "2.8.*",
    "doctrine/orm": "^2.4.8",
    "doctrine/doctrine-bundle": "~1.4",
    "symfony/swiftmailer-bundle": "~2.3",
    "symfony/monolog-bundle": "~2.4",
    "sensio/distribution-bundle": "~5.0",
    "sensio/framework-extra-bundle": "^3.0.2",
    "incenteev/composer-parameter-handler": "~2.0",
    "braincrafted/bootstrap-bundle": "~2.0",
    "twbs/bootstrap": "3.0.*",
    "jquery/jquery":  "1.11.*",
    "hwi/oauth-bundle": "^0.5.0",
    "friendsofsymfony/user-bundle": "~2.0@dev",
    "stephanecollot/datetimepicker-bundle": "dev-master"
},
"require-dev": {
    "sensio/generator-bundle": "~3.0",
    "symfony/phpunit-bridge": "~2.7"
},
"scripts": {
    "symfony-scripts": [
        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
    ],
    "post-install-cmd": [
        "@symfony-scripts"
    ],
    "post-update-cmd": [
        "@symfony-scripts"
    ]
},
"config": {
    "bin-dir": "bin"
},
"extra": {
    "symfony-app-dir": "app",
    "symfony-web-dir": "web",
    "symfony-assets-install": "relative",
    "incenteev-parameters": {
        "file": "app/config/parameters.yml"
    }
}

推荐答案

我已经看过几次这样的问题,但是找不到答案和解释都可以接受的问题.这样吧.

I have seen this sort of question several times but I could not find one with an accepted answer and explanation. So here goes.

基本问题在于:

"friendsofsymfony/user-bundle": "~2.0@dev",

当Symfony 2.8/3.0首次发布时,稳定的1.x版本的FOSUserBundle不再起作用. 2.x版本已经开发了多年,没有什么实际的路线图可以稳定它.因此,开发部门被黑以使其正常工作.而且人们别无选择,只能使用它,这当然是危险的,因为您不知道何时进行开发更改实际上可能会破坏您的代码.

Back when Symfony 2.8/3.0 was first released, the stable 1.x version of FOSUserBundle no longer worked. The 2.x version has been in development for years with no actual road map in sight for when it would be stabilized. So the development branch was hacked up to get it working. And folks had no choice but to use it which of course is dangerous because you never know when a development change might in fact break your code.

时间流逝,最终发布了稳定的2.x版本的FOSUserBundle.但是,相当多的开发人员从未更新过他们的依赖关系,而是继续使用master分支.

Time went by and eventually a stable 2.x version of the FOSUserBundle was released. However, quite a few developers never got around to updating their dependencies and continued to use the master branch.

快进当下.现在,Symfony 4的发布已经触发了master分支中的大量开发.开发正在对现有的2.8(可能是3.0)代码进行重大更改.

Fast forward to the present. The release of Symfony 4 has now triggered a fair amount of development in the master branch. Development which is introducing breaking changes to existing 2.8 (and probably 3.0) code.

最重要的是要使用一个稳定的分支,并带有:

The bottom line is to use a stable branch with:

"friendsofsymfony/user-bundle": "~2.0",

随后是作曲家更新.

这篇关于供应商更新通过“在非对象上调用成员函数has()"破坏了FOS用户捆绑包.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆