PHP Composer Basics

623 views

Published on

Explains basic of Composer (PHP).

1 Comment
1 Like
Statistics
Notes
No Downloads
Views
Total views
623
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
9
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide

PHP Composer Basics

  1. 1. Let Composer Do It Slides' Link: http://j.mp/composersyl
  2. 2. Me? Muhammad Usman Work mostly with PHP Accounting Graduate Live in Kalighat, Sylhet, Bangladesh. http://usman.it
  3. 3. Work for Vegan Cuts http://VeganCuts.com
  4. 4. Working on a SAAS for Vegan Cuts too http://CreateAudience.com
  5. 5. Open Source ( )http://GitHub.com/usmanhalalit
  6. 6. What is Composer? Composer is a dependency manager for PHP. You use many PHP libraries in your project, right? These are your project's dependencies. Bundler is for ruby, npm is for node.js, Composer is for PHP.
  7. 7. Didn't understand? No problem, all do have problems understanding for the first time, including me.
  8. 8. How would I explain Composer to my wife? You're going to cook delicious Biryani. So you need rice, spices, onions, ...? These are dependencies of Biryani. You want me to buy and manage these dependencies for you? So now you can just call these dependencies when needed. Congrats! I am your Composer.
  9. 9. Theory behind package managers Lets not always reinvent the wheel. I depend on you, someone else depends on me and the nesting goes further. We can use bits and pieces.
  10. 10. Enough with theories.
  11. 11. Installation (requires Git mostly) https://getcomposer.org/ *nix curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer Windows Download and run and set up your PATH so that you can just call composer from any directory in your command line. https://getcomposer.org/Composer-Setup.exe
  12. 12. Packagist https://packagist.org/ The store for Biryani materials :D Search for packages/libraries. Select the version you want.
  13. 13. Install a package (go to your project root) composer require monolog/monolog Basic composer.json file Update or install dependencies composer update
  14. 14. The vendor directory
  15. 15. autoload.php require 'vendor/autoload.php'; All library files are loaded*, they can be used now. Performance issues? Nope. *Files are lazy loaded.
  16. 16. You can use autoload for you own classes/files PSR-4 autoload Classmap autoload. Files autoload
  17. 17. Exhausted?
  18. 18. Your questions please! Peace! Slides Link: http://j.mp/composersyl

×