advance admin generator symfony2 - symfony

At the company where I'm working we want to create a complex admin for a new project. We have the following requirements:
Should restrict the list of objects an user has access.
Have a log of changes to the entities.
Permisions based on role of user and group he belongs (think for goup as organization). The user can manage entities that are created by users of the same organization. When a entity is created, a owner is assigned.
RESTfull
We considered SonataAdmin, EasyAdmin or creating an admin with SyliusResourceBundle and SyliusGridBundle.
The questions for SonataAdmin and EesyAdmin are if it is easy to manage permissions based on roles and the organization the user belongs to. Also, we are not sure if it will be complex to made it able to make it RESTfull.
Our questions regarding to SyliusResourceBundle and SyliusGridBundle are if it is too complex to create an admin generator with this two components. On the other hand we think it is more flexible on configuring to use custom managers (to envolve the repositories) in SyliusResourceBundle then SonataAdmin and EasyAdmin. Is that true?
What do you thing of this options? Are there other options?

I can only answer the first of your questions. Will be not easy to implement this future on EasyAdmin and as it's owner say to me:
"If this feature is essential to your backend, I recommend you to use
SonataAdminBundle instead"
This are some post when you can find some clues about how to do it here, here and here. You can see the intention of it's owner to develop this feature in the near future,but not ready yet, so Sonata still remain as the best option. The problem with sonata is that still isn't fully compatible with symfony3 in an stable version, so it's only recommended with symfony 2.7.
Hope this information help you.

Related

symfony configuration parameter storage entity

In a symfony project, I'm looking the best way to storage some configuration parameter such as the application is online, offline or accesible.
I need to change this value constantly from the web interface with my role ADMIN, so I could put the application offline during maintenance period, but for the ADMIN role the application will be available (not for other users). In each redirect, I ask for this configuration (this is already agreed).
I thougth create an entity with this configuration param, but this table will have no more than one row, so I'm asking me if this is the best way. Is there any other way to storage this param in Symfony?
Thanks a lot.
Having a "settings" table for this sort of things is a common solution. You can manage them easily with SettingsBundle.
Alternatively you could use Symfony Cache to store it: https://stackoverflow.com/a/43785356/1637446

Symfony2 sharing entities in multiple bundles

In my project I have API Bundle and Dashboard Bundle where I reuse Entities like Client, User, Store etc in both bundles. All entities are in API Bundle at the moment, however I have a feeling that they should be stored in a different Bundle, something like Generic Bundle.
Does anyone has a Best Practice for that?
I read this question about relationships, but it speaks about relationships and not Best Practice.
Thanks.
I don't think there is really one best practice here but the key is re-usability. Let's say down the road for some reason you decide to run the API & Dashboard as 2 separate services. Having a UserBundle with your Client & User Entities means you'll just need to install that on both services along with either the API or Dashboard bundle. You could then also have a service with only your UserBundle that handles the login, ect... Same thing for the Store, I would personally decouple that as much as I could.
But the real question is if it is necessary ? Would you reuse that UserBundle in another project ? Do you plan on splitting the project as services down the road ?
Ultimately the specifics are really up to you, a GenericBundle could be all you need or you might have enough to separate into UserBundle & StoreBundle for example.

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 FOSUserBundle Role entities

I'm currently trying to figure out the best way to implement doctrine persisted Role entities as a M2M relationship compatible with FOSUserBundle. Previously I was using just strings with the default implementation and was persisting it with a doctrine array mapping.
Now I need to have roles as seperate entites as we want to build an admin backend where others can grant users roles.
Basically, it's a pain in the ass. The FOS interfaces are built for string representations, not Role entities. Change the implementation, you break a lot of stuff i.e. FOS commands to promote users. And it's hard to figure out exactly which pieces of the interfaces are needed to allow the symfony2 security system to continue working correctly.
I could rewrite the role management code and use Role entities as much as possible, e.g.:
$user->addRole(new Role('ROLE_FOO'));
But that breaks commands and possibly existing code?
Or continue using:
$user->addRole('ROLE_FOO');
And couple role/entity manager code in addRole() (bad design).
I've noticed this is a grey area (Role entities with FOS) and has been mentioned on the symfony2 boards and round here, but no decent solutions.
Anyone had any experience or can think of a decent solution?
I decided to go with a mix of an array/ArrayCollection implementation. I tried to follow the existing interfaces as much as possible so as not to break the security system. I have documented my solution at http://blog.jmoz.co.uk/symfony2-fosuserbundle-role-entities

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