Your SlideShare is downloading. ×
Composer | PHP Dependency Manager
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Composer | PHP Dependency Manager

392
views

Published on

A quick start presentation on Composer, PHP dependency manager

A quick start presentation on Composer, PHP dependency manager

Published in: Technology

3 Comments
1 Like
Statistics
Notes
No Downloads
Views
Total Views
392
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
8
Comments
3
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. COMPOSER A PHP dependency manager
  • 2. Who am I? • Ujjwal Ojha • BSc. CSIT • Hrevert Technologies • Web application development
  • 3. Table Of Contents • Introduction • What is dependency? • Why not Pear? • Installation • Basic Usage
  • 4. Introduction • PHP dependency manager • Very useful to work with third party libraries • Similar to npm for node.js, Bundler for Ruby, or pip for Python
  • 5. What is dependency?
  • 6. Recursive Dependencies
  • 7. Two Way Recursive Dependencies
  • 8. Why not Pear? • Pears installs packages globally • With Pear, your code is scattered throughout the machine.
  • 9. Installation mkdir myprojectname cd myprojectname curl -s https://getcomposer.org/installer | php
  • 10. Create composer.json { "require": { "silex/silex": "~1.0" } } php composer.phar install
  • 11. Loading composer repositories with package information Installing dependencies - Installing psr/log (1.0.0) Loading from cache - Installing symfony/routing (v2.2.1) Downloading: 100% - Installing symfony/http-foundation (v2.2.1) Downloading: 100% - Installing symfony/event-dispatcher (v2.2.1) Loading from cache - Installing symfony/http-kernel (v2.2.1) Downloading: 100% - Installing pimple/pimple (v1.0.2) Downloading: 100% - Installing silex/silex (v1.0.0) Downloading: 100% Writing lock file Generating autoload files Your dependencies dependency Your dependency
  • 12. Autoloading Composer generates an autoload file for all your Dependencies
  • 13. Autoloader Supports PSR-0 Autoloader PSR-4 Autoloader Classmap Autoloader
  • 14. Autoloader usage <?php // From your app`s bootstrap.php include “vendor/autoload.php”;
  • 15. Scripts Perform custom actions during installation and update "scripts": { "post-install-cmd": [ "Sensio...ComposerScriptHandler::buildBootstrap", "Sensio...ComposerScriptHandler::clearCache", "Sensio...ComposerScriptHandler::installAssets", "Sensio...ComposerScriptHandler::installRequirementsFile " ], "post-update-cmd": [ “Sensio...ComposerScriptHandler::buildBootstrap", "Sensio...ComposerScriptHandler::clearCache", "Sensio...ComposerScriptHandler::installAssets", "Sensio...ComposerScriptHandler::installRequirementsFile " ] },
  • 16. Non-composer packages { "repositories": [ { "type": "package", "package": { "name": "smarty/smarty", "version": "3.1.7", "dist": { "url": "http://www.smarty.net/files/Smarty-3.1.7.zip", "type": "zip" }, "source": { "url": "http://smarty-php.googlecode.com/svn/", "type": "svn" } } } ] }
  • 17. Private dependencies with Satis { "repositories": [ { "type": "composer", "url": "http://packages.example.org/" } ], "require": { "company/package": "1.2.0", "company/package2": “1.5.2", } }
  • 18. Thank You Questions? Ujjwal Ojha