SlideShare uma empresa Scribd logo
1 de 31
Baixar para ler offline
Jordi Boggiano
@seldaek
http://nelm.io/

Dependency Management
with Composer
About Me
              Belgian living in Zürich, Switzerland
              Building the internet for 10 years
               http://seld.be
              Symfony2, Composer and other OSS contributions
               http://github.com/Seldaek
              Working at Nelmio
               http://nelm.io
               Symfony2 & frontend performance consulting




Jordi Boggiano                                                 Company nelm.io
Twitter @seldaek                                                   Blog seld.be
Jordi Boggiano     Company nelm.io
Twitter @seldaek       Blog seld.be
Managing
                   Packages vs Dependencies




Jordi Boggiano                                Company nelm.io
Twitter @seldaek                                  Blog seld.be
Package Management in PHP




Jordi Boggiano                                 Company nelm.io
Twitter @seldaek                                   Blog seld.be
The Composer Ecosystem
                        github.com/composer




Jordi Boggiano                                Company nelm.io
Twitter @seldaek                                  Blog seld.be
The Composer Ecosystem
              Composer - CLI Tool
                   Easy to use
                   Installs deps per-project
                   Flexible and embeddable




Jordi Boggiano                                 Company nelm.io
Twitter @seldaek                                   Blog seld.be
The Composer Ecosystem
              Packagist - Package Repository
                   Aggregates PHP libraries
                   Open to all OSS projects
                   Feeds on VCS repositories




Jordi Boggiano                                 Company nelm.io
Twitter @seldaek                                   Blog seld.be
Early adopters are loving it




Jordi Boggiano                                    Company nelm.io
Twitter @seldaek                                      Blog seld.be
The Composer Ecosystem
              Satis - Micro Repository
                   Minimalistic
                   Useful for closed code




Jordi Boggiano                               Company nelm.io
Twitter @seldaek                                 Blog seld.be
Usage Instructions
Using a Composed Project
               git clone https://github.com/igorw/trashbin

               Cloning into trashbin...

               cd trashbin/
               curl -s http://getcomposer.org/installer | php

               All settings correct for using Composer
               Composer successfully installed to: /home/bob/trashbin/composer.phar
               Use it: php composer.phar




Jordi Boggiano                                                                    Company nelm.io
Twitter @seldaek                                                                      Blog seld.be
Using a Composed Project
               php composer.phar install

               Installing from lock file
                 - Package symfony/class-loader (2.1.0-dev)
                   Downloading
                   Unpacking archive
                   Cleaning up
               [...]
                   - Package predis/predis (dev-master)
                     Downloading
                     Unpacking archive
                     Cleaning up
                   - Package twig/twig (1.6.0)
                     Downloading
                     Unpacking archive
                     Cleaning up
               Generating autoload files




Jordi Boggiano                                                Company nelm.io
Twitter @seldaek                                                  Blog seld.be
Using a Composed Project
              01 vendor/
              02     .composer/
              03     bin/
              04     pimple/
              05         pimple/
              06     predis/
              07         predis/
              08         service-provider/
              09     silex/
              10         silex/
              11     symfony/
              12         browser-kit/
              13         class-loader/
              14         css-selector/
              15         dom-crawler/
              16         event-dispatcher/
              17         finder/
              18         http-foundation/
              19         http-kernel/
              20         routing/
              21     twig/
              22         twig/




Jordi Boggiano                                              Company nelm.io
Twitter @seldaek                                                Blog seld.be
Downloading Project Dependencies
              composer.json
                   Located in project root directory
                   Defines dependencies
               1 {
               2       "require": {
               3           "silex/silex": ">=1.0.0-dev",
               4           "symfony/finder": "2.1-dev",
               5           "twig/twig": "1.*",
               6           "predis/service-provider": "dev-master"
               7       }
               8 }
              Source install: With install --prefer-source it clones/checks out the code.




