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
51
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
74
PHP and Databases
justinyost
2
36
Ansible: What Is It and What Is It Good For?
justinyost
0
24
Generators: All About the Yield
justinyost
0
11
Laravel 6: What's New and What's Changed
justinyost
0
200
Middleware: Between the Framework and the Browser
justinyost
2
68
Caching and You and You and You and You...
justinyost
0
41
Git: The Pain and the Gain
justinyost
0
100
Generators: All About the Yield
justinyost
0
160
Other Decks in Programming
See All in Programming
Deep Dive into React Stream/Serialize
mugi_uno
4
860
Jetpack Composeとデザインシステム
rmakiyama
0
230
HonoのRPCで真の型安全が欲しかった
kosei28
1
150
PHPコードの実行モデルを理解する / Understanding-the-PHP-Execution-Model
shin1x1
0
1.1k
Exploring Type-Informed Lint Rules in Rust based TypeScript Linters
unvalley
3
640
一文字エイリアスのすすめ
fujimura
0
200
TypeScriptの型とパフォーマンス (TSKaigi 2024)
ypresto
14
4.6k
WebGLで始める コンピュータグラフィックス入門
heller77
0
390
哲学史とモデリング
tanakahisateru
2
430
ペパボOpenTelemetry革命
pyama86
2
1.1k
Namespace, What and Why
tagomoris
3
700
Good first issues of TypeProf
mame
4
600
Featured
See All Featured
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
34
6.1k
Rebuilding a faster, lazier Slack
samanthasiow
74
8.3k
Principles of Awesome APIs and How to Build Them.
keavy
121
16k
Embracing the Ebb and Flow
colly
80
4.2k
StorybookのUI Testing Handbookを読んだ
zakiyama
13
4.7k
Designing Experiences People Love
moore
136
23k
How STYLIGHT went responsive
nonsquared
92
4.8k
No one is an island. Learnings from fostering a developers community.
thoeni
16
2.1k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
14
8.4k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
501
140k
Building Flexible Design Systems
yeseniaperezcruz
320
37k
Music & Morning Musume
bryan
41
5.6k
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