Composer has triggered a renaissance in the PHP community, it has changed the way we deal with other people’s code and it has changed the way we share our code. We are all slowly moving to using Composer, from Wordpress to Joomla and Drupal and frameworks in between. But many of us mistreat composer, follow outdated practices or simply lack a few tricks. In this session i’ll get you the low down on how to use composer the right way.
15. {
"require": {
"monolog/monolog": “2.0”
}
}
{
"name": “monolog/monolog”
...
}
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
!
Problem 1
- The requested package monolog/monolog could not be found in any version, there may be a typo in the package name.
!
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.
!
Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
!
Installation failed, reverting ./composer.json to its original content.
photo: 18millionpixels
16. {
"require": {
___
~1.1
"monolog/monolog": “2.0”
}
}
{
"name": “monolog/monolog”
...
}
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
!
Problem 1
- The requested package monolog/monolog could not be found in any version, there may be a typo in the package name.
!
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.
!
Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
!
Installation failed, reverting ./composer.json to its original content.
photo: 18millionpixels
17. {
"require": {
___
~1.1
"monolog/monolog": “2.0”
}
}
{
"name": “monolog/monolog”
...
}
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
!
Problem 1
- Installing psr/log (1.0.0)
Loading from cache
!
- Installing monolog/monolog (1.11.0)
- The requested package monolog/monolog could not be found in any version, there may be a typo in the package name.
!
Downloading: 100%
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
!
monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
[...]
monolog/see <https://monolog groups.suggests google.installing com/d/ext-topic/mongo composer-(Allow dev/_sending g3ASeIFlrc/log messages discussion> to a for MongoDB more server)
details.
monolog/!
monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/Read <http://monolog getcomposer.suggests org/installing doc/articles/rollbar/troubleshooting.rollbar (Allow md> sending for further log messages common to problems.
Rollbar)
!
Writing lock file
Installation Generating autoload failed, files
reverting ./composer.json to its original content.
photo: 18millionpixels
30. pick your own
unique vendor
Library Publisher Unique vendor names
31. or join a collective
Library Publisher Unique vendor names
32. ! README
% CHANGELOG
& LICENSE
Library Publisher What’s in your library?
33. ! README
% CHANGELOG
& LICENSE
' What problem does it solve?
' Usage examples
' Install instructions
' How can I contribute?
Library Publisher What’s in your library?
34. ! README
% CHANGELOG
& LICENSE
' What problem does it solve?
' Usage examples
' Install instructions
' How can I contribute?
' List relevant changes
' Make BC breaks prominent
' Show examples of how to upgrade
Library Publisher What’s in your library?
35. ! README
% CHANGELOG
& LICENSE
' What problem does it solve?
' Usage examples
' Install instructions
' How can I contribute?
' List relevant changes
' Make BC breaks prominent
' Show examples of how to upgrade
' Pick one that reflects your values
' choosealicense.com can help
Library Publisher What’s in your library?
36. 1 . 2 . 3
major minor patch
Library Publisher Semantic Versioning
37. 1 . 2 . 3
major minor patch
Library Publisher Semantic Versioning
Bug Fixes
38. New Features Bug Fixes
1 . 2 . 3
major minor patch
Library Publisher Semantic Versioning
39. API / BC Breaks New Features Bug Fixes
1 . 2 . 3
major minor patch
Library Publisher Semantic Versioning
101. ,
$ composer install --prefer-dist --no-dev —optimize-autoloader
1 Install same versions
1 Uses information defined in the composer.lock file
Library Consumer Composer and deployments
103. ,
$ composer install --prefer-dist --no-dev —optimize-autoloader
1 Downloads distribution packages
1 Can use local cache for previously downloaded
1 No git required
Library Consumer Composer and deployments
107. ,
$ composer install --prefer-dist --no-dev —optimize-autoloader
1 Generates classmap from PSR-0/4 autoloaders
1 Speeds up autoloading
Library Consumer Composer and deployments
108. Tip
$ composer licenses
!
Name: __root__
Version: 1.0.0
Licenses: none
Dependencies:
!
doctrine/annotations v1.2.1 MIT
doctrine/cache v1.3.1 MIT
doctrine/collections v1.2 MIT
doctrine/common v2.4.2 MIT
doctrine/inflector v1.0 MIT
doctrine/lexer v1.0 MIT
psr/log 1.0.0 MIT
symfony/symfony v2.5.6 MIT
twig/twig v1.16.2 BSD-3-Clause
Library Consumer Licensing
109. Satis and Toran
Library Consumer Private Packages and Proxy
110. composer Packagist
"
Your application
$
Public
Repository
#
Library Consumer Private Packages and Proxy
111. composer
Packagist
"
Your application
$
Public
Repository
#
Satis / Toran
"
Private
Repository
2
proxy
Library Consumer Private Packages and Proxy
112. toranproxy.com
private repos, automatic packagist proxy
and support composer development
Library Consumer Private Packages and Proxy
113. How many of you?
$ composer require jquery/jquery
Library Consumer Tooling