Symfony 2 application with Wordpress as CMS Symfony 2 application with Wordpress as CMS symfony symfony

Symfony 2 application with Wordpress as CMS


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 :

//app/config.ymldoctrine:dbal:    default_connection:   default    connections:        default:            driver:   "%database_driver%"            host:     "%database_host%"            port:     "%database_port%"            dbname:   "%database_name%"            user:     "%database_user%"            password: "%database_password%"            charset:  UTF8        cms:            driver:   "%database_driver_cms%"            host:     "%database_host_cms%"            port:     "%database_port_cms%"            dbname:   "%database_name_cms%"            user:     "%database_user_cms%"            password: "%database_password_cms%"            charset:  UTF8orm:    auto_generate_proxy_classes: %kernel.debug%    default_entity_manager:   default    entity_managers:        default:            connection:       default            mappings:                MyFirstBundle: ~                MySecondBundle: ~ #if you have more than one bundle in your application        cms:            connection:       cms            mappings:                KayueWordpressBundle: ~

And the KayueWordpressBundle configuration :

//app/config.ymlkayue_wordpress:# Site URL must match *EXACTLY* with WordPress's setting. Can be found# on the Settings > General screen, there are field named "WordPress Address"site_url:       %blog_url% #Note : I put the site_url in my parameters.yml to get this working on all my environments (see comment below) # Logged in key and salt. Can be found in the wp-config.php file.logged_in_key:  'samethingasinyourwpconfig'logged_in_salt: 'samethingasinyourwpconfig'# Optional: WordPress cookie path / domain settings.cookie_path:    '/'cookie_domain:  null# Optional: Custom table prefix. Default is "wp_".table_prefix:   'wp_'# Optional: Entity manager configuration to use (cache etc). Default is 'default'.entity_manager: 'cms' #here is where i put the name of my new entity manager defined above

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.