Skip to content
  1. Blog

Twelve-Factor WordPress App #2: Dependencies

Scott Walkinshaw Scott Walkinshaw on

Factor #2: Dependencies

Explicitly declare and isolate dependencies

With Codebase out of the way, we’re already getting into unknown territory for WordPress.

Most programming languages offer a packaging system for distributing support libraries, such as CPAN for Perl or Rubygems for Ruby.

The packaging/dependency system for PHP is Composer.

A twelve-factor app never relies on implicit existence of system-wide packages. It declares all dependencies, completely and exactly, via a dependency declaration manifest.

In the world of Composer, the dependency declaration manifest is a composer.json file in the root of your project. At its core it’s just a JSON file that lists out all your dependencies and their versions. WordPress Plugins are also dependencies but by default there’s no explicit declaration of them. The solution to this is to manage your plugins via Composer. This means the plugins are also Composer packages.

One benefit of explicit dependency declaration is that it simplifies setup for developers new to the app. The new developer can check out the app’s codebase onto their development machine, requiring only the language runtime and dependency manager installed as prerequisites.

Once again in the world of Composer, this means that after a developer has checked out/cloned your codebase, they only need to run composer install. This simplifies developer on boarding time and makes for faster collaboration.

In Practice

Using Composer, especially with WordPress, is a massive topic on its own. Thankfully I’ve already addressed this in a blog post and screencast.

Turning a WordPress site into a Twelve-Factor App

  1. Codebase
  2. Dependencies
  3. Config
  4. Backing Services
  5. Build, release, run
  6. Processes
  7. Port binding
  8. Concurrency
  9. Disposability
  10. Dev/prod parity
  11. Logs
  12. Admin processes

Want to turn your WordPress site into a Twelve-factor App? Bedrock is a modern WordPress stack to help you get started with the best tools and practices.

About the author

Scott Walkinshaw

Scott Walkinshaw is a full-stack web developer who's trying to drag WordPress into 2024 and help people modernize their development workflow. He lives in Toronto and likes sports almost as much as coding.

Subscribe for updates

Join over 8,000 subscribers on our newsletter to get the latest Roots updates and tips on building better WordPress sites

Looking for WordPress plugin recommendations, the newest modern WordPress projects, and general web development tips and articles?