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.3
的Sylius
安装中
@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
) usinggenerate:bundle
like I have many times. It has automatically registered the bundle in theAppKernel
and it added the loading of the bundle'srouting.yml
to theapp/Resource/config/routing.yml
as well. This is within aSylius
installation runningSymfony 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
最满意答案
感谢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.
相关问答
更多-
如何只循环(假设很少)N个实例: addZeros <- function(x, N = 3) { xx <- x z <- x - 1 for (i in 1:N) { xx <- xx + c(rep(0, i), z[-c((NROW(x) - i + 1):NROW(x))]) } xx[xx<0] <- 0 xx } 只需将所有零实例转换为-1,即可减去N个后续值。 > x <- c(1,1,1,1,1,1,1,1,0,0,0,0, ...
-
使用str_pad() $val = 1; echo str_pad($val,4,"0",STR_PAD_LEFT); // 0001 $val = 10; echo str_pad($val,4,"0",STR_PAD_LEFT); // 0010 use str_pad() $val = 1; echo str_pad($val,4,"0",STR_PAD_LEFT); // 0001 $val = 10; echo str_pad($val,4,"0",STR_PAD_LEFT); // 00 ...
-
awk加零(awk adding on zeroes)[2022-06-17]
那么我不知道你的输入文件,但这个awk命令: awk -v q=, "/$x/ { count++ } END { print $x q count }" 肯定是不正确的。 您需要使用相同的-v选项传递$x以传递变量q 。 试试这个awk命令: awk -v x="$x" -v q="," '$0 ~ x { count++ } END { print x q count }' 很可能所有的脚本都可以用一个awk命令编写,并且不需要不必要的cat, awk, uniq等。 Well I don't kn ... -
感谢leppie指点我指向dotras.codeplex.com的方向 - 尽管我最终没有使用该库,查看它的源代码帮我修复了自己的... 关键在于RASENTRY的定义......下面第一行的变化使它起作用 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 4)] public struct RASENTRY { public int dwSize; public int dw ...
-
领先零后的逗号(Comma after leading zeroes)[2022-03-23]
这可以通过正则表达式轻松完成。 In [1]: import re In [2]: def reformat_numbers(num): ...: return float(re.sub('^0', '0.', num)) ...: In [3]: [reformat_numbers(n) for n in ['00', '20', '15', '05', '003', '01']] Out[6]: [0.0, 20.0, 15.0, 0.5, 0.03, 0.1] This i ... -
你想使用的函数是zeros而不是zeroes The function you want to use is zeros not zeroes
-
这条线 while (toRead < 0) 确保你从未真正阅读过。 在循环之前,toRead将> = 0。 然后转储从未填充的字节数组。 This line while (toRead < 0) makes sure you never actually read. toRead will be >= 0 before the loop. Afterwards you dump the byte array that was never filled.
-
删除除数字以外的所有零(Remove all zeroes except in numbers)[2024-03-20]
我不相信正则表达式是解决此问题的最佳方法,但是这个适用于所有测试用例: string clean = Regex.Replace(dirty, @"(?这是你想要做的吗? #include#include int main() { int length = 4; printf("How long do you want your pi: "); if (1 == scanf("%d", &length)) printf("%.*f\n", length, M_PI); return 0; } 样本输出#1 How long do you want your pi: ... 如何删除右边的零(How to remove zeroes to the right)[2022-07-13]
以下应该有效: sed -e 's/\(\.[1-9][1-9]*\)0*/\1/g' -e 's/\.00*//' xmlFile.xml 这将导致以下结果:3.14 3 something 3.1 ... 相关文章
更多- Symfony2网站开发
- OSGi Service 和 Bundle扩展点 的区别,谢谢大家
- Unable to load configuration.
- 【第四章】 资源 之 4.2 内置Resource实现 ——跟我学spring3
- form load 的问题
- 【第四章】 资源 之 4.4 Resource通配符路径 ——跟我学spring3
- 【第四章】 资源 之 4.3 访问Resource ——跟我学spring3
- gui求jtapi高手T_T
- 移动MM failed to find resource file{mmiap.xml}
- hibernate延迟加载
最新问答
更多- 您如何使用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)