Better Site Stacks
with Composer
Andrey “Rarst” Savchenko
Composer — Dependency Manager
Utility to consume code in projects and conventions to
publish code for it. In open, flexible, and robust manner.
getcomposer.org
Hobby — Profession
Version Control Isn’t Everything
WordPress is
145K lines
PHP code
Namespaces PHP >= 5.3
<?php
namespace Rarst\Fragment_Cache;
class Plugin extends \Pimple {
php.net/namespaces
PSR–0 Autoloading Standard
Requirements that must be adhered to for autoloader interoperability.
php-fig.org
Decoupled Frameworks
Installation
curl -sS
https://getcomposer.org/installer
| php
WordPress Stack with Composer
composer create-project
rarst/install-test
--repository-url=https://www.rarst.net
--stability dev
Sources
- direct downloads
- Subversion
- Git (+ GitHub downloads)
- Mercurial (+ Bitbucket downloads)
also PEAR and local archives
packages.json
Describes locations of packages.
composer.json
Contains information about package.
composer.lock
Captures precise state of project.
Dependencies
"require" : {
"rarst/wordpress" : ">=3.6"
}
Also `conflict`
and `suggest`
Current Challenges
- bridge to core
- access to repositories
- asset management
solidify your sites
own your code
Composer All the Things! Questions?
Rarst.net/slides/composer