VaN
VaN

Reputation: 2210

New Route returning 404

I'm trying to install the following bundle on my site : https://github.com/comur/ComurImageBundle

I did everything mentioned in the Installation part. I can see the bundle is successfully installed, I have no error on the admin panel. But when the modal creatd by the bundle, I got a JS error saying a malformed JSON was received from /image-library route. If I browse this route in a browser, I get a 404 page, and I don't understand why. I checked the route, everything looks fine :

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

The route debug seems OK. And I succesfully exposed the route to FOSJSRouting bundle with php app/console fos:js-routing:dump, I can find the route in my fos_js_routes.js :

"comur_api_image_library":{"tokens":[["text","\/image-library"]],"defaults":[],"requirements":[],"hosttokens":[]}},"prefix":"","host":"localhost","scheme":"http"}

I cleared cache, rebuilt bootstrap.php.cache, and still this route returns 404. Any idea ?

Upvotes: 1

Views: 2658

Answers (1)

VaN
VaN

Reputation: 2210

I finally found the problem.

My main routing file was the following :

# 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"

I swapped to

# 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:   /

And everything works fine. This ZF1Bundle Route resolver has to be the last route defined. I guess only few ppl will use this bundle, but maybe this answer will help someone.

Upvotes: 1

Related Questions