What is php composer and what does dependency manager means? -
hello guys i've been stuck around php composer read lot of articles still not clear 100% can please explain main reason why should use composer , dependency ? , mean composer dependency manager ?
thanks in advance.
can please explain main reason why should use composer , dependency
you use install libraries made other people.
example: you're dealing dates in php application. can use date
function , datetime
class comes php. however, need display human-readable date in format of "5 minutes ago" or "in 2 hours" etc.
so developing , realize you're going spend time on feature. it's nice have, takes time it.
a wise developer think "someone had same issue did, let's see how solved it" , stumble upon library: carbon
now want use library because takes care of problem. option download github , add project manually, means placing in directory, including in app etc.
or can use composer , can tell composer want specific version of library. in terminal, type:
composer require "nesbot/carbon: ~1.21"
composer downloads specific version of library, places in vendor/
directory , provides autoloader.
for you, means can:
- install libraries made other developers
- track version of libraries installed , lock down project specific library version
- you autoloader, it's simple add libraries project, don't have manually type
require
orinclude
because needinclude vendor/autoload.php
gain access libraries installed via composer.
since had issues dates, databases, mailing , on - other people had them , of people awesome enough create free code rest of use. composer helps code , manage it.
Comments
Post a Comment