How to embed Symfony2 actions into WordPress? How to embed Symfony2 actions into WordPress? wordpress wordpress

How to embed Symfony2 actions into WordPress?


As you don't want to "..just copy-paste a bunch of WordPress CSS and headers into Symfony views", I suggest you embed the WordPress header and footer to all you Symfony views programmatically.

Also take a look at Silex as this has lower overhead than Symfony and works with Symfony forms.

  1. Install Symfony2, or Silex
  2. Put the WordPress files in your web/ folder
  3. wp-config.php can live one folder up next to composer.json, which is better for security anyway
  4. Move your Symfony, or Silex, front controller/s to a sub-folder, probably named signup/ in your case
  5. Fix the require / include paths at the top of your front controller/s
  6. Add a line at the top of your front controller/s to include wp-load.php from the parent folder - this file fires up WordPress and makes all the WordPress functions available to you - note it has to be included from the global scope not from inside a function
  7. Call the WordPress methods get_header(); and get_footer(); above the and below the Symfony, or Silex, code in your front controller/s. In Silex that's just above and below $app->run();

Your file structure should look like this:

vendor/  |-- Third party libraries web/  |-- WordPress files  |-- signup/       |-- Symfony2 or Silex front controllercomposer.jsonwp-config.php

Inspired by this post.


Symfony 2 permits the usage of parts of the framework without using the whole.

The form is a component that IS detachable, as you can find here:

http://symfony.com/components

sadly ,there is not much documentation yet, therefore you'd have to discover it by yourself...

edit:the same goes along with the routing, etc.if you want to be able to use the symfony routing to recognize paths/things to do , you'd have to include the HttpFoundation component, and obviously the routing.