I would like to build a sf2 application and maintain all the content ( categories, articles, pages, media, etc ) in WordPress with internationalization ( wpml plugin ). The app would have it’s own admin and for managing the content the user would log on to the WordPress backend.
My plan is to have a sf2 controller backed up by the routing system and give it the first chance to identify a route and do its thing. If not it should then let WordPress handle the rendering of the page.
I also think that I will need to pull WordPress content in some sf2 pages like the homepage where I may want to put the newest articles alongside sf2 content.
Has anyone ever done this before? Pros and cons? Suggestions on how to implement this?
Thanks!
Have a look at these two projects which are approaching the Symfony-WordPress integration from different angles:
There are some Sf2 bundles that help close the gap a bit, like https://github.com/kayue/KayueWordpressBundle where you can use Symfony2 entities to get WordPress data, authenticate into WordPress, use WordPress functions in Twig, things like that. Maybe you can work with that.
I did this in a recent project and it worked really well.
To make this work, you need to have two seperate databases and two entity managers (one for your sf2 application, one for WordPress) – at least that’s how it worked best for me, having a real sf2 application on one side and using WordPress on the side to handle dynamic pages.
Here is an example of my configuration :
And the KayueWordpressBundle configuration :
Using KayueWordpressBundle, I can now access all elements of my WordPress using the “cms” entity manager. Using WordPress menus, we were able to make our application menu dynamically integrate new pages that were added to them. We were also able to keep the same header and footer on our WordPress using curl, so the whole thing was practically seamless.
On the practical side :
I installed WordPress in a file located in the root directory of my project. This means that I can use Git with it, deploy it using Capifony and things like that.
Note that design, plugins and stuff need to be added/edited on your local environment, then pushed to your Git repository before deploying with Capifony. The dynamic content of your wordpress (pages, articles) however is dependent on your database, so the final content should be written on your production environment only.
First of all, in order to integrate WordPress with Symfony 2, you would have to come up with a “glue” plan, since WordPress doesn’t follow the interoperability standards, followed by Symfony 2 and other frameworks to achieve this level of easy integration.
Second of all, it would be great if you could check out the Symfony CMF, which is basically an implementation of a content management framework that lets you create your own CMS on top of Symfony 2 components.
The third and last point would be that this integration that you are trying to achieve doesn’t make a whole lot of sense. The first part of your requirements, where you need a simple layer on top of WordPress to handle the incoming requests, could be solve with a simple hack on WordPress’ front controller code.