Symfony2 generate crud for third party bundle - symfony

It is possible to generate a basic admin interface using the CRUD generator for my Entities.
i.e. php app/console generate:doctrine:crud
The question is, can this also be done for an entity bundled by a vendor? I get errors about not finding the entity I want.
Thank you

It seems that you want to add extra functionality to the vendor bundle so you might need to extend it.
Symfony2 Inhertiance

Related

Cakephp model->save equivalent in symfony framework without doctrine

I need the equivalent method in symfony framework which is there cakephp model->save() method , I do not want to use doctrine orm I just need cakephp like solution to my problem
What you're looking for (i.e. $model->save()) is called Active Record. Doctrine was using it in version 1.x but it does not anymore since version 2.x. You need to find some ORM which does and use it in your Symfony application. As far as I know you can't use Cake's ORM as a standalone component hence you can't inject it in Symfony so you need to find some other Active Record ORM.
You should give Propel a try (and its integration with Symfony - PropelBundle
)
You need to take time to approach Symfony2, you just can't look for an equivalent for every single thing. Learning how to do things "the Symfony" way will be worth in the mid/long run, because the logic is different between those 2 frameworks in many places you won't be able to reason like this for long.
A great place to start is the Symfony book: http://symfony.com/doc/current/index.html
Without Doctrine, you don't have the notion of "model". Then you can only fall back to save (array) data manually using PDO.

Symfony: Relation between Bundles and Services

I'm planning to write an AJAX extension for the forms in Symfony3. I want to be able to use ajax requests in many forms instead of submissions.
Now I don't understand the exact relation between Bundles and Services.
As I understand it to write a service is the right way to do so. At the same time I want to make my code reusable, so I can use it in further projects.
My extension needs to have some JS and TWIGs I guess.
So, is the right way for deploying my service to encapsulate in a bundle? Or are they bundles theirself? Or can they be deployed without encapsulating?
If you want to make your code reusable, you need to make your bundle configurable, basic steps to achieve it:
Create a bundle:
http://symfony.com/doc/current/bundles/SensioGeneratorBundle/commands/generate_bundle.html
Making it configurable:
http://symfony.com/doc/current/cookbook/bundles/configuration.html
You need to put it in another repository and read it later using git submodule or packagist, depending on your strategy or if its private or not.
This steps will means your bundle cannot depend of any class internally created in your project, I would recommend to you to check some other bundles around.
A good example can be the Tactitian bundle, which integrates the League Pipeline library into SF https://github.com/thephpleague/tactician-bundle
In this code you can see how they configure the library and create the services around it!
I hope this helps you!

What is the correct way to extend an existing entity in a Symfony bundle

I have a symfony project.
In the core bundle (the appBundle) I have a User entity.
This project is used by several of my clients, and different clients need different features.
I'm trying to encapsulate a feature in a bundle, but that feature needs to add fields to the User entity in the appBundle.
I'd rather not change the appBundle but rather keep all the changes in the feature bundle.
What's the correct way to do that?
(would creating an entity in the feature bundle to hold the additional fields, and connecting it in a one to one relationship a good idea?)
Assuming doctrine, have you looked into Table Inheritance?
Your AppBundle could provide just a Mapped Superclass and the feature bundles could inherit from it.

Symfony2 user manager bundles?

Which are the best user manager bundles for Symfony 2 and why?
I only know FOSUserBundle.
Are there other good bundles for managing users?
(like it was sfDoctrineGuardPlugin for Symfony 1)
I need not a final, closed solution, but the pros and contras for someone to be able to choose the best bundle depending on his needs.
Firstly, i wrote an UserBundle implementation for my requirements, after i discovered FOSUserBundle and i learned best practices from it.
I think FosUserBundle is a good choice for user manager in Symfony 2. Because
Actively maintained and supported
Provides command line commands for creating new user, activating, promoting etc.
Built-in forms, controllers and views for user related actions.
Supports Doctrine, Propel, CouchDB and Mongo for persistance.
Localization, translations
Optional features like email activation
Supported by other bundles like Sonata bundles
I never worked with other UserBundle, but i highly recommend to use FOSUserBundle.

Symfony2 Backend?

I am new to Symfony, please don't scold me about this question.
I read in a Symfony 1.4 book that there is a functionality of adding backends to your applications via doctrine:generate-admin or generate:app backend, implementing CRUD operations.
Now I wonder, is there anything similiar with Symfony2.0?
Basically I have an user management and a database in the background that I would love to have available for my Admin Users, but do I have to code it myself (i.e. securing the are /admin, creating templates, classes, methods etc. that fulfill this tasks) or can it be done more easy by using some kind of an already existing backend functionality?
Thanks!
EDIT: Also read there's a plugin called "Apostophe" - but isn't there anything included with SF2 or are there any preconfigured SF2 Versions that already come with Backend solutions?
There's the SonataAdminBundle (and possibly a few more I haven't seen) that helps provide an admin system, however this area is still being worked on heavily by the Symfony2 community.
Lukas has put together a blog article on the current state of development of a Symfony2 CMF, with some rough timescales - State of the Symfony2 CMF
Hope this helps!
Also there is another bundle for managing the admin. You can take a look here http://knpbundles.com/cedriclombardot/AdmingeneratorGeneratorBundle
For "admin generation", Symfony2 is not yet with the code generation on that aspect. The base is VERY STRONG. Remember Symfony2 is still at 2.0 stage. (Not 2.1++ like symfony1).
If you want cut and paste code. Symfony2 is not exactly for that.
DISCLAIMER
I am more specialized in frontend than backend, but I got around stuff. But Thanks to Symfony2. I can be on both sides. So I speak from this context.
CAVEATS
What I call "good stuff".
Only using ONE {{ form_widget(form) }} that Symfony form documentation recommends ... and not explictly cut and pasting from the Twig tutorial that is /meant/ to show how to do theme... not to implement like it is shown.
Thinnest controller methods possible
... out of scope of this post.
SO
My best advice is serious RTFM, a few times, with Symfony books. It is scary, but I am working with it since three months and re-reading a lot. Everytime I get excited with gems.
ANSWER IN QUESTION
My current choice of bundles is:
FR3DLdapBundle, with FOSUserBundle
MopaBootstrapBundle along with all code generated with HTML/CSS structure Twitter Bootstrap gives. (if you haven't heard of it, yet, where were you?)
AsseticBundle with proper {%- javascript %} inclusion
And the rest is contextual.
My READ and RE-Read list
A hidden gem and very helpful blog posts were for me from:
Problematic's blog post series "On a diet"
Matthias Noback
Liip Symfony2 tagged blog posts, but mostly the Table Inheritance topic
and CraftItOnline
For the sake of completeness there is a native way to generate CRUDs:
php app/console doctrine:generate:crud
This command will ask to you some information, like the entity, if you want a write action, the configuration format or the base route prefix.
In my opinion this is the fastest and light way to quickly generate a controller to create, read, update or delete your entities, so it is good on simple projects or to code a basic CRUD inside a little Bundle.
Official documentation: http://symfony.com/doc/master/bundles/SensioGeneratorBundle/commands/generate_doctrine_crud.html

Resources