Composer Tutorial (PHP Hampshire Sept 2013)
-
Upload
james-titcumb -
Category
Technology
-
view
2.957 -
download
3
description
Transcript of Composer Tutorial (PHP Hampshire Sept 2013)
![Page 1: Composer Tutorial (PHP Hampshire Sept 2013)](https://reader033.fdocuments.us/reader033/viewer/2022051616/554a3fc8b4c90582328b509c/html5/thumbnails/1.jpg)
ComposerA Lightning Talk by James Titcumb
![Page 2: Composer Tutorial (PHP Hampshire Sept 2013)](https://reader033.fdocuments.us/reader033/viewer/2022051616/554a3fc8b4c90582328b509c/html5/thumbnails/2.jpg)
● Your app depends on libraries● Maintenance - keeping up to date● Libraries depend on other libraries● Could result in conflicting code - MESS
The Problems
Guzzle Twig PSR-3
Pimple
![Page 3: Composer Tutorial (PHP Hampshire Sept 2013)](https://reader033.fdocuments.us/reader033/viewer/2022051616/554a3fc8b4c90582328b509c/html5/thumbnails/3.jpg)
nooooo!!!!!!
![Page 4: Composer Tutorial (PHP Hampshire Sept 2013)](https://reader033.fdocuments.us/reader033/viewer/2022051616/554a3fc8b4c90582328b509c/html5/thumbnails/4.jpg)
Nils Adermann (phpBB)Jordi Boggiano (SF2, Doctrine)
![Page 5: Composer Tutorial (PHP Hampshire Sept 2013)](https://reader033.fdocuments.us/reader033/viewer/2022051616/554a3fc8b4c90582328b509c/html5/thumbnails/5.jpg)
Say hello to...
![Page 6: Composer Tutorial (PHP Hampshire Sept 2013)](https://reader033.fdocuments.us/reader033/viewer/2022051616/554a3fc8b4c90582328b509c/html5/thumbnails/6.jpg)
What Does It Do?
● You tell it what libraries you want● Manages dependencies● Installs them (downloads them)● Creates an autoloader
![Page 7: Composer Tutorial (PHP Hampshire Sept 2013)](https://reader033.fdocuments.us/reader033/viewer/2022051616/554a3fc8b4c90582328b509c/html5/thumbnails/7.jpg)
Installing composer.phar
$ curl -sS https://getcomposer.org/installer | php
#!/usr/bin/env php
All settings correct for using Composer
Downloading...
Composer successfully installed to: composer.phar
Use it: php composer.phar
$
![Page 8: Composer Tutorial (PHP Hampshire Sept 2013)](https://reader033.fdocuments.us/reader033/viewer/2022051616/554a3fc8b4c90582328b509c/html5/thumbnails/8.jpg)
composer.json
{
"require": {
"php": ">= 5.3",
"symfony/console": "2.3.*"
}
}
![Page 9: Composer Tutorial (PHP Hampshire Sept 2013)](https://reader033.fdocuments.us/reader033/viewer/2022051616/554a3fc8b4c90582328b509c/html5/thumbnails/9.jpg)
Now Install$ php composer.phar install
Loading composer repositories with package information
Installing dependencies (including require-dev)
- Installing symfony/console (v2.3.4)
Downloading: 100%
Writing lock file
Generating autoload files
$
![Page 10: Composer Tutorial (PHP Hampshire Sept 2013)](https://reader033.fdocuments.us/reader033/viewer/2022051616/554a3fc8b4c90582328b509c/html5/thumbnails/10.jpg)
Where Did You Come From?
● Packagist - main repository
● You can make your own (Satis)
![Page 11: Composer Tutorial (PHP Hampshire Sept 2013)](https://reader033.fdocuments.us/reader033/viewer/2022051616/554a3fc8b4c90582328b509c/html5/thumbnails/11.jpg)
Autoloading!
index.php
<?php
require 'vendor/autoload.php';
// You can use your dependencies
// without requiring them all the time
use Symfony\Component\Console\Application;
![Page 12: Composer Tutorial (PHP Hampshire Sept 2013)](https://reader033.fdocuments.us/reader033/viewer/2022051616/554a3fc8b4c90582328b509c/html5/thumbnails/12.jpg)
60 seconds Live Demo (!)
● Download Composer● Create composer.json● Run Composer install● Write index.php
![Page 13: Composer Tutorial (PHP Hampshire Sept 2013)](https://reader033.fdocuments.us/reader033/viewer/2022051616/554a3fc8b4c90582328b509c/html5/thumbnails/13.jpg)
● It’s very simple● Magical dependencies (recursively)● You can make your own packages!● Composer autoloader rocks (PSR-0/4)● Simplifies deployment!
● Get it here:
Summary
getcomposer.org
![Page 14: Composer Tutorial (PHP Hampshire Sept 2013)](https://reader033.fdocuments.us/reader033/viewer/2022051616/554a3fc8b4c90582328b509c/html5/thumbnails/14.jpg)
Thanks!
@asgrimgithub.com/asgrim