SlideShare a Scribd company logo
1 of 13
presents 
Lightning Talk => Composer
A quick slide about Me 
Eric Van Johnson 
PHP Developer, Architect and an Organizer of SDPHP 
● Github: https://github.com/shocm 
● LinkedIn: http://www.linkedin.com/in/vanjohnson 
● Joind.in: https://joind.in/user/view/1770 
● Twitter: @shocm 
● IRC: @shocm 
● eric@sdphp.org 
● Website: www.shocm.com
The Issues 
● Your app depends on libraries 
● There is maintenance to keep 
these libraries up to date 
● Libraries also have dependency 
on other libraries
We’ve (php) tried to 
address this issue before 
PEAR : A Library for PHP 
PHP Extension and Application Repository 
Used by many developers 
Problems with PEAR 
● In general, PEAR is meant to be installed on a system level. Although with 
some tweaking this can be avoided. However, using PEAR at a system 
level can make it difficult to migrate code from system to system. 
● There are a TON of PEAR Libraries and not all of them are very well 
documented.
Enter Composer 
What Does Composer Do? 
● You tell Composer what libraries you want 
● Composer then manages the libraries and the 
dependencies for those libraries 
● Installs everything for you 
● Creates an autoloader
Installing Composer 
You can install Composer in a local directory 
using the command 
curl -s https://getcomposer.org/installer | php 
A more common practice is to install composer 
globally 
curl -s https://getcomposer.org/composer.phar  
-o $HOME/local/bin/composer 
chmod +x $HOME/local/bin/composer 
This gives you access to 
composer install
Using Composer 
composer create-project laravel/laravel --prefer-dist 
The above command downloads and installs the core 
libraries for a Laravel Project. It also downloads and install 
all the dependencies such as several symfony 
components. 
End result
The composer.json File 
This is where a lot of magic 
happens. 
“require” is the key to the 
strength of Composer. This 
tells composer what core 
libraries, and their versions, 
you would like to install. 
Composer then figures out 
the dependencies and their 
versions and installs them.
Where do these Packages 
come from? 
Packagist 
Main Repository 
https://packagist.org/ 
Create your own 
with Satis 
https://github.com/composer/satis
Autoloading 
index.php 
<?php 
require ‘vendor/autoload.php’; 
// You can now use your dependencies 
// without requiring them 
use 
SymfonyComponentConsoleApplication;
Updating with Composer 
To add a library, you can edit the composer.json file directly or 
use the command-line 
composer require vendor/package:2.* vendor/package2:dev-master 
Then simply run 
composer update 
‘composer update’ will also update all the existing packages and 
dependencies based on the composer.json configuration.
Summary 
● Very Simple to Install and Implement 
● Cool “Magical” dependency resolution 
● You can make and contribute your own packages 
● Composer autoloader make life easy and is PSR compliant
THANK YOU! 
Eric Van Johnson 
● Twitter: @shocm 
● IRC: @shocm 
● eric@sdphp.org 
● Website: www.shocm.com

More Related Content

What's hot

php[world] 2015 Laravel 5.1: From Homestead to the Cloud
php[world] 2015 Laravel 5.1: From Homestead to the Cloudphp[world] 2015 Laravel 5.1: From Homestead to the Cloud
php[world] 2015 Laravel 5.1: From Homestead to the CloudJoe Ferguson
 
Brief introduction to Symfony Flex
Brief introduction to Symfony FlexBrief introduction to Symfony Flex
Brief introduction to Symfony FlexFedir Kryvytskyi
 
Material Design and Seaside
Material Design and SeasideMaterial Design and Seaside
Material Design and SeasidePharo
 
Jenkins on Docker
Jenkins on DockerJenkins on Docker
Jenkins on DockerCraig Trim
 
Laravel Code Generators and Packages
Laravel Code Generators and PackagesLaravel Code Generators and Packages
Laravel Code Generators and PackagesPovilas Korop
 
Why You Should Use Oracle SQL Developer
Why You Should Use Oracle SQL DeveloperWhy You Should Use Oracle SQL Developer
Why You Should Use Oracle SQL DeveloperJeffrey Kemp
 
Symfony Nano Framework
Symfony Nano FrameworkSymfony Nano Framework
Symfony Nano FrameworkLoïc Faugeron
 
