2017 © Pedro Peláez
 

symfony-bundle wordpress-integration-bundle

Integration of WordPress in Symfony2

image

startplatz/wordpress-integration-bundle

Integration of WordPress in Symfony2

  • Thursday, February 9, 2017
  • by ge-o
  • Repository
  • 11 Watchers
  • 5 Stars
  • 2,076 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 2 Open issues
  • 7 Versions
  • 1 % Grown

The README.md

WordPress Integration Bundle

Open-Source Bundle to integrate WordPress in a Symfony2 Project., (*1)

Features: * Using WordPress and Symfony in parallel * Using layout from WordPress as a Twig - Template by annotation * Use Symfony Controller output as WordPress Shortcodes, (*2)

Installation

Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation., (*3)

Applications that use Symfony Flex

Open a command console, enter your project directory and execute:, (*4)

$ composer require wordpress-integration-bundle

Applications that don't use Symfony Flex

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:, (*5)

$ composer require startplatz/wordpress-integration-bundle

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the config/bundles.php file of your project:, (*6)

// config/bundles.php

return [
    // ...
    Startplatz\Bundle\WordpressIntegrationBundle\StartplatzWordpressIntegrationBundle::class => ['all' => true],
];

Manual Steps

enable a route that should be handled by WordPress in your routing configuration (e.g. config/routing.yaml), (*7)

....
wordpress:
    resource: "@StartplatzWordpressIntegrationBundle/Controller/PassthruController.php"
    type: annotation

Note: all your other routes should be configured in advance., (*8)

For Apache 2 User: Take the sample .htaccess file to your document root and adjust it to your needs e.g. Error Handling etc. Note: It is better to prevent WordPress from changing this file!, (*9)

For other HTTP-Server you need to setup the rules based on the Apache rules, (*10)

Setup WordPress

Your WordPress Installation should be located in the public - folder of your Symfony2 - Project, (*11)

To complete the integration you should update the globals - cache by calling the Symfony Console Command:, (*12)

app/console startplatz:wordpress-integration:build-global-names-cache

Configuration

Add file config/startplatz_wordpress_integration.yaml (if it is not done by flex yet), (*13)

startplatz_wordpress_integration:
    wordpress_root_dir: '%kernel.project_dir%/../public'
  • wordpress_root_dir: Directory, where Wordpress is installed - mandatory, no default value

Implementation

Using WordPress output as Twig - Template

Usage in Controller and Twig Template

defining the WordPress URL as template via annotation, (*14)

<?php

namespace Acme\Bundle\WebsiteBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Startplatz\Bundle\WordpressIntegrationBundle\Annotation\WordpressResponse;

class DefaultController extends Controller
{
    /**
     * @Route("/",name="show_index")
     * @WordpressResponse("/url-from-wordpress/", createTwigTemplate=true)
     * @Template
     */
    public function indexAction()
    {
        return array();
    }
}

Your Twig Template should look like:, (*15)

{% extends template_from_string(app.request.get('_wordpressTemplate')) %}

{% block something %}
    Hello world!
{% endblock %}

Note: The twig function template_from_string() is not activated by default. See the documentation http://twig.sensiolabs.org/doc/functions/template_from_string.html for this., (*16)

Define blocks in WordPress

In your WordPress page (or post) you can define as many blocks as you want. The WordPress Integration Bundle translates the wildcards like %%SOMETHING%% to the block definitions {%block something %}{% endblock %}, (*17)

There are some default blocks that are integrated every time:, (*18)

{% block additionalHead %}{% endblock %}
{% block additionalBody %}{% endblock %}
{% block robots %}index,follow{% endblock %}

The Versions

09/02 2017

dev-master

9999999-dev http://github.com/startplatz/wordpress-integration-bundle

Integration of WordPress in Symfony2

  Sources   Download

MIT

The Requires

 

wordpress symfony integration

09/02 2017

1.0.4

1.0.4.0 http://github.com/startplatz/wordpress-integration-bundle

Integration of WordPress in Symfony2

  Sources   Download

MIT

The Requires

 

wordpress symfony integration

17/03 2016

dev-deployment-sys11

dev-deployment-sys11 http://github.com/startplatz/wordpress-integration-bundle

Integration of WordPress in Symfony2

  Sources   Download

MIT

The Requires

 

wordpress symfony integration

17/01 2015

1.0.3

1.0.3.0 http://github.com/startplatz/wordpress-integration-bundle

Integration of WordPress in Symfony2

  Sources   Download

MIT

The Requires

 

wordpress symfony integration

17/01 2015

1.0.2

1.0.2.0 http://github.com/startplatz/wordpress-integration-bundle

Integration of WordPress in Symfony2

  Sources   Download

MIT

The Requires

 

wordpress symfony integration

06/01 2014

1.0.1

1.0.1.0 http://github.com/startplatz/wordpress-integration-bundle

Integration of WordPress in Symfony2

  Sources   Download

MIT

The Requires

 

wordpress symfony integration

18/11 2013

1.0.0

1.0.0.0 http://github.com/startplatz/wordpress-integration-bundle

Integration of WordPress in Symfony2

  Sources   Download

MIT

The Requires

 

wordpress symfony integration