Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Using Composer to Manage WordPress

Using Composer to Manage WordPress

Talk given at Manchester WordCamp October ’15

Tom de Bruin

October 10, 2015
Tweet

More Decks by Tom de Bruin

Other Decks in Programming

Transcript

  1. “Composer is a tool for dependency management in PHP. It

    allows you to declare the libraries your project depends on and it will manage (install/update) them for you.” https://getcomposer.org/ https://packagist.org/
  2. composer.json and composer.lock and composer install and composer update •

    composer install • installs everything if .lock file doesn’t exist, writes .lock file. • subsequently, brings everything up to date with what’s in the .lock file. • composer update • brings everything in your .json up to date, and updates the .lock file. • Always run composer install on the server. • Composer sees that .json and .lock match, installs everything. • This can be confusing. Read all about it on http://daylerees.com/ composer-primer/ and https://adamcod.es/2013/03/07/composer- install-vs-composer-update.html
  3. WP’s file structure You can’t put your plugins in the

    vendor folder. https://codex.wordpress.org/Editing_wp-config.php#Moving_wp-content_folder
  4. https://codex.wordpress.org/Editing_wp-config.php#Moving_wp-content_folder ‛ Change the location, and name, of wp-config with

    a setting in your wp-config.php file. define('WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/app'); define('WP_CONTENT_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/app');
  5. Composer has many powers • require-dev • Register other repos

    (e.g. GitHub, BitBucket, …) • Post install scripts • And many more…
  6. Deployment At deployment you run composer install on the server.

    http://stackoverflow.com/questions/21721495/how-to-deploy-correctly-when-using-composers-develop-production-switch
  7. Questions? Tom de Bruin @deadlyhifi Read this…
 https://roots.io/using-composer-with-wordpress/ http://composer.rarst.net/ http://www.smashingmagazine.com/2014/03/better-dependency-

    management-team-based-wordpress-projects-composer/ Use this… https://roots.io/bedrock/ https://github.com/deadlyhifi/wp-gate8