Category Archives: Doctrine

Symfony2: My Form Type Class generator

Symfony2 has a Doctrine Form Generator. It is work properly but it always needs Entity as a parameter and it only generates one Form Type Class at the same time.I’ve rebuild the generator. My generator supports bulk form generation and … Continue reading

Posted in Doctrine, form generator, Symfony2 | Leave a comment

Symfony2: How to generate new form type class?

Generate test bundle: php app/console generate:bundle –namespace=Acme/TestBundle –format=yml Mapping databse, generate entities: php app/console doctrine:mapping:convert yml ./src/Acme/TestBundle/Resources/config/doctrine/metadata/orm –from-database –force php app/console doctrine:mapping:import AcmeTestBundle annotation php app/console doctrine:generate:entities AcmeTestBundle Generate form type class (I used FosUSerBundle db tables in this example): … Continue reading

Posted in Doctrine, form generator, Symfony2 | Leave a comment

Symfony2 command line and Doctrine

<?php namespace ProjectName\TestBundle\Command; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use PDO; class TestCommand extends ContainerAwareCommand { protected $em = NULL; protected function configure() { $this ->setName(‘testcommandlineapp’) ->setDescription(‘Blabla’) ->setDefinition(array()); } protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln( ‘Working…’ … Continue reading

Posted in CommandLine, Doctrine, Symfony2 | Leave a comment

Symfony2, Doctrine – get the primary key field name in controller

If you need the primary key name in the Symfony2 controller you can get in this way: public function setGridDataAction(Request $request) { $em = $this->getDoctrine()->getEntityManager(); $meta = $em->getClassMetadata(‘AcmeTestBundle:TestTable’); $sPrimaryKeyName =$meta->getSingleIdentifierFieldName(); //get primary key name $aAllField = $meta->getFieldNames(); //get all field … Continue reading

Posted in Doctrine, get all field name, get primary key name, Symfony2 | 3 Comments

Symfony2 – FOSUserBundle a sfDoctrineGuardPlugin helyett

A FOSUserBundle egy Symfony2-höz készült felhasználó kezelő, biztonsági bundle, mely kiválthatja az sfDoctrineGuardPlugin-t (vagy az sfGuardPlugin-t). A FOSUserBundle telepítése viszonylag egyszerű, ha pontosan követed a telepítési útmutatót: https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/index.md akkor működnie kell, legalábbis nekem elsőre működött 🙂 ami nem éppen átlagos … Continue reading

Posted in Doctrine, FOSUserBundle, sfDoctrineGuardPlugin, Symfony2, User Bundle | Leave a comment