Question

I've generated a bundle (@ShopfishApiBundle) using generate:bundle like I have many times. It has automatically registered the bundle in theAppKernel and it added the loading of the bundle's routing.yml to the app/Resource/config/routing.yml as well. This is within a Sylius installation running Symfony 2.3

The @ShopfishApiBundle/Resource/config/routing.yml looks like this:

shopfish_api:
    resource: "@ShopfishApiBundle/Controller/ProductController.php"
    type:     annotation

The product controller looks like this:

namespace Shopfish\Bundle\ApiBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

/**
 * @Route("/api")
 */    
class ProductController extends Controller
{
    /**
     * @Route("/products")
     * @Method({"GET"})
     *
     * @Rest\View
     */
    public function allAction()
    {
        $products = array();

        return array('products' => $products);
    }
}

Loading any page instantly yields the below exception:

FileLoaderLoadException: Cannot load resource "@ShopfishApiBundle/Controller/". Make sure the "ShopfishApiBundle" bundle is correctly registered and loaded in the application kernel class.

In another Symfony2 (version 2.4) application I've made a similar bundle and this worked without error, I'm thinking something in Sylius messes this up. Do you know where I might solve this issue?

NOTE: I did a little test to see if a direct-no-annotations code snippet worked, and that seems to work. Though I want to use the FOS Rest bundle, using Annotations for Routing.

sf_api_controller:
    pattern: /no-annotation-test
    defaults:
         _controller: ShopfishApiBundle:Product:all
Was it helpful?

Solution

I hadn't registered the essential SensionFrameworkExtraBundle in my AppKernel.php:

new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle()

Thanks, @pazi!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top