WordPress and Composer

+

Kalen Johnson

Web Developer

  • PHP, Front-end, WordPress
  • Self-employed crazy person

http://kalenjohnson.com
@kalenjohnson

What is Composer?

Dependency Manager

https://getcomposer.org/

https://github.com/composer/composer :

Composer helps you declare, manage and install dependencies of PHP projects, ensuring you have the right stack everywhere.

https://packagist.org

composer.json

The Basics

{
  "require": {
    "monolog/monolog": "1.13.*"
  }
}

Installs to the                   directory

vendor

$ composer install

  • Autoload all installed dependencies
    with                     
vendor/autoload.php
$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev)
  - Installing psr/log (1.0.0)
    Loading from cache

  - Installing monolog/monolog (1.13.1)
    Loading from cache

http://wpackagist.org/

{
  "repositories": [
    {
      "type":"composer",
      "url":"http://wpackagist.org"
    }
  ],
  "require": {
    "monolog/monolog": "1.13.*",
    "wpackagist-plugin/akismet": "3.1.1",
    "wpackagist-plugin/woocommerce": "2.3.*",
    "wpackagist-theme/modern": "1.2.*"
  }
}

composer.json with WordPress

themes and plugins

Installing WP and everything else

{
  "repositories": [
    {
      "type":"composer",
      "url":"http://wpackagist.org"
    }
  ],
  "require": {
    "wpackagist-plugin/akismet": "3.1.1",
    "wpackagist-plugin/woocommerce": "2.3.*",
    "wpackagist-theme/modern": "1.2.*",
    "johnpbloch/wordpress": "4.*"
  },
  "extra": {
    "installer-paths": {
      "content/plugins/{$name}/": ["type:wordpress-plugin"],
      "content/themes/{$name}/": ["type:wordpress-theme"]
    },
    "wordpress-install-dir": "wp"
  }
}

After $ composer install

$ l
.
├── [ 136]  content/
├── [ 170]  vendor/
├── [ 748]  wp/
├── [ 487]  composer.json
└── [8.4K]  composer.lock

Resources

Thank You!

WordPress and Composer

By Kalen Johnson

WordPress and Composer

  • 688
Loading comments...

More from Kalen Johnson