Modern PHP with Composer

For some of you who may not know about composer for PHP 5.3 and above, I’d like to summarize what I’ve discovered about this powerful tool so far.
Composer is a tool for dependency management in PHP. It allows you to declare the dependent libraries your project needs and it will install them in your project for you. (composer.org). To use it, go to the website and download the Composer-Setup.exe for windows or run a terminal to get the latest Composer version by command curl -sS https://getcomposer.org/installer | php

– On windows, point to the php.exe file during your composer settings. If you see some error like .dll not working, try to disable it in php.ini before running composer installation. Once done, open cmd line and type composer in Windows. It should tell you what version you installed and all the available commands.
– To use it, each of your package/library must have a file called “composer.json” in the root of your project. Then cd to your project dir C:/>cd myproject. Then you must run command “composer update“, so that all libraries that you have specified in composer.json will be loaded onto your web server and make them available automatically for you to use in your project.
– Once you run composer update command, the /vendor dir will be automatically created inside your project’s directory by the composer. This is the structure you’ll see in your project directory.


1)YourProjectTest1
1a)lib
1aa)Test\PrintTest.php
1b)vendor
1ba)composer
ClassLoader.php
autoload_classmap.php
autoload_namespaces.php
autoload_psr4.php
autoload_real.php
1bb)autoload.php
1c)composer.json

Next, I’ll show you how to create the first project that use the composer. It’s a powerful tool for PHP so we all need a little time to discover it. It’s new to me, too, so stay tuned. If you find anything missing, please notify me. Happy learning!