Mastering composer
Upcoming SlideShare
Loading in...5
×
 

Mastering composer

on

  • 2,944 views

 

Statistics

Views

Total Views
2,944
Views on SlideShare
2,912
Embed Views
32

Actions

Likes
6
Downloads
12
Comments
0

1 Embed 32

https://twitter.com 32

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Mastering composer Mastering composer Presentation Transcript

    • Mastering Composer Adán Lobato
    • What’s up! • Soy Adán Lobato • Soy de Barcelona • Soy software developer • Backend Developer en SocialPoint • Mi twitter es @adanlobato
    • Agenda • Minimum stability • Branch aliases • Semantic versioning • Private Repositories • Installers • Embedded Composer • Useful links
    • Parental Advisory
    • Minimum stability
    • Minimum stability, the problem
    • Minimum stability exposed Stable! RC “minimum-stability”: Beta Alpha Dev @stable @rc @beta @alpha @dev
    • minimum-stability, the global solution { "require": { "php": ">=5.3.3", "symfony/icu": "~1.0", "doctrine/common": "~2.2", "twig/twig": "~1.11", "psr/log": "~1.0" }, “minimum-stability”: “dev” }
    • @stability flags, the specific solution { "require": { "php": ">=5.3.3", "symfony/icu": "~1.0", "doctrine/common": “~2.2@dev", "twig/twig": "~1.11", "psr/log": "~1.0" } }
    • @stability flags, recursive stability { "require": { "php": ">=5.3.3", "symfony/icu": "~1.0", "doctrine/orm": “~2.2", "doctrine/dbal": “@dev", "twig/twig": "~1.11", "psr/log": "~1.0" } }
    • prefer-stable, the “magic” solution { "require": { "php": ">=5.3.3", "symfony/icu": "~1.0", "doctrine/common": "~2.2", "twig/twig": "~1.11", "psr/log": "~1.0" }, “prefer-stable”: true }
    • Branch aliases
    • Branch aliases, the problem
    • Branch aliases, the bad practice { "require": { “welovephp/foobar”: “dev-master” } }
    • Branch aliases, the solution { “name”: “welovephp/foobar” "extra": { "branch-alias": { "dev-master": "2.5-dev" } } }
    • Branch aliases & stability flags { "require": { “welovephp/foobar”: “2.5.*@dev” } }
    • Branch aliases, inline aliases { "require": { “welovephp/foobar”: “my-branch as 2.5-dev” } }
    • Semantic Versioning
    • Semantic versioning X.Y.Z
    • Semantic versioning X.Y.Z
    • Semantic versioning X.Y.Z
    • Semantic versioning X.Y.Z
    • Semantic versioning 1.*
    • Semantic versioning >=1.1,<2.0
    • Semantic versioning ~1.1
    • Private Repositories
    • Private Repositories, the basics { “repositories”: [ { “type”: “git”, “url”: “git@github.com/welovephp/foobar.git” } ] }
    • Private Repositories, the basics { “repositories”: [ { “type”: “git”, “url”: “git@github.com/welovephp/foobar.git” }, { “type”: “git”, “url”: “git@github.com/welovephp/foobar-bundle.git” }, { “type”: “git”, “url”: “git@github.com/welovephp/fizz.git” }, { “type”: “git”, “url”: “git@github.com/welovephp/buzz.git” }, { “type”: “git”, “url”: “git@github.com/welovephp/fizzbuzz-bundle.git” }, { “type”: “git”, “url”: “git@github.com/welovephp/qwerty.git” }, { “type”: “git”, “url”: “git@github.com/welovephp/doe.git” } ] }
    • Private Repositories, the basics
    • Private Repositories, the basics
    • Private Repositories: Satis
    • Private Repositories, Satis $ composer create-project composer/satis
    • Private Repositories, Satis // config.json { "name": "WelovePhp", "homepage": "http://packages.welovephp.es", "require-all": true, “repositories”: [ { “type”: “git”, “url”: “git@github.com/welovephp/foobar.git” }, { “type”: “git”, “url”: “git@github.com/welovephp/foobar-bundle.git” }, { “type”: “git”, “url”: “git@github.com/welovephp/fizz.git” }, { “type”: “git”, “url”: “git@github.com/welovephp/buzz.git” }, { “type”: “git”, “url”: “git@github.com/welovephp/fizzbuzz-bundle.git” }, { “type”: “git”, “url”: “git@github.com/welovephp/qwerty.git” } ] }
    • Private Repositories, Satis $ php bin/satis build config.json web/
    • Private Repositories, Satis
    • Private Repositories, Satis { "repositories": [ { "type": "composer", "url": “http://packages.welovephp.es/“ } ] }
    • Private Repositories, Satis Security: • Basic HTTP Authentication • SSH • Private network ! Updates • CRON job
    • Private Repositories: Packagist
    • Private Repositories, Packagist • Packagist is an Open Source project • It is built as a Symfony application • You can have your own private Packagist • Supports Github Webhooks
    • Private Repositories, Packagist Requirements: • MySQL • Redis • Solr • git / svn / hg
    • Private Repositories: Bottlenecks
    • Private Repositories, the bottlenecks
    • Installers
    • Installers, the official ones • Wordpress • Drupal • CakePHP • CodeIgniter • Laravel • Tons more! http://github.com/composer/installers
    • Installers, building your own installer { "name": "welovephp/blog-module", "type": “welovephp-module", "require": { “welovephp/module-installer-plugin“: "*" } }
    • Installers, building your own installer { "name": “welovephp/module-installer-plugin", "type": "composer-plugin", "autoload": { "psr-0": {"WeLovePhpComposer": "src/"} }, "extra": { "class": "WeLovePhpComposerModuleInstallerPlugin" }, "require": { "composer-plugin-api": “1.0.0" } }
    • Installers, building your own installer namespace WeLovePhpComposer; class ModuleInstallerPlugin implements PluginInterface { public function activate(Composer $composer, IOInterface $io) { $installer = new ModuleInstaller($io, $composer); $composer->getInstallationManager()->addInstaller($installer); } }
    • Installers, building your own installer namespace phpDocumentorComposer; ! class ModuleInstaller extends LibraryInstaller { public function getPackageBasePath(PackageInterface $package) { return 'welovephp/modules/'.$package->getPrettyName(); } ! public function supports($packageType) { return ‘welovephp-module' === $packageType; } }
    • Embedded Composer By Beau Simensen
    • Embedded Composer, the problem • You have an application • Your application has dependencies • Your application can be extended via third-party plugins • Those plugins depend on your app, but can have other extra dependencies • Both, app & plugins dependencies, must be installed once and be compatible between them
    • Embedded Composer, the solution We need to be able to run Composer on runtime
    • Embedded Composer & Sculpin.io
    • Commands you must know
    • diagnose $ composer diagnose Checks common errors to help debugging problems.
    • —verbose $ composer command […] -v|vv|vvv Increase output verbosity. Useful for debugging.
    • config —global $ composer config —global […] Read/Write Composer global settings.
    • global $ composer global require phpunit/phpunit Add COMPOSER_HOME/vendor/bin to PATH ! Run Composer operations globally. Useful for CLI tools.
    • status $ composer status Displays a list of dependencies that have been modified locally.
    • show $ composer show package/name Displays detailed information about a package.
    • dump-autoload —optimize $ composer dump-autoload — optimize Dumps a classmap for PSR-0 vendors.
    • Useful links
    • Useful links Composer • http://getcomposer.org/doc/ • https://github.com/composer/composer • https://packagist.org/ • #composerphp at twitter ! Composer Basics • http://www.slideshare.net/adanlobato/composer-gestor-de-dependencias-para-php • http://www.youtube.com/watch?v=U1dTiDlUUmU • http://adanlobato.github.io/composer-2013
    • Useful links Minimum stability • http://getcomposer.org/doc/04-schema.md#minimum-stability • http://getcomposer.org/doc/04-schema.md#package-links • https://igor.io/2013/02/07/composer-stability-flags.html ! Branch alias • http://getcomposer.org/doc/articles/aliases.md • https://igor.io/2013/01/07/composer-versioning.html ! Semantic versioning • http://semver.org/
    • Useful links Private Repositories • https://github.com/composer/satis • https://github.com/composer/packagist • https://help.github.com/articles/post-receive-hooks ! Installers • http://getcomposer.org/doc/articles/custom-installers.md • https://github.com/composer/installers !
    • Useful links Embedded Composer • https://speakerdeck.com/simensen/embedded-composer-sflive-portland-2013 • https://github.com/dflydev/dflydev-embedded-composer • https://github.com/sculpin !
    • That’s all folks! Questions?