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.

Josh Pollock #wcatl using composer to increase your word press development powers


Published on

Composer, the PHP dependency manager, is a simple tool that can make it easier for you to reuse your code across projects, speed up your plugin, theme and site development, use other people’s code more efficiently and can even improve your site deployments. In this talk you will learn how to add Composer to your projects, publish Composer libraries, use other developer’s open source Composer libraries, improve your site deployments and otherwise make your life easier.

More information:

Presentation given at WordCamp Atlanta 2015:

Published in: Internet
  • Be the first to comment

  • Be the first to like this

Josh Pollock #wcatl using composer to increase your word press development powers

  1. 1. Using Composer To Improve Your WordPress Development Powers Josh Pollock -- @Josh412 -- JoshPress. net
  2. 2. // “" 4:. ‘ CALDERA W0rdPre55 PIUSIVIS &Tral“l“g Ho| oTree: Team Decision Making JOSHPRESS. NET WordPress Development Framework I DO ALL THE WORDPRESS THINGS
  3. 3. II On lV”l1a_-f: lo <7i<: » mp »: ::<: -.: r 4 II Composer is the PHP dependency management system. http: //GetComposer. org
  4. 4. What is this "Dependency Management" you speak of?
  5. 5. AKA a "Package Manager"
  6. 6. F i1i3.4<aim: §r M4‘: ';l. 'l. Installing Code Updating Code Removing Code Deploying Code ( _, s F 4'. ‘ “FR ;4 1}} lzsl. / "ad / . . uhzni
  7. 7. Why Should You Care?
  8. 8. Staying DRY
  9. 9. The Don't Repeat Yourself Principle Write code once, and reuse it right. Or don't write it at all -- use someone else's : ) A Most Sacred Principle of Programing
  10. 10. No New Copy Pasta!
  11. 11. Reuse Your Code The Right Way Reuse your code, and update it once to update it every where. Be Smart About Your Reuse
  12. 12. < Vi‘: l1ier 9 j4Ioi‘: <:-. :i11f: Node Package Manager (NPM) Bower PEAR ‘ APT-G ET GIT submodules (sort of) * WordPress Plugin and Theme admin
  13. 13. (_ (_ I I TI] r < : i<: » rm: <: » oer‘? lri W<: » i”oTF Improving Deployments Plugin, Theme & Site Development: o Share common code between: 5 Plugins 5 Themes 0 Use other people's code and keep it up to date
  14. 14. Version Control Systems (VCS) vs Dependency Management Or Can't I Just Use A Git Repo?
  15. 15. You Should Use Both I!
  16. 16. What To Use A VCS For? lsityourcode? Is it unique to this project? Then It Belongs To The Project's VCS Repo I
  17. 17. Everything That Isn't Unique If it's not unique to a project or could be reused, then manage it with a dependency manager. So Basically Almost All The Things
  18. 18. Don't Forget Composer checks packages out as VCS (git/ svn/ etc) reposl Make A Change? Commit & Push I
  19. 19. composer. json
  20. 20. Meta Info "name" : "pods-framework/ pods-gravity-forms", "description" : "Pods Gravity Forms Add-On", "type" : "wordpress-plugin", "keywords" : [ "pods", "wordpress", "gravityforms", "gravity-forms" L "homepage" : "https: //github. com/ pods-framework/ pods-gravity-forms", "license" : "GPL-2.0+"
  21. 21. "authors" I I "name" : "Pods Framework Teamfi "email" : "contact@pods. io2 "homepage" : "http: //pods. io/ " "name" : "Scott Kingsley Clarkfi "email" : "scott@pods. io2 "homepage" : "http: //scottkclark. com/ D "role" : "Lead Developer" "name" : "Naomi C. Bush 1 gravity+3 "email" : "naomi@gravityplus. pro5 "homepage" : "https: //gravityplus. prW
  22. 22. Links "support" : I "issues" : "https: //github. Com/ pods-framework/ pods-gravity-forms/ issues' "source" : "https: //github. Com/ pods-framework/ pods-gravity-forms"
  23. 23. Requirements "require" : I "composer/ installers‘: "~l. O", uphpu Z u>_5. 3:-
  24. 24. J J_ f_ V‘ , L <11 . .~ I~4.-«: ..I r‘ " (3. i"*‘ J ‘:1-v mg I v Can be hosted on a Packagist server 0 Packagist. org o WPackagist. org r Or use any Git, SVN or other VCS repo with a valid composer. json
  25. 25. Packagist "require" : I "johnpbloch/ wordpress" "wpackagist-plugin/ pods" : "calderawp/ edd-licensing" : in ‘f u4.1u, nan: r nan:
  26. 26. Peitj U i PC-.2 m e into From Version Control "repositories": [ I "type": "gitfl "url": "https: //qithub. com/ pods-framework/ pods—json—ap" I I, "require" : I "pods-framework/ pods-json-api‘: "*" I
  27. 27. Example One: Full Site Development
  28. 28. Full Site Development Example Phflosophy: Git repo tracks: a Theme or Child Theme o wp-config, etc o mu-plugins
  29. 29. More Full Site Examples a Bed rock 0 https: //roots. io/ bedrock/ 0 Very Complete System 0 My Grunt Site Generator 0 https: //github. com/ Shelob9/wp—vvv—start—with— grunt 0 Use grunt-init to create Composer-manages sites.
  30. 30. Example Two: A Very Word Press Composer Package
  31. 31. Example WordPress Package Reusable soft-expiring transient library.
  32. 32. M: re mp loo Case Study On TLC Transients: v http: //composer. rarst. net/ case-study/ t|c- transients Fragment Cache v https: //github. com/ Rarst/ fragment-cache
  33. 33. Example Three: Creating A Plugin Out Of Composer Libraries
  34. 34. Plugin Development Example Example plugin uses a non- WordPress specific library and several packages built for this. Those packages can now be reused.
  35. 35. The Composer Autoloader Three Ways To Use It: 0 PSR-4 o PSR-O o Class Map / File Map
  36. 36. PSR-4 Autoloader Will autoload all classes in directory "src" using "hats" namepsace. The Best Way. .. If PHP 5.2 Doesn't Bother You
  37. 37. PSR-O Without A Namespace "autoload": I "psr-O": I uSlug7AdminH. nu, "Slug_Other_Stuff": "lib/ " You Could Use A Namespace, But Why?
  38. 38. Classmap & Filemap "autoload" : I "Classmap": ["class—l: lc~l: ransienl: .php", "class—I: lc~l: ransienI: —updal: e—server. php''] 7 "files" : ["funcI: ions. php"] Specify a class and file by name to autoload. Filemap is the solution for files containing non-OOP code.
  39. 39. v, Q‘ ‘I *I M I” ” I, l-err7~ < J‘
  40. 40. THAN KS! JoshJoshPress. net @Josh412