using symfony bundles - symfony

I am new to symfony, so may be it's not a good question...
If any symfony1 plugin works in Symfony2?
How to install new bundle in Symfony2 or where can I learn about it?
Is there any good place to look after bundles?
Is there a bundle for resizing images?

No. Symfony2 is completely different. But some symfony1 modules have been ported to Symfony2.
Usually each bundle provides instructions for setting it up. Take a look at ElnurBlowfishPasswordEncoderBundle for an example.
KnpBundles is the de-facto place for searching bundles.
http://knpbundles.com/search?q=imag

Related

symfony should I create a new bundle or use appbundle

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.

Migration from Propel to Propel2

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

Symfony2 and Frontend & Backend Bundles

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.

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

Do you sort your classes?

I'm developing and intranet application with symfony2. I'm currently using only one fat bundle for all my features. Seem like this is what is recommended and what most symfony2 developpers do.
I wonder how you deal with an growing application where you create entities again and again. Do you just create them in your Entitiy directory inside your bundle? Do you sort them into subdirectories?
The same question can me applied to others classes like the forms.
Any advice on this?
In my opinion, even if best practices say to use a single bundle, for big project this can make you lose time.
In my projects I'm used to create :
- one bundle for statics pages and resources : for example PagesBundle
- one bundle to the member area : UserBundle
- One bundle for the core of the application : ArticlesBundle in the case of a blog, for example.
This serves to separate and save time in the tree Symfony2.
Tell me what you think.
This is a very subjective topic and mostly relies on what you are most comfortable with. The reason why the best practice now proposes just one big bundle is that the bundle approach was mainly for reusability purposes.
Some people even recommend to store entities outside of any bundle in src\YourNamespace\Entity.
Either way: subdirectories are definitely a very valuable option to sort classes.

Resources