我尝试在我的网站上安装以下软件包:https://github.com/comur/ComurImageBundle
我做了安装部分中提到的所有内容。我可以看到捆绑包已成功安装,我在管理面板上没有错误。但是当捆绑的modal创建时,我得到一个JS错误,说从/ image-library路由收到了格式错误的JSON。 如果我在浏览器中浏览此路线,我会得到一个404页面,但我不明白为什么。我检查了路线,一切都很好看:
C:\server\www>php app/console router:debug comur_api_image_library
[router] Route "comur_api_image_library"
Name comur_api_image_library
Path /image-library
Host ANY
Scheme ANY
Method ANY
Class Symfony\Component\Routing\Route
Defaults _controller: Comur\ImageBundle\Controller\UploadController::getLibraryImagesAction
Requirements NO CUSTOM
Options compiler_class: Symfony\Component\Routing\RouteCompiler
expose: true
Path-Regex #^/image\-library$#s
路由调试似乎没问题。我成功地通过php app / console fos将路径发送到FOSJSRouting捆绑包:js-routing:dump,我可以在我的fos_js_routes.js中找到路由:
"comur_api_image_library":{"tokens":[["text","\/image-library"]],"defaults":[],"requirements":[],"hosttokens":[]}},"prefix":"","host":"localhost","scheme":"http"}
我清除了缓存,重建了bootstrap.php.cache,但这条路线仍然返回404。 有什么想法吗?
答案 0 :(得分:1)
我终于找到了问题。
我的主要路由文件如下:
# Route ZF1 Wrapper
zf1_wrapper:
resource: "@Zf1WrapperBundle/Resources/config/routing.yml"
prefix: /
# Routes Bundles Tiers
comur_image:
resource: "@ComurImageBundle/Resources/config/routing.yml"
prefix: /
fos_js_routing:
resource: "@FOSJsRoutingBundle/Resources/config/routing/routing.xml"
我换了
# Routes Bundles Tiers
comur_image:
resource: "@ComurImageBundle/Resources/config/routing.yml"
prefix: /
fos_js_routing:
resource: "@FOSJsRoutingBundle/Resources/config/routing/routing.xml"
# Route ZF1 Wrapper
zf1_wrapper:
resource: "@Zf1WrapperBundle/Resources/config/routing.yml"
prefix: /
一切正常。此ZF1Bundle路径解析器必须是最后定义的路径。我想只有少数人会使用这个包,但也许这个答案会帮助别人。