Jordi Boggiano                                                                              Company nelm.io
Twitter @seldaek                                                                                Blog seld.be
Creating a Package Definition
              01 {
              02       "name": "predis/predis",
              03       "type": "library",
              04       "description": "Flexible and feature-complete Redis client",
              05       "keywords": ["nosql", "redis", "predis"],
              06       "homepage": "http://github.com/nrk/predis",
              07       "license": "MIT",
              08       "version": "0.7.1"
              09       "authors": [
              10           {
              11               "name": "Daniele Alessandri",
              12               "email": "suppakilla@gmail.com",
              13               "homepage": "http://clorophilla.net"
              14           }
              15       ],
              16       "require": {
              17           "php": ">=5.3.0"
              18       },
              19       "autoload": {
              20           "psr-0": {"Predis": "lib/"}
              21       }
              22 }
              Note: Package Definition === Application/Root Package




Jordi Boggiano                                                                        Company nelm.io
Twitter @seldaek                                                                          Blog seld.be
Avoiding version chaos
                                          in your team
              composer.lock
                   Lists packages & versions
                   Replaces composer.json
                   Created by composer install (installs your dependencies)
                   Updated by composer update (updates your dependencies)
                   Must be committed in your VCS and shipped with your releases
              Benefits
                   Everyone on a team works with exactly the same dependency versions
                   When deploying, all machines run exactly the same dependency versions
                   Users will never get dependency versions that you did not test with




Jordi Boggiano                                                                        Company nelm.io
Twitter @seldaek                                                                          Blog seld.be
Autoloading
              Libraries/projects define their namespaces:
               1 "autoload": {
               2     "psr-0": {"Predis": "lib/"}
               3 }
              Composer builds an autoloader for you:
               1 vendor/.composer/
               2     autoload_namespaces.php
               3     autoload.php
               4     ClassLoader.php
               5     installed.json
              Trashbin uses the generated autoloader:
               1   require_once __DIR__.'/../vendor/.composer/autoload.php';
               2
               3   use SilexApplication;
               4   use SilexExtensionTwigExtension;
               5
               6   use SymfonyComponentFinderFinder;
               7   use SymfonyComponentHttpFoundationResponse;
               8
               9   $app = new Application();



Jordi Boggiano                                                                 Company nelm.io
Twitter @seldaek                                                                   Blog seld.be
Autoloading Tests
              Add your own namespaces for testing purposes in PHPUnit's bootstrap:
               1 # tests/bootstrap.php
               2
               3 $loader = require_once __DIR__.'/../vendor/.composer/autoload.php';
               4
               5 $loader->add('MyTest', __DIR__);




Jordi Boggiano                                                                         Company nelm.io
Twitter @seldaek                                                                           Blog seld.be
Alternative Repositories
              01 "repositories": [
              02     {
              03         "type": "composer",
              04         "url": "http://example.org"
              05     },
              06     {
              07         "type": "vcs",
              08         "url": "git://example.org/MyRepo.git"
              09     },
              10     {
              11         "type": "pear",
              12         "url": "http://pear.example.org"
              13     },
              14     {
              15         "packagist": false
              16     }
              17 ]
              Composer Repository Implementations ($url/packages.json)
                 Packagist
                 Satis
                 (Pirum)




Jordi Boggiano                                                           Company nelm.io
Twitter @seldaek                                                             Blog seld.be
Depending on packages without composer.json
              01   "repositories": [
              02       {
              03           "type": "package",
              04           "package": {
              05               "name": "vendor/package",
              06               "version": "1.0.0",
              07               "dist": {
              08                   "url": "http://example.org/package.zip",
              09                   "type": "zip"
              10               },
              11               "source": {
              12                   "url": "git://example.org/package.git",
              13                   "type": "git",
              14                   "reference": "tag name, branch name or commit hash"
              15               }
              16           }
              17       }
              18   ],
              19   "require": {
              20       "vendor/package": "1.0.0"
              21   }
              Note: repositories are only available to the root package




Jordi Boggiano                                                                           Company nelm.io
Twitter @seldaek                                                                             Blog seld.be
State of the Project




Jordi Boggiano                            Company nelm.io
Twitter @seldaek                              Blog seld.be
Adoption
                   >500 packages on Packagist (+150 in
                   Feb.)
                   Alpha1 just released
                   Many early adopters
                   Supported by frameworks/libs
                   Chef recipes http://goo.gl/1QMKp
                   (Integration in apps for plugins)
                   (Integration by PaaS providers)


Jordi Boggiano                                           Company nelm.io
Twitter @seldaek                                             Blog seld.be
Missing Features
                   Human readable error reporting
                   User-friendliness on expected failures
                   Better support for beta/alpha/.. releases
                   Many more little things:
                   github.com/composer/composer/issues




