Mir*_*age 3 annotations symfony sylius
我已经多次生成了一个bundle(@ShopfishApiBundle)generate:bundle.它会自动注册到捆绑AppKernel,并将其列入了包的的装载routing.yml到app/Resource/config/routing.yml为好.这是在Sylius安装运行中Symfony 2.3
该@ShopfishApiBundle/Resource/config/routing.yml如下所示:
shopfish_api:
resource: "@ShopfishApiBundle/Controller/ProductController.php"
type: annotation
Run Code Online (Sandbox Code Playgroud)
产品控制器如下所示:
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);
}
}
Run Code Online (Sandbox Code Playgroud)
立即加载任何页面会产生以下异常:
FileLoaderLoadException: Cannot load resource "@ShopfishApiBundle/Controller/". Make sure the "ShopfishApiBundle" bundle is correctly registered and loaded in the application kernel class.
Run Code Online (Sandbox Code Playgroud)
在另一个Symfony2(版本2.4)应用程序中,我制作了一个类似的包,这个工作没有错误,我在思考Sylius的一些事情搞砸了.你知道我可以在哪里解决这个问题吗?
注意:我做了一些测试,看看直接无注释代码片段是否有效,这似乎有效.虽然我想使用FOS Rest软件包,但使用Annotations for Routing.
sf_api_controller:
pattern: /no-annotation-test
defaults:
_controller: ShopfishApiBundle:Product:all
Run Code Online (Sandbox Code Playgroud)
我没有注册SensionFrameworkExtraBundle我的必需品AppKernel.php:
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle()
谢谢,@ pazi!
| 归档时间: |
|
| 查看次数: |
2220 次 |
| 最近记录: |