Composer for Busy Developers - php|tek13
Composer for Busy Developers - php|tek13Composer for Busy Developers - php|tek13
Composer for Busy Developers - php|tek13Rafael Dohms
 
All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$Joe Ferguson
 
Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3kognate
 
Php Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerPhp Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerJackson F. de A. Mafra
 
perlcc made easy or, how to make a CGI Moose app
perlcc made easy or, how to make a CGI Moose appperlcc made easy or, how to make a CGI Moose app
perlcc made easy or, how to make a CGI Moose appcPanel
 
10 less-known Laravel Packages: May 2016
10 less-known Laravel Packages: May 201610 less-known Laravel Packages: May 2016
10 less-known Laravel Packages: May 2016Povilas Korop
 
You are not_hiding_from_me_.net
You are not_hiding_from_me_.netYou are not_hiding_from_me_.net
You are not_hiding_from_me_.netChung Wee Jing
 

What's hot (20)

php[world] 2015 Laravel 5.1: From Homestead to the Cloud
php[world] 2015 Laravel 5.1: From Homestead to the Cloudphp[world] 2015 Laravel 5.1: From Homestead to the Cloud
php[world] 2015 Laravel 5.1: From Homestead to the Cloud
 
composer_talk_20160209
composer_talk_20160209composer_talk_20160209
composer_talk_20160209
 
PHP Conference - Phalcon hands-on
PHP Conference - Phalcon hands-onPHP Conference - Phalcon hands-on
PHP Conference - Phalcon hands-on
 
Brief introduction to Symfony Flex
Brief introduction to Symfony FlexBrief introduction to Symfony Flex
Brief introduction to Symfony Flex
 
Phalcon 2 - PHP Brazil Conference
Phalcon 2 - PHP Brazil ConferencePhalcon 2 - PHP Brazil Conference
Phalcon 2 - PHP Brazil Conference
 
Material Design and Seaside
Material Design and SeasideMaterial Design and Seaside
Material Design and Seaside
 
Jenkins on Docker
Jenkins on DockerJenkins on Docker
Jenkins on Docker
 
Laravel Code Generators and Packages
Laravel Code Generators and PackagesLaravel Code Generators and Packages
Laravel Code Generators and Packages
 
Why You Should Use Oracle SQL Developer
Why You Should Use Oracle SQL DeveloperWhy You Should Use Oracle SQL Developer
Why You Should Use Oracle SQL Developer
 
Magento Meetup New Delhi- Console
Magento Meetup New Delhi- ConsoleMagento Meetup New Delhi- Console
Magento Meetup New Delhi- Console
 
Symfony Nano Framework
Symfony Nano FrameworkSymfony Nano Framework
Symfony Nano Framework
 
Subversion Saves The Day
Subversion Saves The DaySubversion Saves The Day
Subversion Saves The Day
 
Composer for Busy Developers - php|tek13
Composer for Busy Developers - php|tek13Composer for Busy Developers - php|tek13
Composer for Busy Developers - php|tek13
 
All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$
 
Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3
 
Perl ides
Perl idesPerl ides
Perl ides
 
Php Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerPhp Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant Killer
 
perlcc made easy or, how to make a CGI Moose app
perlcc made easy or, how to make a CGI Moose appperlcc made easy or, how to make a CGI Moose app
perlcc made easy or, how to make a CGI Moose app
 
10 less-known Laravel Packages: May 2016
10 less-known Laravel Packages: May 201610 less-known Laravel Packages: May 2016
10 less-known Laravel Packages: May 2016
 
You are not_hiding_from_me_.net
You are not_hiding_from_me_.netYou are not_hiding_from_me_.net
You are not_hiding_from_me_.net
 

Similar to Composer Lightning Talk

Dependency management with Composer
Dependency management with ComposerDependency management with Composer
Dependency management with ComposerJason Grimes
 
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 2016Clark Everetts
 
Php Dependency Management with Composer ZendCon 2017
Php Dependency Management with Composer ZendCon 2017Php Dependency Management with Composer ZendCon 2017
Php Dependency Management with Composer ZendCon 2017Clark Everetts
 