Jordi Boggiano                                                 Company nelm.io
Twitter @seldaek                                                   Blog seld.be
Wishful Thinking
Look around.
                   Write small libs.
                      Share code.
                    Reuse things.
                   Reinvigorate PHP


Jordi Boggiano                         Company nelm.io
Twitter @seldaek                           Blog seld.be
Find Out More
                   GetComposer.org
                   Packagist.org
                   github.com/composer
                   composer-dev google group
                   #composer & #composer-dev



Jordi Boggiano                                 Company nelm.io
Twitter @seldaek                                   Blog seld.be
Thank you.




Jordi Boggiano                  Company nelm.io
Twitter @seldaek                    Blog seld.be
Questions?
                      jordi@nelm.io
                         @seldaek
                      slides.seld.be

                        Feedback:
                   http://joind.in/6051

Jordi Boggiano                            Company nelm.io
Twitter @seldaek                              Blog seld.be

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Composer for Magento 1.x and Magento 2
Composer for Magento 1.x and Magento 2Composer for Magento 1.x and Magento 2
Composer for Magento 1.x and Magento 2
 
Composer the Right Way - PHPBNL16
Composer the Right Way - PHPBNL16Composer the Right Way - PHPBNL16
Composer the Right Way - PHPBNL16
 
Composer The Right Way - 010PHP
Composer The Right Way - 010PHPComposer The Right Way - 010PHP
Composer The Right Way - 010PHP
 
Php Dependency Management with Composer ZendCon 2016
Php Dependency Management with Composer ZendCon 2016Php Dependency Management with Composer ZendCon 2016
Php Dependency Management with Composer ZendCon 2016
 
Create your own composer package
Create your own composer packageCreate your own composer package
Create your own composer package
 
PHP Quality Assurance Workshop PHPBenelux
PHP Quality Assurance Workshop PHPBeneluxPHP Quality Assurance Workshop PHPBenelux
PHP Quality Assurance Workshop PHPBenelux
 
Composer The Right Way #PHPjhb15
Composer The Right Way #PHPjhb15Composer The Right Way #PHPjhb15
Composer The Right Way #PHPjhb15
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.cat
 
Composer The Right Way
Composer The Right WayComposer The Right Way
Composer The Right Way
 
Composer the right way
Composer the right wayComposer the right way
Composer the right way
 
Composer the right way - DPC15
Composer the right way - DPC15Composer the right way - DPC15
Composer the right way - DPC15
 
Composer the Right Way - MM16NL
Composer the Right Way - MM16NLComposer the Right Way - MM16NL
Composer the Right Way - MM16NL
 
Composer the right way [SweetlakePHP]
Composer the right way [SweetlakePHP]Composer the right way [SweetlakePHP]
Composer the right way [SweetlakePHP]
 
Composer the Right Way - PHPSRB16
Composer the Right Way - PHPSRB16Composer the Right Way - PHPSRB16
Composer the Right Way - PHPSRB16
 
Composer the right way - NomadPHP
Composer the right way - NomadPHPComposer the right way - NomadPHP
Composer the right way - NomadPHP
 
Composer The Right Way - PHPUGMRN
Composer The Right Way - PHPUGMRNComposer The Right Way - PHPUGMRN
Composer The Right Way - PHPUGMRN
 
Python at Facebook
Python at FacebookPython at Facebook
Python at Facebook
 
Web backends development using Python
Web backends development using PythonWeb backends development using Python
Web backends development using Python
 
Servlet 3.1 Async I/O
Servlet 3.1 Async I/OServlet 3.1 Async I/O
Servlet 3.1 Async I/O
 
Phalcon 2 - PHP Brazil Conference
Phalcon 2 - PHP Brazil ConferencePhalcon 2 - PHP Brazil Conference
Phalcon 2 - PHP Brazil Conference
 

Destaque

Nolahouse
NolahouseNolahouse
Nolahouse
carcin
 
Lgelectronics 110912130948-phpapp02
Lgelectronics 110912130948-phpapp02Lgelectronics 110912130948-phpapp02
Lgelectronics 110912130948-phpapp02
Rizwan Ahmad
 
