Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Using Composer with WordPress

1,357 views

Published on

Composer is a command line dependency management tool designed for PHP. Composer can help you:

- Simplify new project creation
- Minimize duplication of code in your project repositories
- Quickly install and update plugins and themes in bulk
- Manage versioning within your project
- Follow best practices when managing code for your projects

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Using Composer with WordPress

  1. 1. Using Composer with WordPress Micah Wood @wpscholar wpscholar.com/wcatl2016
  2. 2. What is ?
  3. 3. Manages Project Dependencies and Versions
  4. 4. Why Use Composer?
  5. 5. Eliminates Duplication
  6. 6. Consistent Versioning
  7. 7. Reusable
 Code
  8. 8. Composer Features
  9. 9. Automatic Package Installation
  10. 10. Bulk Package Updates
  11. 11. Class and File Autoloading
  12. 12. Recursive Dependencies
  13. 13. Package Discovery
  14. 14. Installing Composer
  15. 15. Go to https://getcomposer.org/ Click ‘Getting Started’ Find your install method
  16. 16. $ composer diagnose Check system for common errors
  17. 17. Using Composer
  18. 18. $ composer init Create a new composer.json file
  19. 19. $ composer validate Validate your composer.json file
  20. 20. $ composer require package Adds package to composer.json and installs
  21. 21. $ composer require package --dev Adds package to composer.json as a dev requirement and installs
  22. 22. $ composer install Downloads and installs all dependencies
  23. 23. $ composer install --no-dev Install composer dependencies for production environment
  24. 24. $ composer update Checks for and installs package updates
  25. 25. $ composer update package Checks for and installs a single package update
  26. 26. $ composer remove package Removes package from composer.json and uninstalls
  27. 27. $ composer search package Discover packages on packagist.org
  28. 28. $ composer config repositories.package git git@github.com:username/package.git Add a custom repository
  29. 29. Custom Repositories Require 
 a composer.json File Run composer init to generate
  30. 30. Specifying Versions
  31. 31. Exact Version 1.0.2
  32. 32. Range of Versions >=1.0,<2.0
  33. 33. Wildcard Version 1.0.*
  34. 34. Next Significant Release Version ~1.2
  35. 35. Version Stability Flags
 @stable 
 @rc
 @beta
 @alpha
 @dev
  36. 36. Semantic Versioning semver.org
  37. 37. 2.3.1 Increment when you make breaking changes Major Version
  38. 38. 2.3.1 Increment when you add backwards compatible features Minor Version
  39. 39. 2.3.1 Increment when you make backwards compatible bug fixes Patch Version
  40. 40. How Composer Works
  41. 41. composer.json How you declare your dependencies
  42. 42. composer.lock How Composer stores your dependencies
  43. 43. vendor directory Where composer installs your packages
  44. 44. autoload files require __DIR__ . '/vendor/autoload.php';
  45. 45. Using Composer with WordPress
  46. 46. Use Case #1 Custom Plugin or Theme
  47. 47. Use Case #2 Custom Site or App
  48. 48. $ composer require johnpbloch/wordpress Add WordPress as a dependency
  49. 49. $ composer config repositories.wpackagist composer http://wpackagist.org/ Add wpackagist.org as a repository
  50. 50. $ composer require composer/installers Enables WordPress themes and plugins to be put in their respective directories
  51. 51. Setup WordPress Paths Places WordPress and its themes and plugins in their respective directories
  52. 52. File Structure
  53. 53. Project Bootstrapping
  54. 54. $ composer create-project package Downloads project and runs `composer install`
  55. 55. $ composer create-project wpscholar/wp-skeleton Setup a new WordPress project
  56. 56. $ composer create-project wpscholar/vvv-skeleton Setup a new WordPress project using VVV
  57. 57. Thank You! Micah Wood @wpscholar wpscholar.com/wcatl2016

×