Composer - The missing package manager for PHP
Composer - The missing package manager for PHPComposer - The missing package manager for PHP
Composer - The missing package manager for PHPTareq Hasan
 
Composer Tutorial (PHP Hampshire Sept 2013)
Composer Tutorial (PHP Hampshire Sept 2013)Composer Tutorial (PHP Hampshire Sept 2013)
Composer Tutorial (PHP Hampshire Sept 2013)James Titcumb
 
12 Composer #burningkeyboards
12 Composer #burningkeyboards12 Composer #burningkeyboards
12 Composer #burningkeyboardsDenis Ristic
 
Introducing composer - a php dependency manager
Introducing composer  - a php dependency managerIntroducing composer  - a php dependency manager
Introducing composer - a php dependency managerDigvijay Tiwari
 
Using Composer to create manageable WordPress websites
Using Composer to create manageable WordPress websitesUsing Composer to create manageable WordPress websites
Using Composer to create manageable WordPress websitesAnna Ladoshkina
 
Create a PHP Library the right way
Create a PHP Library the right wayCreate a PHP Library the right way
Create a PHP Library the right wayChristian Varela
 
Volunteering atyouseeforit services
Volunteering atyouseeforit servicesVolunteering atyouseeforit services
Volunteering atyouseeforit servicesYouSee
 

Similar to Composer Lightning Talk (20)

Dependency management with Composer
Dependency management with ComposerDependency management with Composer
Dependency management with Composer
 
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
 
Composer: Dependency Manager for PHP
Composer: Dependency Manager for PHPComposer: Dependency Manager for PHP
Composer: Dependency Manager for PHP
 
Composer
ComposerComposer
Composer
 
Composer intro
Composer introComposer intro
Composer intro
 
Php Dependency Management with Composer ZendCon 2017
Php Dependency Management with Composer ZendCon 2017Php Dependency Management with Composer ZendCon 2017
Php Dependency Management with Composer ZendCon 2017
 
Composer - The missing package manager for PHP
Composer - The missing package manager for PHPComposer - The missing package manager for PHP
Composer - The missing package manager for PHP
 
Composer Tutorial (PHP Hampshire Sept 2013)
Composer Tutorial (PHP Hampshire Sept 2013)Composer Tutorial (PHP Hampshire Sept 2013)
Composer Tutorial (PHP Hampshire Sept 2013)
 
Php
PhpPhp
Php
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
Composer namespacing
Composer namespacingComposer namespacing
Composer namespacing
 
Composer
ComposerComposer
Composer
 
12 Composer #burningkeyboards
12 Composer #burningkeyboards12 Composer #burningkeyboards
12 Composer #burningkeyboards
 
Introducing composer - a php dependency manager
Introducing composer  - a php dependency managerIntroducing composer  - a php dependency manager
Introducing composer - a php dependency manager
 
Phalcon - Giant Killer
Phalcon - Giant KillerPhalcon - Giant Killer
Phalcon - Giant Killer
 
Guzzle Drupal 7
Guzzle Drupal 7Guzzle Drupal 7
Guzzle Drupal 7
 
Using Composer to create manageable WordPress websites
Using Composer to create manageable WordPress websitesUsing Composer to create manageable WordPress websites
Using Composer to create manageable WordPress websites
 
Composer
ComposerComposer
Composer
 
Create a PHP Library the right way
Create a PHP Library the right wayCreate a PHP Library the right way
Create a PHP Library the right way
 
Volunteering atyouseeforit services
Volunteering atyouseeforit servicesVolunteering atyouseeforit services
Volunteering atyouseeforit services
 

More from Eric Johnson

Deploy Laravel on Heroku
Deploy Laravel on HerokuDeploy Laravel on Heroku
Deploy Laravel on HerokuEric Johnson
 
Git - the stupid content tracker
Git - the stupid content trackerGit - the stupid content tracker
Git - the stupid content trackerEric Johnson
 
Google App Engine for PHP
Google App Engine for PHP Google App Engine for PHP
Google App Engine for PHP Eric Johnson
 
Introduction to PHP (SDPHP)
Introduction to PHP   (SDPHP)Introduction to PHP   (SDPHP)
Introduction to PHP (SDPHP)Eric Johnson
 
