PHP Composer Basics
-
Upload
muhammad-usman -
Category
Software
-
view
115 -
download
0
description
Transcript of PHP Composer Basics
Let ComposerDo It
Slides' Link: http://j.mp/composersyl
Me?Muhammad Usman
Work mostly with PHP Accounting Graduate Live in Kalighat, Sylhet, Bangladesh.
http://usman.it
Work for Vegan Cutshttp://VeganCuts.com
Working on a SAAS for Vegan Cuts too
http://CreateAudience.com
Open Source ( )http://GitHub.com/usmanhalalit
What is Composer?
ComposerisadependencymanagerforPHP.
YouusemanyPHPlibrariesinyourproject,right?
Theseareyourproject'sdependencies.
Bundlerisforruby,npmisfornode.js,ComposerisforPHP.
Didn't understand?Noproblem,alldohaveproblemsunderstandingforthefirst
time,includingme.
How would I explain Composerto my wife?
You'regoingtocookdeliciousBiryani.Soyouneedrice,spices,onions,...?ThesearedependenciesofBiryani.Youwantmetobuyandmanagethesedependenciesforyou?Sonowyoucanjustcallthesedependencieswhenneeded.Congrats!IamyourComposer.
Theory behind packagemanagers
Letsnotalwaysreinventthewheel.Idependonyou,someoneelsedependsonmeandthenestinggoesfurther.Wecanusebitsandpieces.
Enough with theories.
Installation (requires Git mostly)
https://getcomposer.org/
*nixcurl-sShttps://getcomposer.org/installer|phpmvcomposer.phar/usr/local/bin/composer
WindowsDownloadandrun andsetupyourPATHsothat
youcanjustcallcomposerfromanydirectoryinyourcommandline.
https://getcomposer.org/Composer-Setup.exe
Packagisthttps://packagist.org/
ThestoreforBiryanimaterials:D
Searchforpackages/libraries.
Selecttheversionyouwant.
Install a package (go to your project root)
composerrequiremonolog/monolog
Basiccomposer.jsonfile
Updateorinstalldependenciescomposerupdate
The vendor directory
autoload.phprequire'vendor/autoload.php';
Alllibraryfilesareloaded*,theycanbeusednow.
Performance issues? Nope.*Filesarelazyloaded.
You can use autoload for youown classes/files
PSR-4autoloadClassmapautoload.Filesautoload
Exhausted?
Your questions please!
Peace!
Slides Link: http://j.mp/composersyl