Bloemen
BloemenBloemen
Bloemen
MoensM
 
маски Dual system
маски Dual systemмаски Dual system
маски Dual system
Liza Alypova
 

Destaque (18)

CRISE - INSTITUT 2012 - Brian Mishara - Enjeux et défis en prévention du suic...
CRISE - INSTITUT 2012 - Brian Mishara - Enjeux et défis en prévention du suic...CRISE - INSTITUT 2012 - Brian Mishara - Enjeux et défis en prévention du suic...
CRISE - INSTITUT 2012 - Brian Mishara - Enjeux et défis en prévention du suic...
 
Why Towels
Why TowelsWhy Towels
Why Towels
 
Trabajo carol sql
Trabajo  carol sqlTrabajo  carol sql
Trabajo carol sql
 
Whitepaper the mobile-commerce-impact
Whitepaper the mobile-commerce-impactWhitepaper the mobile-commerce-impact
Whitepaper the mobile-commerce-impact
 
Solution cz
Solution czSolution cz
Solution cz
 
Nolahouse
NolahouseNolahouse
Nolahouse
 
Lgelectronics 110912130948-phpapp02
Lgelectronics 110912130948-phpapp02Lgelectronics 110912130948-phpapp02
Lgelectronics 110912130948-phpapp02
 
Paypersocials
PaypersocialsPaypersocials
Paypersocials
 
Cmmaao action-pmi-pmp
Cmmaao action-pmi-pmpCmmaao action-pmi-pmp
Cmmaao action-pmi-pmp
 
Những tác phẩm điêu khắc ngoài trời thú vị
Những tác phẩm điêu khắc ngoài trời thú vịNhững tác phẩm điêu khắc ngoài trời thú vị
Những tác phẩm điêu khắc ngoài trời thú vị
 
Task 2
Task 2Task 2
Task 2
 
Drupal usage by example : World Food Programme
Drupal usage by example : World Food ProgrammeDrupal usage by example : World Food Programme
Drupal usage by example : World Food Programme
 
J O B S I
J  O  B  S  IJ  O  B  S  I
J O B S I
 
Общественный контроль за полицией в Волгодонске
Общественный контроль за полицией в ВолгодонскеОбщественный контроль за полицией в Волгодонске
Общественный контроль за полицией в Волгодонске
 
Image ideas
Image ideasImage ideas
Image ideas
 
Bloemen
BloemenBloemen
Bloemen
 
маски Dual system
маски Dual systemмаски Dual system
маски Dual system
 
Esculturas de Areia
Esculturas de AreiaEsculturas de Areia
Esculturas de Areia
 

Semelhante a Dependency Management with Composer

international PHP2011_Jordi Boggiano_PHP Reset
international PHP2011_Jordi Boggiano_PHP Resetinternational PHP2011_Jordi Boggiano_PHP Reset
international PHP2011_Jordi Boggiano_PHP Reset
smueller_sandsmedia
 

Semelhante a Dependency Management with Composer (20)

PHP Reset
PHP ResetPHP Reset
PHP Reset
 
international PHP2011_Jordi Boggiano_PHP Reset
international PHP2011_Jordi Boggiano_PHP Resetinternational PHP2011_Jordi Boggiano_PHP Reset
international PHP2011_Jordi Boggiano_PHP Reset
 
Of metacello, git, scripting and things
Of metacello, git, scripting and thingsOf metacello, git, scripting and things
Of metacello, git, scripting and things
 
WordPress modern development
WordPress modern developmentWordPress modern development
WordPress modern development
 
2012 11-01 Hackers & founders - Boot to the web, boot 2 gecko / Firefox OS
2012 11-01 Hackers & founders - Boot to the web, boot 2 gecko / Firefox OS2012 11-01 Hackers & founders - Boot to the web, boot 2 gecko / Firefox OS
2012 11-01 Hackers & founders - Boot to the web, boot 2 gecko / Firefox OS
 
2015 DockerCon Using Docker in production at bity.com
2015 DockerCon Using Docker in production at bity.com2015 DockerCon Using Docker in production at bity.com
2015 DockerCon Using Docker in production at bity.com
 
Intro to Web Components, Polymer & Vaadin Elements
Intro to Web Components, Polymer & Vaadin ElementsIntro to Web Components, Polymer & Vaadin Elements
Intro to Web Components, Polymer & Vaadin Elements
 
