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.
- Backing Services
- Build, release, run
- Port binding
- Dev/prod parity
- 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.