当前位置:  开发笔记 > 编程语言 > 正文

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

如何解决《Symfony2.8:自2.8以来,不推荐使用ResourceInterface::isFresh()》经验,为你挑选了2个好方法。

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

"Symfony\Bundle\AsseticBundle\Config\AsseticResource"类通过ResourceInterface :: isFresh()执行资源检查,自2.8以来不推荐使用,将在3.0中删除(54次)

堆栈(来自Symfony profiler)

BCResourceInterfaceChecker::isFresh() (called from bootstrap.php.cache at line 3061)
ResourceCheckerConfigCache::isFresh() (called from ResourceCheckerConfigCacheFactory.php at line 45)
ResourceCheckerConfigCacheFactory::cache() (called from classes.php at line 1328)
Router::getMatcher() (called from classes.php at line 1288)
Router::match() (called from classes.php at line 7170)
Router::match() (called from classes.php at line 2086)
RouterListener::onKernelRequest()
call_user_func() (called from WrappedListener.php at line 61)
WrappedListener::__invoke()
call_user_func() (called from classes.php at line 1853)
EventDispatcher::doDispatch() (called from classes.php at line 1771)
EventDispatcher::dispatch() (called from TraceableEventDispatcher.php at line 132)
TraceableEventDispatcher::dispatch() (called from bootstrap.php.cache at line 3178)
HttpKernel::handleRaw() (called from bootstrap.php.cache at line 3151)
HttpKernel::handle() (called from bootstrap.php.cache at line 3302)
ContainerAwareHttpKernel::handle() (called from bootstrap.php.cache at line 2498)
Kernel::handle() (called from app_dev.php at line 29)

升级我使用过:

composer.phar update symfony/symfony --with-dependencies

这是我的composer.json

{
    "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"
        }
    }
}

怎么解决这个弃用警告?



1> Joshua..:

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

它们链接到Assetic GitHub页面,该页面声称2.7.1已准备好用于Symfony 3.但显然它不是.就这么简单.Assetic只是不准备symfony 3所以它会在2.8中产生大量的弃用通知.修复此问题的合并请求尚未合并.



2> Don Omondi..:

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

composer.json

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

作曲家更新symfony/assetic-bundle

所有错误都消失了.


您将获取正在开发的版本(因此标记dev-master),该版本始终具有新功能(并删除折旧代码)但尚未经过彻底测试以确保与第3版的兼容性派对延期.通常情况下,开发大师非常稳定,但由于人们没有时间对其进行测试,因此需要很长时间才能稳定运行,现在它将解决您的问题.
推荐阅读
依然-狠幸福
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有