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.

Composer Tips/Tricks

77 views

Published on

Lets get together to learn some tips and tricks about composer. We will start with a brief explanation of why composer and move into how to composer. Then finally discuss some composer tricks that most developers dont use on the daily, but none the less are very powerful.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Composer Tips/Tricks

  1. 1. 1 Composer Tips/Tricks June 23rd, 2017
  2. 2. 2 Chris Haynes chris.haynes@icfolson.com @haynescw drupal.org/u/haynescw github.com/haynescw
  3. 3. What 3 is Composer?
  4. 4. What Dependency/package management software. 4 is Composer?
  5. 5. Why use composer? Generically Has become the standard in PHP. Smaller repository size. Easier to update you packages. Less overhead on a project. With Drupal Installing Drupal Better module management Use non-Drupal libraries 5
  6. 6. Proper vs Improper 6
  7. 7. Improper! Don’t manually alter you composer.json unless you know what you are doing. 7
  8. 8. Improper! Do not try to update the entire project at once with composer update. 8
  9. 9. Improper! Don’t update when your not supposed to! 9
  10. 10. Dry Runs (trick #1) Use the --dryrun flag when updating a package. 10
  11. 11. Proper (tip #1) When merging code into you feature branch, if you see a change to the composer.lock, don’t forget to install those changes. 11
  12. 12. Performance(trick #2) When running composer for prod artifact, use the -- prefer-dist flag. 12
  13. 13. Sorting your packages (trick #3) "config": { "sort-packages": true } 13
  14. 14. Prestissimo (trick #4) http://bit.ly/2s0Ae0I Use a parallel install plugin to increase performance. 14
  15. 15. Finding info on installed packages (tip #2) composer show Combine your composer cli with Nix commands (trick #5) composer show |grep {package} 15
  16. 16. Why? (tip #3) composer why {package} 16
  17. 17. Forking a package to update it (trick #6) http://bit.ly/2sun0wI Fork the repo, make your changes, add you repository to your composer.json, then change the package version and preface it with “dev-” 17
  18. 18. Understand version constraints (tip #4) http://bit.ly/2suL3LG 18
  19. 19. Teach your composer how to script tasks (trick #7) "scripts": { "nuke": [ "rm -rf vendor composer.lock", "@composer clearcache", "@composer install" ] } Documentation: http://bit.ly/2suI3yZ 19
  20. 20. Lock file not a match (tip #5) composer update --lock 20
  21. 21. Validate before you commit. (pro tip #lost count) composer validate --no-check-all –ansi 21
  22. 22. Don’t forget dependencies composer update drupal/core --with-dependencies 22
  23. 23. Keep Composer Up to Date composer self-update 23
  24. 24. Patching composer require cweagans/composer-patches 24 "extra": { "enable-patching": true, "patches-file": "composer.patches.json” }
  25. 25. Know your commands (tip #3) http://bit.ly/2s0PV80 25
  26. 26. Any Questions? Don’t forget to sprint @ICFOlson across from Target Field in the Ford Center 26

×