2014-04-09 11 views
1

这可能是一个错字,但我看不到它......它让我疯狂!不能“使用”在symfony2.4中的表格

我的结构是:

软件包:/ Symfony24/src目录/ NRtworks/ChartOfAccountsBundle

我的形式:/Symfony24/src/NRtworks/ChartOfAccountsBundle/Form/Account_fastedit_form.php

该控制器像这样:

<?php 

namespace NRtworks\ChartOfAccountsBundle\Controller; 
//form loading 
use NRtworks\ChartOfAccountsBundle\Form\Account_fastedit_form; 
use NRtworks\SubscriptionBundle\Form\NewCustomer; 

class ChartOfAccountsController extends Controller 
{ 
    public function indexAction() 
    { 
     new NewCustomer(); 
     new Account_fastedit_form(); 
    } 

} 

?> 

表格我的表格类/ Account_fastedit_form.php

<?php 

namespace NRtworks\ChartOfAccountsBundle\Form; 

use Symfony\Component\Form\AbstractType; 
use Symfony\Component\Form\FormBuilderInterface; 

class Account_fastedit_form extends AbstractType 
{ 
    //whatever 
} 
?> 

然后我得到:

ClassNotFoundException: Attempted to load class "Account_fastedit_form" from namespace "NRtworks\ChartOfAccountsBundle\Form" in /home/eagle1/www/Symfony24/src/NRtworks/ChartOfAccountsBundle/Controller/ChartOfAccountsController.php line 72. Do you need to "use" it from another namespace? 

我不觉得我的错误。 PS:你可以看到我可以用我的形式NewCustomer,另一束没有任何问题,而且结构相似...

+0

Symfony的可能不喜欢你混合的事实'CamelCase'和'snake_case'在你的班级命名方案中为'NRtworks \ ChartOfAccountsBundle \ Form \ Account_fastedit_form' –

回答

0

我这里测试这一点,我可以证实,Symfony的不喜欢你的事实在你的课堂名称中强调。

将类更改为AccountFasteditForm,包含类的文件为AccountFasteditForm.php并更新您的use语句。它应该工作。

编辑

追捕关于这个的一些信息,我怀疑这是有关PSR-0。您可以在文档中找到:

CLASS NAME中的每个_字符都转换为DIRECTORY_SEPARATOR。 _字符在命名空间中没有特殊含义。

言下之意是_在命名空间不错,但在类名。

我也是在Symfony的文档类名称必须是驼峰发现引用(再次暗示下划线的命名空间是罚款)

Here is a similar SO question

+0

就是这样,非常感谢! – Eagle1

+0

没有问题!乐意效劳 :) –