0
Project Dependencies
Project that depends on a number of libraries.
Libraries depend on other libraries.
Declare the thing...
●
●

Command-line utility
Inspired by npm and bundler

●
●

Dependency manager
Not package manager

What is
Composer?
●
●
...
System Requirements
●

PHP 5.3.2+

●

php settings and compile flags

●

git, svn or hg

●

Composer is multi-platform
Installation
●

Can be installed locally i.e in your working directory

●

Recommended to install globally (/usr/local/bin...
Using Composer
●

composer require phpunit/phpunit:3.9

●

composer.json

●

“require” key
○ {
“require” : {“monolog/monol...
Autoloading
require ‘vendor/autoload.php’
Supported : PSR-0 AND PSR-4
{
"autoload": {
"psr-4": {
"Monolog": "src/",
"Vendo...
Google+ API Examples
{
"name": "googleplus/quickstart",
"description": "This quick-start ...",
"license": "Apache-2.0",
"r...
References
http://www.phptherightway.com/#composer_and_packagist
http://foohack.com/2010/08/intro-to-npm/
https://getcompo...
Composer
Upcoming SlideShare
Loading in...5
×

Composer

313

Published on

Tool to manage dependency packages in your project

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
313
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Composer"

  1. 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. 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. 3. System Requirements ● PHP 5.3.2+ ● php settings and compile flags ● git, svn or hg ● Composer is multi-platform
  4. 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. 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. 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. 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. 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
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×