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

Composer for WordPress Projects

Af561b02ecb57183677c63f62bbc81f2?s=47 Tyrel Kelsey
October 12, 2019

Composer for WordPress Projects

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

Af561b02ecb57183677c63f62bbc81f2?s=128

Tyrel Kelsey

October 12, 2019
Tweet

Transcript

  1. Composer for WordPress Projects WordCamp SLC 2019

  2. Tyrel Kelsey ninnypants

  3. +

  4. wp-content

  5. ~/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 <tyrel@ninnypants.com>, 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
  6. { "name": "ninnypants/cwp", "description": "WordPress + Composer example.", "type": "project",

    "license": "GPL2", "authors": [ { "name": "Tyrel Kelsey", "email": "tyrel@ninnypants.com" } ], "minimum-stability": "stable", "require": {} } Do you confirm generation [yes]? Would you like the vendor directory added to your .gitignore [yes]? yes
  7. Plugins & Themes

  8. wpackagist.org

  9. "repositories":[ { "type":"composer", "url":"https://wpackagist.org" } ],

  10. "require": { "wpackagist-plugin/formidable": ">=4.03", "wpackagist-plugin/wordpress-seo": ">=12.2" },

  11. Installer Paths

  12. <?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}/', ); }
  13. "extra": { "installer-paths": { “plugins/{$name}":[ “type:wordpress-plugin" ], "mu-plugins/{$name}": [ “type:wordpress-muplugin"

    ], "themes/{$name}": [ “type:wordpress-theme" ] } }
  14. None
  15. External Repositories

  16. "repositories":[ { "type":"composer", "url":"https://wpackagist.org" }, { "type": "vcs", "url": "git@github.com:ninnypants/cwp-theme.git",

    "no-api": true } ],
  17. "require": { "wpackagist-plugin/formidable": ">=4.03", "wpackagist-plugin/wordpress-seo": ">=12.2", "ninnypants/cwp-theme": "dev-master" },

  18. None
  19. Premium Plugins

  20. "require": { "wpackagist-plugin/formidable": ">=4.03", "wpackagist-plugin/wordpress-seo": ">=12.2", "ninnypants/cwp-theme": "dev-master", "strategy11/formidable-pro": "4.02.03"

    },
  21. None
  22. { "name": "strategy11/formidable-pro", "type": "wordpress-plugin", "version": "4.02.03", "license": "GPLv3", "description":

    "", "require": { } }
  23. "repositories":[ { "type":"composer", "url":"https://wpackagist.org" }, { "type": "vcs", "url": "git@github.com:ninnypants/cwp-theme.git",

    "no-api": true }, { "type": "artifact", "url": "artifacts/" } ],
  24. "strategy11/formidable-pro": "4.02.03" strategy11-formidable-pro-4.02.03.zip

  25. None
  26. .gitignore

  27. ~/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)
  28. plugins/* !plugins/some-plugin themes/* !themes/some-theme

  29. Scripting

  30. "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." }
  31. Links • https://github.com/ninnypants/composer-for-wordpress • https://github.com/ninnypants/cwp-theme • https://getcomposer.org/ • https://wpackagist.org/

  32. Thanks!