Intro to CakePHP - SDPHP MeetUp Dec 2012
Intro to CakePHP - SDPHP MeetUp Dec 2012Intro to CakePHP - SDPHP MeetUp Dec 2012
Intro to CakePHP - SDPHP MeetUp Dec 2012Eric Johnson
 
Introduction to PHP - SDPHP
Introduction to PHP - SDPHPIntroduction to PHP - SDPHP
Introduction to PHP - SDPHPEric Johnson
 

More from Eric Johnson (6)

Deploy Laravel on Heroku
Deploy Laravel on HerokuDeploy Laravel on Heroku
Deploy Laravel on Heroku
 
Git - the stupid content tracker
Git - the stupid content trackerGit - the stupid content tracker
Git - the stupid content tracker
 
Google App Engine for PHP
Google App Engine for PHP Google App Engine for PHP
Google App Engine for PHP
 
Introduction to PHP (SDPHP)
Introduction to PHP   (SDPHP)Introduction to PHP   (SDPHP)
Introduction to PHP (SDPHP)
 
Intro to CakePHP - SDPHP MeetUp Dec 2012
Intro to CakePHP - SDPHP MeetUp Dec 2012Intro to CakePHP - SDPHP MeetUp Dec 2012
Intro to CakePHP - SDPHP MeetUp Dec 2012
 
Introduction to PHP - SDPHP
Introduction to PHP - SDPHPIntroduction to PHP - SDPHP
Introduction to PHP - SDPHP
 

Recently uploaded

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Recently uploaded (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
+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...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Composer Lightning Talk

  • 2. A quick slide about Me Eric Van Johnson PHP Developer, Architect and an Organizer of SDPHP ● Github: https://github.com/shocm ● LinkedIn: http://www.linkedin.com/in/vanjohnson ● Joind.in: https://joind.in/user/view/1770 ● Twitter: @shocm ● IRC: @shocm ● eric@sdphp.org ● Website: www.shocm.com
  • 3. The Issues ● Your app depends on libraries ● There is maintenance to keep these libraries up to date ● Libraries also have dependency on other libraries
  • 4. We’ve (php) tried to address this issue before PEAR : A Library for PHP PHP Extension and Application Repository Used by many developers Problems with PEAR ● In general, PEAR is meant to be installed on a system level. Although with some tweaking this can be avoided. However, using PEAR at a system level can make it difficult to migrate code from system to system. ● There are a TON of PEAR Libraries and not all of them are very well documented.
  • 5. Enter Composer What Does Composer Do? ● You tell Composer what libraries you want ● Composer then manages the libraries and the dependencies for those libraries ● Installs everything for you ● Creates an autoloader
  • 6. Installing Composer You can install Composer in a local directory using the command curl -s https://getcomposer.org/installer | php A more common practice is to install composer globally curl -s https://getcomposer.org/composer.phar -o $HOME/local/bin/composer chmod +x $HOME/local/bin/composer This gives you access to composer install
  • 7. Using Composer composer create-project laravel/laravel --prefer-dist The above command downloads and installs the core libraries for a Laravel Project. It also downloads and install all the dependencies such as several symfony components. End result
  • 8. The composer.json File This is where a lot of magic happens. “require” is the key to the strength of Composer. This tells composer what core libraries, and their versions, you would like to install. Composer then figures out the dependencies and their versions and installs them.
  • 9. Where do these Packages come from? Packagist Main Repository https://packagist.org/ Create your own with Satis https://github.com/composer/satis
  • 10. Autoloading index.php <?php require ‘vendor/autoload.php’; // You can now use your dependencies // without requiring them use SymfonyComponentConsoleApplication;
  • 11. Updating with Composer To add a library, you can edit the composer.json file directly or use the command-line composer require vendor/package:2.* vendor/package2:dev-master Then simply run composer update ‘composer update’ will also update all the existing packages and dependencies based on the composer.json configuration.
  • 12. Summary ● Very Simple to Install and Implement ● Cool “Magical” dependency resolution ● You can make and contribute your own packages ● Composer autoloader make life easy and is PSR compliant
  • 13. THANK YOU! Eric Van Johnson ● Twitter: @shocm ● IRC: @shocm ● eric@sdphp.org ● Website: www.shocm.com