PHPackages                             dreimus/wordpress-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. dreimus/wordpress-bundle

ActiveSymfony-bundle[API Development](/categories/api)

dreimus/wordpress-bundle
========================

Use Wordpress 5 as a backend for a Symfony application

1.4.9(5y ago)00GPL-3.0-or-laterPHPPHP &gt;=5.6.1

Since Dec 22Pushed 5y agoCompare

[ Source](https://github.com/Dreimus/wordpress-bundle)[ Packagist](https://packagist.org/packages/dreimus/wordpress-bundle)[ RSS](/packages/dreimus-wordpress-bundle/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (7)Versions (38)Used By (0)

Wordpress &amp; Symfony, with ♥
===============================

[](#wordpress--symfony-with-)

Introduction
------------

[](#introduction)

Use Wordpress 5 as a backend for a Symfony application

The main idea is to use the power of Symfony for the front / webservices with the ease of Wordpress for the backend.

How does it work ?
------------------

[](#how-does-it-work-)

When the Wordpress bundle is loaded, it loads a small amount of Wordpress Core files to allow usage of Wordpress functions inside Symfony Controllers.

Wordpress is then linked to the bundle via a plugin located in the mu folder.

Because it's a Symfony bundle, there is no theme management in Wordpress and the entire routing is powered by Symfony.

Features
--------

[](#features)

From Composer :

- Install/update Wordpress via composer
- Install/update plugin via composer

From Symfony :

- Template engine
- Folder structure
- Http Cache
- Routing
- Installation via Composer for Wordpress Core and plugins
- YML configuration ( even for Wordpress )
- DotEnv
- Enhanced Security ( Wordpress is hidden )
- Dynamic image resize

From the bundle itself :

- YML configuration for Wordpress (see bellow )
- Permalink settings for custom post type and taxonomy
- ACF data cleaning
- SF Cache invalidation ( Varnish compatible )
- Post/Image/Menu/Term/User/Comment/Query entities
- Download backup ( uploads + bdd ) from the admin
- Maintenance mode
- Multisite images sync ( for multisite as multilangue )
- SVG Support
- Edit posts button in toolbar on custom post type archive page
- Wordpress predefined routes via permastruct
- Context helpers
- Relative urls
- Terms bugfix ( sort )
- Form helpers ( get / validate / send )
- Multisite post deep copy ( with multisite-language-switcher plugin )
- Image filename clean on upload
- Custom datatable support with view and delete actions in admin
- Extensible, entities, controller and bundle plugins can be extended in the app
- Site health checker

Drawbacks
---------

[](#drawbacks)

Because of Wordpress design, functions are available in the global namespace, it's not perfect but Wordpress will surely change this soon.

Some plugins may not work directly, Woocommerce provider needs some rework

Demo
----

[](#demo)

A demo is available at ,

it's an implementation of the Twenty Nineteen theme for Wordpress 5.

Installation
------------

[](#installation)

#### 1 - Start a fresh project

[](#1---start-a-fresh-project)

```
symfony new --full my_project

```

or

```
composer create-project symfony/website-skeleton my_project

```

#### 2 - Prepare composer to work with Wordpress

[](#2---prepare-composer-to-work-with-wordpress)

Edit `composer.json`

Add  repository

```
"repositories": [
    {
        "type":"composer", "url":"https://wpackagist.org"
    }
],

```

Define installation path for Wordpress related packages

```
"extra": {
    ...
    "installer-paths": {
        "public/wp-bundle/mu-plugins/{$name}/": ["type:wordpress-muplugin"],
        "public/wp-bundle/plugins/{$name}/": ["type:wordpress-plugin"],
        "public/edition/": ["type:wordpress-core"]
    }
    ...
}

```

Use optimized autoloader

```
"config": {
    ...
    "optimize-autoloader": true,
    "apcu-autoloader": true,
    ...
}

```

#### 3 - Configure database

[](#3---configure-database)

edit `.env`

```
###> metabolism/wordpress-bundle ###
DATABASE_URL=mysql://user:pwd@host:3306/dbname
TABLE_PREFIX=wp_
###< metabolism/wordpress-bundle ###

```

Only mysql is supported

#### 4 - Require Wordpress Bundle

[](#4---require-wordpress-bundle)

```
composer require metabolism/wordpress-bundle

```

if you want to use the development version (not recommended), edit `composer.json` before

```
"license": "GPL-3.0-or-later",
...
"prefer-stable": true,
"minimum-stability": "dev",
...

```

then

```
composer require metabolism/wordpress-bundle:dev-develop

```

#### 5 - Add Wordpress routing

[](#5---add-wordpress-routing)

edit `routes.yaml`

```
_wordpress:
    resource: "@WordpressBundle/Routing/permastructs.php"

```

Clear cache

```
./bin/console cache:clear

```

#### 6 - Update gitignore

[](#6---update-gitignore)

edit `.gitignore`

```
/public/uploads/*
!/public/uploads/acf-thumbnails
/public/edition
/public/cache
/public/wp-bundle

```

#### 7 - Start the server

[](#7---start-the-server)

Configure a vhost mounted to `/public`, or start the built-in Symfony server

```
./bin/console server:start

```

Accessing the server url will now start the Wordpress Installation,

#### 8 - Develop your website !

[](#8---develop-your-website-)

Take a look at `src/Controller/BlogController.php`, `templates/generic.html.twig` and `config/wordpress.yml` and continue to read the doc bellow.

Wordpress configuration
-----------------------

[](#wordpress-configuration)

When the bundle is installed, a default `wordpress.yml` is copied to `/config/`

This file allow you to manage :

- Keys and Salts
- Image options
- Maintenance support
- Admin pages removal
- WYSIWYG MCE Editor
- Feature Support
- Multi-site configuration
- Constants
- ACF configuration
- Menu
- Custom Post type
- Custom Taxonomy
- Page, post, taxonomy templates
- Page states
- Post format
- External table viewer
- Roles
- Optimisations
- Domain name
- Controller name

Plugin installation
-------------------

[](#plugin-installation)

Please use  to find your plugin.

edit `composer.json`

```
"require": {
    ...
    "wpackagist-plugin/classic-editor":"1.*"
    ...
}

```

ACF Pro installation
--------------------

[](#acf-pro-installation)

Edit `composer.json`

Declare a new repository

```
"repositories": [
  {
    "type": "package",
    "package": {
      "name": "elliotcondon/advanced-custom-fields-pro",
      "version": "5.8.4",
      "type": "wordpress-plugin",
      "dist": {"type": "zip", "url": "https://connect.advancedcustomfields.com/index.php?p=pro&a=download&k={%ACF_PRO_KEY}&t={%version}"},
      "require": {
        "ffraenz/private-composer-installer": "^2.0",
        "composer/installers": "^1.0"
      }
    }
  },
  {
    "type":"composer", "url":"https://wpackagist.org"
  }
]

```

Add ACF

```
"require": {
   "elliotcondon/advanced-custom-fields-pro": "5.*",
   ...
}

```

Edit `.env` to set ACF\_PRO\_KEY

```
ACF_PRO_KEY=Your-Key-Here

```

Context service
---------------

[](#context-service)

The Context service is a Wordpress data wrapper, it allows to query post, term, pagination, breadcrumb, comments and sitemap.

Critical data are added automatically, such as current post or posts for archive, locale, home url, search url, ...

### Usage

[](#usage)

```
public function articleAction(Context $context)
{
    $context->addPosts(['category__and' => [1,3], 'posts_per_page' => 2, 'orderby' => 'title'], 'portraits');
    $context->addSitemap();
    return $this->render( 'page/article.twig', $context->toArray() );
}
```

### Preview

[](#preview)

To preview/debug context, just add `?debug=context` to any url, it will output a json representation of itself.

```
{
  "debug": false,
  "environment": "prod",
  "locale": "fr",
  "language": "fr-FR",
  "languages": [],
  "is_admin": false,
  "home_url": "http://brilliant-wordpress-site.fr/",
  "search_url": "/search",
  "privacy_policy_url": "",
  "maintenance_mode": false,
  "tagline": "Un site utilisant WordPress",
  "posts_per_page": "10",
  "body_class": "fr-FR home page-template-default page page-id-38",
  "page_title": "Home",
  "system": "-- Removed from debug --",
  "menu": [...],
  "post": {
    "excerpt": "",
    "thumbnail": "",
    "link": "/",
    "template": "",
    "ID": 38,
    "comment_status": "closed",
    "menu_order": 0,
    "comment_count": "0",
    "author": "1",
    "date": "15 January 2019",
    "date_gmt": "2019-01-15 11:45:59",
    "content": "",
    "title": "Home",
    "status": "publish",
    "password": "",
    "name": "home",
    "modified": "17 January 2019",
    "modified_gmt": "2019-01-17 14:07:13",
    "parent": 0,
    "type": "page",
    "splashscreen": {
      "text": "La France et le Japon partagent les valeurs ...",
      "partner": {
        "link": "http://www.japon.fr"
      }
    }
  },
  "portraits": [...],
  "sitemap": [...],
  "layout": "default"
}
```

Entities
--------

[](#entities)

### Post

[](#post)

```
//BlogController.php

public function articleAction(Context $context)
{
    $article = $context->addPost(12, 'article');
    return $this->render( 'page/article.twig', $context->toArray() );
}
```

```
{# page/article.twig #}

{{ article.title }}
{% set next_article = article.next() %}
{% if next_article %}
    next
{% endif %}
```

ACF fields are directly available so let say you've added a `copyright` text field :

```
{{ post.title }}
{{ post.copyright }}
```

Available functions :

- next($in\_same\_term = false, $excluded\_terms = '', $taxonomy = 'category')
- prev($in\_same\_term = false, $excluded\_terms = '', $taxonomy = 'category')
- getTerm( $tax='' )
- getTerms( $tax='' )
- getParent()

### Image

[](#image)

Image entity provide a nice on the fly resize function, add width and height to crop-resize, set width or height to 0 to resize

To debug images, just add `?debug=image` to any url, it will replace images with placeholder.

[wp-smartcrop](https://wordpress.org/plugins/wp-smartcrop/) plugin is supported

```
{{ post.title }}

```

Generate picture element ( width, height, media queries ), it use wepb if enabled in PHP

```
data.image.toHTML(664, 443, {'max-width: 1023px':[438,246]})|raw
```

Edit image :

resize / insert / colorize / blur / brightness / gamma / pixelate / greyscale / limitColors / mask / text / rotate See :

```
data.image.edit({resize:[260,224], insert:['/newsletter/dots.png','bottom-right', 10, 10]})
```

Use a placeholder if the image doesn't exists

```

```

### Custom posts

[](#custom-posts)

Custom posts can extend the `Post` entity to add some preprocess or new functions, in the `/src` folder, add an `Entity` folder, then create a new class for the post\_type using Pascal case

```
namespace App\Entity;

use Metabolism\WordpressBundle\Entity\Post;
use Metabolism\WordpressBundle\Entity\Image;

class Guide extends Post
{
	public function __construct($id = null)
	{
		parent::__construct($id);

		if( isset($this->picto) && $this->picto instanceof Image)
			$this->picto = $this->picto->getFileContent();
	}
}
```

### Other entities

[](#other-entities)

Menu, Comment, MenuItem, Product, Term and User can be extended by creating the same file in the `/src/Entity` folder.

Additional routes
-----------------

[](#additional-routes)

### Site health

[](#site-health)

You can check site health using `/_site-health`, url options are:

- output : 1 | json
- full : 0 | 1

### Cache

[](#cache)

You can purge cache using `/_cache/purge`, url or using purge cache button in backoffice

You can completely remove and purge cache using `/_cache/clear`, url

Roadmap
-------

[](#roadmap)

- Create Symfony recipe
- Provide more samples
- Woo-commerce Provider rework
- Global maintenance mode for multi-site
- Unit tests

Why not using Bedrock
---------------------

[](#why-not-using-bedrock)

Because Bedrock "only" provides a folder organisation with composer dependencies management. Btw this Bundle comes from years of Bedrock usage + Timber plugin...

Why not using Ekino Wordpress Bundle
------------------------------------

[](#why-not-using-ekino-wordpress-bundle)

The philosophy is not the same, Ekino use Symfony to manipulate Wordpress database. Plus the last release was in 2015...

Is Wordpress classic theme bad ?
--------------------------------

[](#is-wordpress-classic-theme-bad-)

We don't want to judge anyone, it's more like a code philosophy, once you go Symfony you can't go back.

Plus the security is a requirement for us and Wordpress failed to provide something good because of it's huge usage.

Licence
-------

[](#licence)

GNU AFFERO GPL

Maintainers
-----------

[](#maintainers)

This project is made by Metabolism (  )

Current maintainers:

- Jérôme Barbato -
- Paul Coudeville -

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~17 days

Recently: every ~11 days

Total

37

Last Release

2088d ago

PHP version history (2 changes)1.0.0PHP &gt;=7.1.0

1.4.0PHP &gt;=5.6.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2658244?v=4)[Paul Coudeville](/maintainers/dreimus)[@Dreimus](https://github.com/Dreimus)

---

Top Contributors

[![Dreimus](https://avatars.githubusercontent.com/u/2658244?v=4)](https://github.com/Dreimus "Dreimus (2 commits)")

### Embed Badge

![Health badge](/badges/dreimus-wordpress-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/dreimus-wordpress-bundle/health.svg)](https://phpackages.com/packages/dreimus-wordpress-bundle)
```

###  Alternatives

[bagisto/bagisto

Bagisto Laravel E-Commerce

26.2k161.6k7](/packages/bagisto-bagisto)[aimeos/aimeos-core

Full-featured e-commerce components for high performance online shops

4.5k346.9k48](/packages/aimeos-aimeos-core)[unopim/unopim

UnoPim Laravel PIM

9.4k1.8k](/packages/unopim-unopim)[code16/sharp

Laravel Content Management Framework

78959.5k4](/packages/code16-sharp)[metabolism/wordpress-bundle

Build enterprise solutions with WordPress

775.0k1](/packages/metabolism-wordpress-bundle)[luezoid/laravel-core

A feature rich Laravel package which provides fast &amp; flexible way to quickly build powerful RESTful APIs. Various other features like queries &amp; filters over nested complex relationships between models can be done on the go using this package. Read the docs for more info.

112.1k](/packages/luezoid-laravel-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