How to create a local Android open source project mirror in 6 easy steps
How to create a local Android open source project mirror in 6 easy stepsHow to create a local Android open source project mirror in 6 easy steps
How to create a local Android open source project mirror in 6 easy steps
 
Porion a new Build Manager
Porion a new Build ManagerPorion a new Build Manager
Porion a new Build Manager
 
2012 09-04 smart devcon - boot to the web, boot 2 gecko
2012 09-04 smart devcon - boot to the web, boot 2 gecko2012 09-04 smart devcon - boot to the web, boot 2 gecko
2012 09-04 smart devcon - boot to the web, boot 2 gecko
 
DockerCon EU 2015: Trading Bitcoin with Docker
DockerCon EU 2015: Trading Bitcoin with DockerDockerCon EU 2015: Trading Bitcoin with Docker
DockerCon EU 2015: Trading Bitcoin with Docker
 
Monorepo: React Web & React Native
Monorepo: React Web & React NativeMonorepo: React Web & React Native
Monorepo: React Web & React Native
 
Building and Customizing CoreOS
Building and Customizing CoreOSBuilding and Customizing CoreOS
Building and Customizing CoreOS
 
CNCF Québec Meetup du 16 Novembre 2023
CNCF Québec Meetup du 16 Novembre 2023CNCF Québec Meetup du 16 Novembre 2023
CNCF Québec Meetup du 16 Novembre 2023
 
CocoaPods.pptx
CocoaPods.pptxCocoaPods.pptx
CocoaPods.pptx
 
Workshop: Introduction to Web Components & Polymer
Workshop: Introduction to Web Components & Polymer Workshop: Introduction to Web Components & Polymer
Workshop: Introduction to Web Components & Polymer
 
Presentazione resin.io
Presentazione resin.ioPresentazione resin.io
Presentazione resin.io
 
Practical git for developers
Practical git for developersPractical git for developers
Practical git for developers
 
Conhecendo o-composer-por-nandokstronet
Conhecendo o-composer-por-nandokstronetConhecendo o-composer-por-nandokstronet
Conhecendo o-composer-por-nandokstronet
 
