Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Composer: Modern PHP Package Management
Search
Justin Yost
April 08, 2016
Programming
0
55
Composer: Modern PHP Package Management
Justin Yost
April 08, 2016
Tweet
Share
More Decks by Justin Yost
See All by Justin Yost
Laravel 6, 7 and Other Goodies
justinyost
2
87
PHP and Databases
justinyost
2
50
Ansible: What Is It and What Is It Good For?
justinyost
0
43
Generators: All About the Yield
justinyost
0
11
Laravel 6: What's New and What's Changed
justinyost
0
220
Middleware: Between the Framework and the Browser
justinyost
2
96
Caching and You and You and You and You...
justinyost
0
65
Git: The Pain and the Gain
justinyost
0
140
Generators: All About the Yield
justinyost
0
270
Other Decks in Programming
See All in Programming
旅行プランAIエージェント開発の裏側
ippo012
2
780
CloudflareのChat Agent Starter Kitで簡単!AIチャットボット構築
syumai
2
370
Azure SRE Agentで運用は楽になるのか?
kkamegawa
0
1.2k
AWS発のAIエディタKiroを使ってみた
iriikeita
1
150
兎に角、コードレビュー
mitohato14
0
170
JSONataを使ってみよう Step Functionsが楽しくなる実践テクニック #devio2025
dafujii
0
260
サーバーサイドのビルド時間87倍高速化
plaidtech
PRO
0
690
実用的なGOCACHEPROG実装をするために / golang.tokyo #40
mazrean
1
140
オープンセミナー2025@広島LT技術ブログを続けるには
satoshi256kbyte
0
150
Trem on Rails - Prompt Engineering com Ruby
elainenaomi
1
100
Langfuseと歩む生成AI活用推進
licux
3
320
さようなら Date。 ようこそTemporal! 3年間先行利用して得られた知見の共有
8beeeaaat
1
800
Featured
See All Featured
The Power of CSS Pseudo Elements
geoffreycrofte
77
5.9k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
36
2.5k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
31
2.2k
A designer walks into a library…
pauljervisheath
207
24k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
11
1.1k
Into the Great Unknown - MozCon
thekraken
40
2k
Music & Morning Musume
bryan
46
6.8k
A Modern Web Designer's Workflow
chriscoyier
696
190k
The Language of Interfaces
destraynor
160
25k
How to Think Like a Performance Engineer
csswizardry
26
1.9k
Agile that works and the tools we love
rasmusluckow
330
21k
Transcript
Composer: Modern PHP Package Management Justin Yost Web Developer at
Loadsys
What is Composer? —Composer is a modern PHP Dependency Management
Tool
What is Dependency Management? —Install Stuff —Everyone else installs same
version of stuff
Why Do I Care? —Multiple teammates —Install multiple versions on
your machine —Easily stay up to date —Build new projects with Awesome Framework
Requirements —PHP 5.3.2+
Install Mac: php composer-setup.php --install-dir=bin --filename=composer mv composer.phar /usr/local/bin/composer Windows:
look in the docs
What Now? —Now, we can install packages pretty easily
Example
composer require rych/random
require __DIR__ . '/vendor/autoload.php'; $random = new Rych\Random\Random(); $randomInt =
$random->getRandomInteger(1, 100); echo $randomInt . "\r\n";
Where should you use Composer —Everywhere you have a dependency
as part of your PHP projects —Everywhere you have a shared PHP project
What all can Composer do? —It doesn't have to be
PHP —Loadsys has a suite of shell scripts managed via Composer —github.com/loadsys/CakePHP-Shell-Scripts
What all can Composer do? —It doesn't have to be
public facing —Composer will hook into private repositories
What all can Composer do? —The project doesn't even have
to use Composer itself —Composer will install Git/SVN/Mercurial/PEAR backed projects by itself
What all can Composer do? —Install Dependencies for Dev Only
—composer require --dev {vendor/package} —composer install --dev/--no-dev
What all can Composer do? —PHP Version/Extension Requirements "require": {
"php": ">=5.6.0", "ext-openssl": "*" }
What all can Composer do? —SubDependencies —Example chain: symfony/symfony ->
doctrine/common -> doctrine/inflector -> php >=5.3.2
What all can Composer do? —SubDependencies in DevMode —Only installs
top level dev dependencies —Example chain: symfony/symfony -> cache/integration- tests -> psr/cache -> php: >=5.3.0
What all can Composer do? —Lock to Major/Minor/Patch Releases vendor/package:
3.* vendor/package: 3.0.* vendor/package: ~1.2 vendor/package: ~1.2.3 vendor/package: ^1.2.3 vendor/package: ^0.3
What all can Composer do? —Suggest other packages "suggest": {
"vendor/package": "Allow you to do other awesome thing.", },
What all can Composer do? —List Meta Information for Package
"homepage", "license", "authors", "support", "keywords", "description",
What all can Composer do? —Replace other packages "replace": {
"vendor/package": "self.version" }
What all can Composer do? —Conflicts "conflict": { "vendor/package": "1.2.3"
}
What all can Composer do? —Install SubTypes "type": "library", "type":
"project", "type": "metapackage",
What all can Composer do? —Install Custom Types —https://github.com/composer/installers "type":
"wordpress-plugin", "require": { "composer/installers": "~1.0" }
What all can Composer do? —Install Specific Branches "require": {
"vendor/package": "dev-bugfixes" }
Example
Composer Create Project composer create-project —create-project is pretty unique to
Composer —Clones a package, installs dependencies and run scripts for setup, etc
Example
Packagist —Packagist is a repository of Composer Packages for the
PHP Community —Packagist is open source and you can add your own packages
Publish your own stuff on Packagist —Code
ToranProxy —Internal version of Packagist —Provides dupes of public packages
—Provides hosting for internal only packages
Upgrade Your Development Process —Composer will make your projects easier
to manage —Composer will make dependencies less of a hassle —Composer will make deployments simpler and easier
Composer Workflow —composer require —composer install —composer update —composer remove
Final Thoughts —Composer is PHP's way of handling dependency management
—Composer is pretty easy to get started with —Publish your stuff with Composer/Packagist
Thanks/Questions? —twitter.com/justinyost —github.com/justinyost —justinyost.com —lynda.com/justinyost