this is probably a typo but I can't see it... it drives me crazy !
my structure is:
Bundle : /Symfony24/src/NRtworks/ChartOfAccountsBundle
My form: /Symfony24/src/NRtworks/ChartOfAccountsBundle/Form/Account_fastedit_form.php
The controller is like this:
<?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();
}
}
?>
my form class in 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
}
?>
then I get:
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?
I don't find my error. ps: as you can see I can use my form NewCustomer, in another bundle without any problem, and the structure is similar...
I tested this here and I can confirm that Symfony does not like the fact you have underscores in your class name.
Change the class to AccountFasteditForm
, the file containing the class to AccountFasteditForm.php
and update your use
statements. It should work then.
EDIT
Hunting down some information about this, I suspected it was related to PSR-0. You'll find in the doc:
Each _ character in the CLASS NAME is converted to a DIRECTORY_SEPARATOR. The _ character has no special meaning in the namespace.
Implying that _
is fine in namespaces but not in class names.
I also found reference in the Symfony docs that class names must be camel-case (again implying that underscored namespaces are fine)