Docker Runtime Security
Docker Runtime SecurityDocker Runtime Security
Docker Runtime Security
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Último (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 

Dependency Management with Composer

  • 2. About Me Belgian living in Zürich, Switzerland Building the internet for 10 years http://seld.be Symfony2, Composer and other OSS contributions http://github.com/Seldaek Working at Nelmio http://nelm.io Symfony2 & frontend performance consulting Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 3. Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 4. Managing Packages vs Dependencies Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 5. Package Management in PHP Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 6. The Composer Ecosystem github.com/composer Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 7. The Composer Ecosystem Composer - CLI Tool Easy to use Installs deps per-project Flexible and embeddable Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 8. The Composer Ecosystem Packagist - Package Repository Aggregates PHP libraries Open to all OSS projects Feeds on VCS repositories Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 9.
  • 10. Early adopters are loving it Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 11. The Composer Ecosystem Satis - Micro Repository Minimalistic Useful for closed code Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 13. Using a Composed Project git clone https://github.com/igorw/trashbin Cloning into trashbin... cd trashbin/ curl -s http://getcomposer.org/installer | php All settings correct for using Composer Composer successfully installed to: /home/bob/trashbin/composer.phar Use it: php composer.phar Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 14. Using a Composed Project php composer.phar install Installing from lock file - Package symfony/class-loader (2.1.0-dev) Downloading Unpacking archive Cleaning up [...] - Package predis/predis (dev-master) Downloading Unpacking archive Cleaning up - Package twig/twig (1.6.0) Downloading Unpacking archive Cleaning up Generating autoload files Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 15. Using a Composed Project 01 vendor/ 02 .composer/ 03 bin/ 04 pimple/ 05 pimple/ 06 predis/ 07 predis/ 08 service-provider/ 09 silex/ 10 silex/ 11 symfony/ 12 browser-kit/ 13 class-loader/ 14 css-selector/ 15 dom-crawler/ 16 event-dispatcher/ 17 finder/ 18 http-foundation/ 19 http-kernel/ 20 routing/ 21 twig/ 22 twig/ Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 16. Downloading Project Dependencies composer.json Located in project root directory Defines dependencies 1 { 2 "require": { 3 "silex/silex": ">=1.0.0-dev", 4 "symfony/finder": "2.1-dev", 5 "twig/twig": "1.*", 6 "predis/service-provider": "dev-master" 7 } 8 } Source install: With install --prefer-source it clones/checks out the code. Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 17. Creating a Package Definition 01 { 02 "name": "predis/predis", 03 "type": "library", 04 "description": "Flexible and feature-complete Redis client", 05 "keywords": ["nosql", "redis", "predis"], 06 "homepage": "http://github.com/nrk/predis", 07 "license": "MIT", 08 "version": "0.7.1" 09 "authors": [ 10 { 11 "name": "Daniele Alessandri", 12 "email": "suppakilla@gmail.com", 13 "homepage": "http://clorophilla.net" 14 } 15 ], 16 "require": { 17 "php": ">=5.3.0" 18 }, 19 "autoload": { 20 "psr-0": {"Predis": "lib/"} 21 } 22 } Note: Package Definition === Application/Root Package Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 18. Avoiding version chaos in your team composer.lock Lists packages & versions Replaces composer.json Created by composer install (installs your dependencies) Updated by composer update (updates your dependencies) Must be committed in your VCS and shipped with your releases Benefits Everyone on a team works with exactly the same dependency versions When deploying, all machines run exactly the same dependency versions Users will never get dependency versions that you did not test with Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 19. Autoloading Libraries/projects define their namespaces: 1 "autoload": { 2 "psr-0": {"Predis": "lib/"} 3 } Composer builds an autoloader for you: 1 vendor/.composer/ 2 autoload_namespaces.php 3 autoload.php 4 ClassLoader.php 5 installed.json Trashbin uses the generated autoloader: 1 require_once __DIR__.'/../vendor/.composer/autoload.php'; 2 3 use SilexApplication; 4 use SilexExtensionTwigExtension; 5 6 use SymfonyComponentFinderFinder; 7 use SymfonyComponentHttpFoundationResponse; 8 9 $app = new Application(); Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 20. Autoloading Tests Add your own namespaces for testing purposes in PHPUnit's bootstrap: 1 # tests/bootstrap.php 2 3 $loader = require_once __DIR__.'/../vendor/.composer/autoload.php'; 4 5 $loader->add('MyTest', __DIR__); Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 21. Alternative Repositories 01 "repositories": [ 02 { 03 "type": "composer", 04 "url": "http://example.org" 05 }, 06 { 07 "type": "vcs", 08 "url": "git://example.org/MyRepo.git" 09 }, 10 { 11 "type": "pear", 12 "url": "http://pear.example.org" 13 }, 14 { 15 "packagist": false 16 } 17 ] Composer Repository Implementations ($url/packages.json) Packagist Satis (Pirum) Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 22. Depending on packages without composer.json 01 "repositories": [ 02 { 03 "type": "package", 04 "package": { 05 "name": "vendor/package", 06 "version": "1.0.0", 07 "dist": { 08 "url": "http://example.org/package.zip", 09 "type": "zip" 10 }, 11 "source": { 12 "url": "git://example.org/package.git", 13 "type": "git", 14 "reference": "tag name, branch name or commit hash" 15 } 16 } 17 } 18 ], 19 "require": { 20 "vendor/package": "1.0.0" 21 } Note: repositories are only available to the root package Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 23. State of the Project Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 24.
  • 25. Adoption >500 packages on Packagist (+150 in Feb.) Alpha1 just released Many early adopters Supported by frameworks/libs Chef recipes http://goo.gl/1QMKp (Integration in apps for plugins) (Integration by PaaS providers) Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 26. Missing Features Human readable error reporting User-friendliness on expected failures Better support for beta/alpha/.. releases Many more little things: github.com/composer/composer/issues Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 28. Look around. Write small libs. Share code. Reuse things. Reinvigorate PHP Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 29. Find Out More GetComposer.org Packagist.org github.com/composer composer-dev google group #composer & #composer-dev Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 30. Thank you. Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be
  • 31. Questions? jordi@nelm.io @seldaek slides.seld.be Feedback: http://joind.in/6051 Jordi Boggiano Company nelm.io Twitter @seldaek Blog seld.be