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.
14. {
"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
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.
___
~1.1
photo: 18millionpixels
16. {
"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.
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing psr/log (1.0.0)
Loading from cache
- Installing monolog/monolog (1.11.0)
Downloading: 100%
monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
[...]
monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server)
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
Writing lock file
Generating autoload files
___
~1.1
photo: 18millionpixels
38. README!
CHANGELOG%
LICENSE&
Library Publisher What’s in your library?
' List relevant changes
' Make BC breaks prominent
' Show examples of how to upgrade
' What problem does it solve?
' Usage examples
' Install instructions
' How can I contribute?
39. README!
CHANGELOG%
LICENSE&
Library Publisher What’s in your library?
' List relevant changes
' Make BC breaks prominent
' Show examples of how to upgrade
' Pick one that reflects your values
' choosealicense.com can help
' What problem does it solve?
' Usage examples
' Install instructions
' How can I contribute?
106. Library Consumer Composer and deployments
$ composer install --prefer-dist --no-dev --optimize-autoloader
,
- Install same versions
- Uses information defined in the composer.lock file
108. $ composer install --prefer-dist --no-dev --optimize-autoloader
Library Consumer Composer and deployments
,
- Downloads distribution packages
- Can use local cache for previously downloaded
- No git required
112. $ composer install --prefer-dist --no-dev --optimize-autoloader
Library Consumer Composer and deployments
,
- Generates classmap from PSR-0/4 autoloaders
- Speeds up autoloading
113. Library Consumer Licensing
$ 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
Tip
116. Library Consumer Simulating Environments
"config": {
"platform": {
"php": “5.6.2”,
“ext-mongodb”: “1.1”
}
},
Tip
Production
Server
.
Development
Server
.PHP
7.0
PHP
5.6