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
Related
I just started with symfony 4 and have a question about "multi-controller", if my application got many routes, should i go for more controllers to keep the files tiny and readable or is one controller enough / recommended?
There is no recommended way about multi-controllers on the official documentation.
If multi-controller is a good choice, how to split?
If there a good documentation on the inet?
Absolutely yes, you should have more than one controller. Symfony's best practices recommend to keep your controllers tiny and delegate much of your application logic to services that you create to handle different actions. For this, it is essential that you have a basic understanding of Dependency Injection, the Container pattern and, more specifically, how Symfony's DI Container works (how you can register services, for example).
There's tons of documentation on Symfony in the intenet. This one on controllers.
KnpUniversity has some really good tutorials to get you started. Start with the Symfony series, then follow with Symfony Internals.
Also, you will greatly benefit from the features of the maker bundle, that will generate code for you really quickly. You can install it with composer require maker. Then, you can create a controller running php bin/console make:controller.
I am new to Symfony and have been watching a lot of tutorials on using this MVC. They all start (at least the ones I've seen) by saying your app should be in it's own bundle. When I start a new project it comes with AppBundle already there. Should I create a new bundle or use this one.
I realise that people to things differently and that symfony.com says that best practice is to use AppBundle but from what I can see the resources folder is outside of AppBundle instead of within the bundle in the case of creating a new one.
I hope I'm not being too cryptic in my question.
Any help would be greatly appreciated.
Symfony2/3 has a great documentation. There is a complete section that handle the topic of bundles.
http://symfony.com/doc/current/cookbook/bundles/best_practices.html
Take a look at the Cookbook there are a lot of great informations. For your question you can create so much Bundles you need. A bundle should be a complete topic of a function for example a "NewsletterBundle" which holds all your functions for a complete Newsletter section. You should find your own way with one eye on the guidelines.
To complete the #Stony's answer, and answer the title of your question, you can perfectly use the AppBundle.
It's a good example to start with Symfony.
It contains a first route that checks your configuration, uses the Request component, access to a config parameter and display a link to the Create your first page with Symfony2 part of Symfony2 book, in a twig template.
I want to migrate a Symfony2 project (v.2.7.1) from Propel1.7 to Propel2 (currently "alpha 5").
I'm using various Propel behaviors and third party bundles which relies on "Propel" adaptators to correctly work. It will be very helpful for me to have your comments for each behavior / bundle to know if it's trivial to migrate or if difficulties (and which!) could happen...
Behaviors:
Archivable
NestedSet
Sluggable
QueryCache
Timestampable
Typehintable (willdurand/propel-typehintable-behavior)
Equalnest (craftyshadow/propel-equalnest-behavior)
Geocodable (willdurand/geocoder-bundle)
Third party bundles:
FOSUserBundle
GlorpenPropelBundle
FOSElasticaBundle
Core behaviors
Theses behaviors are still in Propel2
Archivable
NestedSet
Sluggable
QueryCache
Timestampable
Third-party behaviors
Equalnest
The author does not seem confident in the compatibility like explained in this issue. I'll create a specific issue #969 to know the state of the art for managing an "equal nest" in Propel2.
Geocodable
A PR has been done here, but no news for a long time...
There is now a dedicated repo for Propel2.
Core source
The typehintable is in the core of Propel2, so it smells good
Third-party bundles
FOSUserBundle
Propel2 integration is related to that issue; as the typehintable behavior is now in the Propel core, I suppose we have to change the schema.xml supplied by default by FOSUserBundle for Propel.
GlorpenPropelBundle
It seems not compatible for the moment as explained here, but I suppose it would be better to discuss all the subjects covered in this fantastic bundle in a dedicated issue to know how Propel2 manage these problematics.
FosElasticaBundle
Even for Propel1, this bundle was a little bit hard to use, I suppose we have to work for Propel2.
Full links & discussion on github / https://github.com/propelorm/Propel2/issues/966
Couple of month ago I got a legacy project written on Sf2. I fixed some bugs, and added some new functionality, but still i feel that it was made a little bit clumsy. Well, maybe not just a little :) So, I have a number of questions, how things really should be done in Sf2.
The first thing which is bothering me, is that the Application is separated on Frontend and Backend bundles. The're standing on the same model, and for example entity Book can be seen from FrontendBundle and edited from BackendBundle. In some way this is producing a confusion of abstractions. So my question is - is it right, or wrong, and if wrong how it should be done in appropriate way?
Bundles are components in symfony2 that provides a functionality to your app. The frontend and backend approach has changed in symfony2, the bundles are used instead.
For example, you can create a BookBundle, and put all the functionality regarding to books in that bundle, adding, updating etc. And by configuring the routes, you can redirect all the requests about the book to that bundle.
The main point is, the frontend and the backend about the books resides in same bundle, and only in that bundle(with controllers and entities and repositories and views etc.).
This is the intended usage in symfony2.
I'm new to version 2 of the Symfony framework. I made some projects with v1 but now trying to get my head around the new version and it's features.
I read over the concept of Bundles but it's purpose is not yet very clear to me.
Say you have a big web application, a CRM for example. How would the bundles look like?
Would it be NewsletterBundle (for sending newsletters), ContactManagementBundle (for managing contacts), UserBundle (for editing users and their permissions).
Or would it be less cut-up like, EmailBundle (for handling the entire email traffic), CRMBundle (for putting in all your CRM code), PermissionsBundle, ApiBundle.
I like to think of it like this: a bundle should represent a specific feature or set of like features for a project.
Your first example is a better use of bundles than your second example, because the purpose of each bundle is more defined. While it's possible to use one CRMBundle for everything, you wouldn't really be taking advantage of Symfony's ability to organize your code. Additionally, if you wanted to port over your Newsletter code to a new project, but not all of the CRM code, you'd have an easier time copying over a NewsletterBundle versus copying over the CRMBundle, and then pruning it.
When thinking about a Symfony2 project, sometimes you want to forget everything you know about symfony 1.x, since they take wildly different approaches to solving many problems. For example, in symfony 1 it was common to build a 'frontend' and 'backend' app for a project, and each app would obviously contain logic specific to those parts of the project. So you might have a Newsletter controller in both the frontend and backend apps. In Symfony2, you're better off using only one Newsletter bundle, but with two controllers (perhaps named 'frontend' and 'backend'). Again, an immediate benefit to this is how reusable your code becomes.