dongliu6848 2011-09-08 16:56
浏览 54
已采纳

为什么我的dev前端控制器包含在Assetic URL中?

I'm using Assetic to include Javascript files, but when used in the dev environment, /app_dev.php is added to the beginning of the URL, so the final url looks like /app_dev.php/js/something.js. This results in a 404 when trying to load the JS. When I access the site from the production environment the URLs don't include /app_dev.php and everything works fine.

I could add a conditional that checks if it's the dev environment and call str_replace on the URLs, but I'd like to solve the root of this problem, if possible.

Edit

@gilden, I would understand that in dev they would get processed every time, but the URLs simply result in 404s.

Here's my Assetic config:

assetic:
    debug:          %kernel.debug%
    use_controller: false
    filters:
        cssrewrite: ~
        # closure:
        #     jar: %kernel.root_dir%/java/compiler.jar
        # yui_css:
        #     jar: %kernel.root_dir%/java/yuicompressor-2.4.2.jar

And here's how I'm using it in my template (app/Resources/views/base.html.php)

foreach ($view['assetic']->javascripts(
            array('@AssetsBundle/Resources/public/js/*'), array(), array('output' => 'js/combined.js')) as $url) {
            echo 'url: ' . $url . '<br />';    
        }

I then include $url using a custom helper I wrote, but it already contains app_dev.php at that point.

  • 写回答

1条回答 默认 最新

  • doufu2396 2011-09-08 18:23
    关注

    I haven't used php templating in Symfony so I'm afraid I don't have the best answer. By using some custom code, you're probably circumventing some internal logic, which handles the request to a controller.

    As a workaround you could try removing assetic: use_controller: true from /app/config_dev.yml.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题