Symfony 2.8:自2.8以来,不推荐使用ResourceInterface :: isFresh()

时间:2015-12-07 16:39:27

标签: php symfony symfony-2.8

升级到Symfony后,我发现了很多弃用警告:

  

班级" Symfony \ Bundle \ AsseticBundle \ Config \ AsseticResource"是   通过ResourceInterface :: isFresh()执行资源检查,   自2.8以来已弃用,将在3.0(54次)中删除

Stack(来自Symfony profiler)

{
    "name": "framework/symfony",
    "license": "proprietary",
    "type": "project",
    "autoload": {
        "psr-4": {
            "": "src/"
        }
    },
    "require": {
        "php": ">=5.3.9",
        "symfony/symfony": "2.8.*",
        "doctrine/orm": "^2.4.8",
        "doctrine/doctrine-bundle": "~1.4",
        "symfony/assetic-bundle": "~2.3",
        "symfony/swiftmailer-bundle": "~2.3",
        "symfony/monolog-bundle": "~2.4",
        "sensio/distribution-bundle": "~4.0",
        "sensio/framework-extra-bundle": "^3.0.2",
        "incenteev/composer-parameter-handler": "~2.0"
    },
    "require-dev": {
        "sensio/generator-bundle": "~2.3"
    },
    "scripts": {
        "post-install-cmd": [
            "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-update-cmd": [
            "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"
        ]
    },
    "config": {
        "bin-dir": "bin"
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "symfony-assets-install": "relative",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        }
    }
}

升级我用过:

 var sort = $(this).val();
 var dealId = $('#dealId-hidden-field').val();
 var urlItems = $('#url-items-hidden-field').val();

 urlItems = urlItems+"?dealId="+dealId+"&sort"+sort;

 //Let's write to console to verify the url is correct.
 console.log(urlItems);

 $.get(urlItems,function(res){

    console.log('result from server',res);
    $('#Product-Items-Container').html(res);

 });

这是我的composer.json

{{1}}

如何解决此弃用警告?

3 个答案:

答案 0 :(得分:13)

一些谷歌搜索发现了这个:https://knpuniversity.com/screencast/symfony3-upgrade/fix-deprecations-in-bundles

他们链接到Assetic GitHub页面,声称2.7.1已准备好用于Symfony 3.但显然不是。就这么简单。 Assetic只是不准备symfony 3所以它会在2.8中产生大量的弃用通知。 merge request to fix this尚未合并。

答案 1 :(得分:10)

dev-master分支已经与Symfony 3兼容了几个星期了。更新使用它没有任何问题。

composer.json

....
"symfony/assetic-bundle": "dev-master",
....

composer update symfony / assetic-bundle

所有错误消失。

答案 2 :(得分:1)

您是否尝试过将资产包版本更新为最新版本?

"symfony/assetic-bundle": "~2.7",