Tags

, , , , ,

Composer is a tool. As a PHP developer you need to depend on many project’s application logic. You need to use their classes and sometimes you need to use them directly into your code repositories. Composer will allow you to declare those libraries on which your project may depend upon. Not only that, it also makes your life comfortable with all those updates and additions that often take place into the world of open source world. Composer will automatically install and update those libraries for your project.

1.2 – How Does Composer Look Like?

It is a dependency manager.
Installing Composer in your project locally is quite easy. Just run this command in LINUX/UNIX/OSX like this:
curl -sS https://getcomposer.org/installer | php
Or you can download it and transfer it to your bin folder so that you can use it globally.
Just issue this command:
Composer install
It will start downloading the dependencies. Every package is therefore installed along with it. In that Composer folder you will find a file called ‘autoload.namespaces.php’. The code inside looks like this:
//code starting

// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'phpDocumentor' => array($vendorDir . '/phpdocumentor/reflectiondocblock/src'), 'jtreminio\\TestExtensions' => array($vendorDir . '/jtreminio/testextensions/src'),
'Twitter' => array($baseDir . '/src'),
'Twit' => array($baseDir . '/src'),
'Symfony\\Component\\VarDumper\\' => array($vendorDir . '/symfony/vardumper'),
'Symfony\\Component\\Validator' => array($vendorDir . '/symfony/validator'),
'Symfony\\Component\\Translation\\' => array($vendorDir . '/symfony/translation'),
'Symfony\\Component\\Security\\Core\\' => array($vendorDir . '/symfony/securitycore'),
'Symfony\\Component\\Routing\\' => array($vendorDir . '/symfony/routing'),
'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'),
'Symfony\\Component\\HttpKernel\\' => array($vendorDir . '/symfony/httpkernel'),
'Symfony\\Component\\HttpFoundation\\' => array($vendorDir . '/symfony/httpfoundation'),
'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'),
'Symfony\\Component\\Debug\\' => array($vendorDir . '/symfony/debug'),
'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'),
'Sanjib' => array($baseDir . '/src'), 'Psy\\' => array($vendorDir .
'/psy/psysh/src'),
'Prophecy\\' => array($vendorDir . '/phpspec/prophecy/src'),
'JakubOnderka\\PhpConsoleHighlighter' => array($vendorDir . '/jakubonderka/phpconsole highlighter/src'),
'JakubOnderka\\PhpConsoleColor' => array($vendorDir . '/jakubonderka/phpconsolecolor/src'),
'Hagudu' => array($baseDir . '/src'),
'Guzzle\\Tests' => array($vendorDir . '/guzzle/guzzle/tests'),
'Guzzle' => array($vendorDir . '/guzzle/guzzle/src'),
'Geocoder' => array($vendorDir . '/willdurand/geocoder/src'),
'Dotenv' => array($vendorDir . '/vlucas/phpdotenv/src'),
'Doctrine\\DBAL' => array($vendorDir . '/doctrine/dbal/lib'),
'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib'),
'Doctrine\\Common' => array($vendorDir . '/doctrine/common/lib'),
'Cron' => array($vendorDir . '/mtdowling/cron-expression/src'),
'Connection' => array($baseDir . '/src'),
'Carbon' => array($vendorDir . '/nesbot/carbon/src'),
);

//code ended
Don’t get scared. They are packages. Most of them were downloaded when you installed Composer. Packages mean classes that contain properties and methods written in PHP. You can write any meaningful class of codes and include her along with other packages later. The advantage of this package is, you can call them anywhere inside your Laravel project and use in building an awesome application.
If you are absolute beginner I will advise you to learn more about PHP Namespace, Trait and JSON. For a quick recapitulation I have decided to inject some basic concepts inside our Composer learning curve. But if you want to go the ‘Laravel installation and starting’ you can skip this part presently. Later you can come back and see how these concepts are used in Laravel.

Since you here…

I’m a professional writer. I do nothing; I only write books.
If you find this post helpful please consider buying any of my books. You can buy from either Leanpub or amazon.
If you live outside the USA, it is good to buy from Leanpub.
Let me explain why. I don’t get my royalty of outside-USA-sale on Amazon. So please consider that aspect.
Maybe you are not in the mood to buy my book. In such case, you can send any amount as a ‘token of appreciation’ through Paypal.
My Paypal username-email is sanjib12sinha@gmail.com.

Advertisements