Composer
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Composer

on

  • 415 views

Tool to manage dependency packages in your project

Tool to manage dependency packages in your project

Statistics

Views

Total Views
415
Views on SlideShare
415
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Composer Presentation Transcript

  • 1. Project Dependencies Project that depends on a number of libraries. Libraries depend on other libraries. Declare the things you depend on. Composer which packages which versions installs them (meaning it downloads them into your project).
  • 2. ● ● Command-line utility Inspired by npm and bundler ● ● Dependency manager Not package manager What is Composer? ● ● Download project dependencies Set autoloading ● ● Composer compatible Php Libraries Packagist
  • 3. System Requirements ● PHP 5.3.2+ ● php settings and compile flags ● git, svn or hg ● Composer is multi-platform
  • 4. Installation ● Can be installed locally i.e in your working directory ● Recommended to install globally (/usr/local/bin) ● Interactive Installation : curl -s https://getcomposer.org/installer | php Run the installer. ● Manual Installation : curl -s https://getcomposer.org/composer.phar -o $HOME/local/bin/composer chmod +x $HOME/local/bin/composer
  • 5. Using Composer ● composer require phpunit/phpunit:3.9 ● composer.json ● “require” key ○ { “require” : {“monolog/monolog” : “dev-master#12”} “require” : { “phpunit/phpunit” : “3.9.*@dev” "prefer-stable": true } “require” : {“dojo/dojo” : “>1.8.0”} “require” : {“dojo/dijit” : “~1.8”} } ● require : { [Vendor Name] / [Package Name] : [version] } ● php composer.phar install
  • 6. Autoloading require ‘vendor/autoload.php’ Supported : PSR-0 AND PSR-4 { "autoload": { "psr-4": { "Monolog": "src/", "VendorNamespace": "" } } } $loader = require 'vendor/autoload.php'; $loader->add('AcmeTest', __DIR__); More Details : https://getcomposer.org/doc/04-schema.md#autoload
  • 7. Google+ API Examples { "name": "googleplus/quickstart", "description": "This quick-start ...", "license": "Apache-2.0", "repositories": [ { "type": "package", "package": { "name": "google/google-api-php-client", "version": "0.6.2", "dist": { "url": "http://google-api-php-client.googlecode.com/files/google-api-php-client-0.6.2.tar.gz", "type": "tar" }, "autoload": { "classmap": [ "src/" ] } } } ], "require": { "silex/silex": "1.0.*@dev", "twig/twig": ">=1.8,<2.0-dev", "google/google-api-php-client": "0.6.2" } }
  • 8. References http://www.phptherightway.com/#composer_and_packagist http://foohack.com/2010/08/intro-to-npm/ https://getcomposer.org/doc/00-intro.md https://security.sensiolabs.org/disclaimer http://www.php-fig.org/psr/psr-4/ https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md https://getcomposer.org/doc/04-schema.md https://developers.google.com/+/quickstart/php