PHP Composer Basics


Published on

Explains basic of Composer (PHP).

1 Comment
1 Like
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

PHP Composer Basics

  1. 1. Let Composer Do It Slides' Link:
  2. 2. Me? Muhammad Usman Work mostly with PHP Accounting Graduate Live in Kalighat, Sylhet, Bangladesh.
  3. 3. Work for Vegan Cuts
  4. 4. Working on a SAAS for Vegan Cuts too
  5. 5. Open Source ( )
  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) *nix curl -sS | 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.
  12. 12. Packagist 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: