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

Composer for WordPress Projects

Tyrel Kelsey
October 12, 2019

Composer for WordPress Projects

An overview of setting up WordPress projects using Composer and WordPress Packagist.

Tyrel Kelsey

October 12, 2019
Tweet

More Decks by Tyrel Kelsey

Other Decks in Programming

Transcript

  1. +

  2. ~/sites/cwp(master*) » composer init Welcome to the Composer config generator

    This command will guide you through creating your composer.json config. Package name (<vendor>/<name>) [tyrelkelsey/cwp]: ninnypants/cwp Description []: WordPress + Composer example. Author [Tyrel Kelsey <[email protected]>, n to skip]: Minimum Stability []: stable Package Type (e.g. library, project, metapackage, composer-plugin) []: project License []: GPL2 Define your dependencies. Would you like to define your dependencies (require) interactively [yes]? no Would you like to define your dev dependencies (require-dev) interactively [yes]? no
  3. { "name": "ninnypants/cwp", "description": "WordPress + Composer example.", "type": "project",

    "license": "GPL2", "authors": [ { "name": "Tyrel Kelsey", "email": "[email protected]" } ], "minimum-stability": "stable", "require": {} } Do you confirm generation [yes]? Would you like the vendor directory added to your .gitignore [yes]? yes
  4. <?php namespace Composer\Installers; class WordPressInstaller extends BaseInstaller { protected $locations

    = array( 'plugin' => 'wp-content/plugins/{$name}/', 'theme' => 'wp-content/themes/{$name}/', 'muplugin' => 'wp-content/mu-plugins/{$name}/', 'dropin' => 'wp-content/{$name}/', ); }
  5. ~/sites/cwp(master*) » git status On branch master Untracked files: (use

    "git add <file>..." to include in what will be committed) plugins/formidable-pro/ plugins/formidable/ plugins/wordpress-seo/ themes/cwp-theme/ nothing added to commit but untracked files present (use "git add" to track)
  6. "scripts": { "start": [ "@composer install", "cd mu-plugins && npm

    install && bower install && grunt", "cd themes/cwp-theme && npm install && grunt" ], "deploy": [ "@composer install --no-dev --optimize-autoloader", "cd mu-plugins && npm install && bower install && grunt", "cd themes/cwp-theme && npm install && grunt" ] }, "scripts-descriptions": { "start": "Initializes repo for development.", "deploy": "Prepares the repo for deployment. Installs with --no-dev and optimizes output etc." }