首页 \ 问答 \ Symfony 2 / Sylius - 在AppKernel中加载Bundle但无法加载资源(Symfony 2/Sylius - Bundle loaded in AppKernel but can't load resource)

Symfony 2 / Sylius - 在AppKernel中加载Bundle但无法加载资源(Symfony 2/Sylius - Bundle loaded in AppKernel but can't load resource)

我使用generate:bundle生成了一个包( @ShopfishApiBundle ),就像我有很多次一样。 它已经在AppKernel自动注册了bundle,并且它AppKernel bundle的routing.yml加载到了app/Resource/config/routing.yml 。 这是在运行Symfony 2.3Sylius安装中

@ShopfishApiBundle/Resource/config/routing.yml如下所示:

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

产品控制器如下所示:

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);
    }
}

立即加载任何页面会产生以下异常:

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

在另一个Symfony2(版本2.4)应用程序中,我已经制作了一个类似的包,这个工作没有错误,我在思考Sylius的一些东西搞砸了。 你知道我可以在哪里解决这个问题吗?

注意:我做了一点测试,看看一个直接无注释的代码片段是否有效,这似乎有效。 虽然我想使用FOS Rest软件包,但使用Annotations for Routing。

sf_api_controller:
    pattern: /no-annotation-test
    defaults:
         _controller: ShopfishApiBundle:Product:all

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

原文:https://stackoverflow.com/questions/22866182
更新时间:2022-05-26 20:05

最满意答案

感谢leppie指点我指向dotras.codeplex.com的方向 - 尽管我最终没有使用该库,查看它的源代码帮我修复了自己的...

关键在于RASENTRY的定义......下面第一行的变化使它起作用

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 4)]
public struct RASENTRY
{
    public int       dwSize;
    public int       dwfOptions;
    public int       dwCountryID;
    public int       dwCountryCode;

// etc.

Thanks leppie for pointing me in the direction of dotras.codeplex.com - although I didn't end up using that library, looking at its source code helped me fix my own...

The key was in the definition of RASENTRY... The change in the first line below made it work

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 4)]
public struct RASENTRY
{
    public int       dwSize;
    public int       dwfOptions;
    public int       dwCountryID;
    public int       dwCountryCode;

// etc.

相关问答

更多

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)