How to generate basic CRUD in Symfony2 - symfony

I'm new in Symfony and I was wondering if there is a way to generate basic CRUD elements for database, preferably with Bootstrap 3. Other frameworks (Laravel, CakePHP) set you off with a functional application.

The best bundle IMHO is EasyAdminBundle by Javier Eguiluz.
But you can also look at AdminGeneratorBundle and SonataAdminBundle
All of these bundles use Bootstrap.

By default the command is run in the interactive mode and asks questions to determine the entity name, the route prefix or whether or not to generate write actions:
php app/console generate:doctrine:crud
To deactivate the interactive mode, use the --no-interaction option but don't forget to pass all needed options:
php app/console generate:doctrine:crud --entity=AcmeBlogBundle:Post --format=annotation --with-write --no-interaction

Related

How to extract translations from a custom vendors bundle

I actually trying to create my own reusable bundle. I created a Demo project that include my custom bundle as dependency using symlink composer config.
Actually, I tried to extract some translation keys from my custom bundle into the demo project.
But when I launch the command bin/console translation:update fr --dump-messages there is no entry from my bundle.
What I want to extract is some constant keys that I want to translate.
For example, in MyCustomClass there is some status in an array. So I don't know if there is an Interface that I can implement to auto extract my translation keys.
I'm using:
Symfony Framework 5.3.8
Symfony Translation 5.3.9
Thanks

Setup symfony CMF

I want to start with Symfony CMF, but I have a problem. I followed tutorial but instead of using default SQL, I need MySQL with doctrine ORM, so I tried configuring it following these guides. Everything looks good until I try to initiate database, by using following command using Doctrine ORM:
$ php app/console doctrine:database:create
$ php app/console doctrine:schema:create
but after firing
$ php app/console doctrine:schema:create
I get error: "No Metadata Classes to process."
As far as my conclusion goes, I need to create some classes which will act as routes, though nothing of that sort is mentioned in above guides. To avoid long post I setup git repo with source code. What may be the cause of this problem, and how could I fix it?
From your repository, it seems you did not configure doctrine orm at all. you are referencing the setup guides for phpcr-odm and your sandbox is configured to use phpcr-odm. you can use jackalope-doctrine-dbal to use phpcr-odm with mysql.
if you really want to use the cmf with doctrine orm, only the RoutingBundle provides entities out of the box, and you will need to adjust those to suit your project.

Manually editing and deleting an entity - Symfony2

How do I manually edit and delete an entity in Symfony2?
I get that it creates a class, but how do I edit everything? I'm guessing I can't just change the PHP class file.
So which files does it create when you use the automatic entity generator and is there an automated-edit command? I use Yaml.
I know with bundles then you there are three files that the automated console command creates/changes, but I can't see any info as to how for entities.
I like to use the automation to save time, but still like to know actually what is being done etc.
Modify your php code ( Entities code ) then just run
php app/console doctrine:generate:entities BundleName:EntityName
you may also want to update your db by running
php app/console doctrine:schema:update --force

Location of propel.ini for symfony2?

I am migrating from symfony1 to symfony2, I have hard time implementing propel behaviors. Where do I actually have the propel.ini in symfony2?
Well in sf1.4, it was inside root config directory. How about symfony2?
The Propel ORM Symfony2 page says this:
You can add a app/config/propel.ini file in your project to specify some configuration parameters. ... However, the recommended way to configure Propel is to rely on build properties.
You can define build properties by creating a propel.ini file in app/config like below, but you can also follow the Symfony2 convention by adding build properties in app/config/config.yml
So I believe you can come close to the Symfony1 behaviour by creating app/config/propel.ini, but the more idiomatic way is to use app/config/config.yml as that page illustrates.
Caveat: I haven't used Propel with Symfony2, so this answer is solely based on the manual.

Deleting not needed bundles from Symfony 2?

Is possible to delete bundles not needed in order to keep the project clean? I'm using Symfony2 with propel to build a RESTful interface. Don't need:
Twig
Doctrine2 (i prefer Propel instead)
Assetic (without Twig assetic does not make sense, correct me if i'm wrong)
Security (no need to model roles)
I can't find any how-to in order to remove uneeded bundles. Any help is much appreciated.
EDIT: monlog is the logger, not mongodb. Need it!
About deps.lock file: it can be removed after removing bundles, than issue:
php bin/vendors update
and i should be recreated. It maintains the git version id checked out, for each bundle.
Sure. Remove them from AppKernel then delete from the file system if you want. You could even edit the deps file to keep them from coming back. Twig and Assetic are independent. You could use the Assetic bundle with straight PHP.
In case anyone else runs into this issue, you can follow the instructions in the Symfony2 docs to remove the Acme Bundle: http://symfony.com/doc/2.0/cookbook/bundles/remove.html
The proccess is like this:
delete /src/Test/BlogBundle directory
change /app/config/routing.yml file to remove the bundle routes
Unregister your bundle from /app/AppKernel.php
clear cache (either by deleting cache/{$env} or console cache:clear)

Resources