Skip to content
Marketing Factory Digital GmbH
Contact
Logo Marketing Factory Digital GmbH
  • Agency
    • About us
    • History
  • Services
    • Consulting, Analysis and Strategy
    • Programming and Development
      • Interface Development
      • PIM/ERP Links
      • Custom Development
      • Seamless CMS Integration
    • Hosting and Support
      • Cloud Strategies
      • Hosting Partners of Marketing Factory
    • Services with Third Parties
  • Technology
    • TYPO3
      • Current TYPO3 Versions
    • Shopware
    • IT Security
      • DDoS Protection
      • Continuous Upgrading
      • Privacy First
    • Tech Stack
      • Commitment to Open Source
      • Technology Selection
      • PHP Ecosystem
      • Containerisation & Clustering
      • Content Delivery Networks
      • Search Technologies
  • References
    • Projects
    • Clients
      • Client List
    • Screenshot of the homepage of the new Maxion Wheels websiteNEW: Relaunch of the corporate website of Maxion Wheels
  • Community
    • Community Initiatives
  • Blog
  • Contact
  • Deutsch
  • English

You are here:

  1. Blog
  2. Setting up WordPress with Composer - Or: how to teach a budgie to talk
Budgie
  • Development
  • WordPress
09.04.2019

Setting up WordPress with Composer - Or: how to teach a budgie to talk


Who does not know this situation: There is once again a WordPress (security) update and magically after the update, the Akismet plugin, as well as two not at all needed or used themes were installed.

Since by default WordPress comes only as a complete package with just this plugin and at least the current theme, the subsequent deactivation / uninstallation of the unneeded aspects was just the bullet we have bitten. Furthermore, for our WordPress updates many manual steps were still necessary, but we have gradually automated more and more to reduce the complexity of the supposedly easy task "perform WordPress update".

Now, as an established TYPO3 agency, we have been consistently using Composer at least since the introduction of TYPO3 version 8.7 LTS and have since enjoyed the advantages. So why not also try to set up WordPress with Composer? We thought so too. No sooner said than done.

First of all: Yes, it works and even more than satisfactorily.

How exactly we proceeded, you will now learn in the following post. If you prefer to start with a "basic" configuration, you can have a look at the repository here. There I have set up an example repository with which you can start directly.

Step 1: set up composer.json initally

Let's go - Step 1: Back to the beginning and we rebuild our blog again technically from scratch with Composer. The biggest hurdle was to pull the WordPress core only selectively with certain components. We got inspired by this page here (https://roots.io/bedrock/) and quickly found out that this is exactly what we are looking for. In the composer.json you must then pay attention to the following information regarding the storage locations:

  • Cores (wordpress-install-dir)
  • Plugins (type:wordpress-plugin)
  • Custom Themes (type:wordpress-theme)
  • Languages (vendor:koodimonni-language)

Because we wanted to additionally set up the configuration of our blog depending on the environment, we controlled this via the application.php file. This gives us the possibility for each environment to pull the access data for the database and the root path of the WordPress instance. Please note that you need to adjust the root path here accordingly, depending on which path you choose in the composer.json (wordpress-install-dir). Now create a customized wp-config.php and you are ready to go. (A .htaccess file should not be forgotten by the way 😉)

Step 2: Use wpcli for plugins

The translations of the core can then also be integrated with the koodimonni-language repository using Composer. Thus, we now have the complete core - and right in our desired target language. What is still missing is a language update of the plugins. This is where wpcli comes into play. With the help of "wpcli/language-command" and "wpcli/extension-command" we can now execute the following commands (replace _WPCLI_ with your path to wpcli):

This command activates all installed plugins:

  _WPCLI_  plugin activate --all --path=_YOUR_WEB_PATH_ --debug=boostrap

Installs all language files for all active plugins for the language de_DE ("_YOUR_WEB_PATH_" should be replaced by the path to the installation):

  _WPCLI_ language plugin install de_DE --all --path=_YOUR_WEB_PATH_

Updates all language files for all plugins:

  _WPCLI_  language plugin update --all --path=_YOUR_WEB_PATH_

Step 3: Integrate a custom (child) theme

A custom (child) theme can now be added in step 3 via composer.json. If you only want to adapt a standard theme, you should set a requirement for the standard theme in your child theme in composer.json. Again, do not forget the package for the translation of the theme as a dependency 😉. Now you can start!

Et voilá: You have set up your WordPress with Composer!

I hope that everything was understandable so far. We are always happy to receive praise, criticism or suggestions as well as experiences/reports on how you got along with our instructions.

By the way, I already gave a presentation on this topic at WordCamp Cologne 2018, which you can watch here. I have included updates in the article here. You can find the example repository at: https://github.com/sfsmfc/wp_composer_starter. And now go ahead and good luck with your own WordPress project.

Simon Schmidt
Get blog posts as RSS feed

Related blog posts

  • Relaunch of the website of our client Maxion Wheels based on TYPO3 12.4 LTS
  • What is the right alt text for which images?
  • Efficient review environments: Why we replaced Kubernetes with Virtual Machines
  • User-friendly customization of the TYPO3 backend

Please feel free to share this article.


Comments

No comments yet.

Write a comment.

I have been informed that the processing of my data is on a voluntary basis and that I can refuse my consent without detrimental consequences for me or withdraw my consent at any time to Marketing Factory Digital GmbH by mail (Marienstraße 14, D-40212 Düsseldorf) or e-mail (info@marketing-factory.de).

I understand that the above data will be stored for as long as I wish to be contacted by Marketing Factory. After my revocation my data will be deleted. Further storage may take place in individual cases if this is required by law.

  • Data privacy policy
  • Legal notice

© Marketing Factory Digital GmbH

Picture Credits
  1. "Budgie": Dalton Touchberry / License: Unsplash License