Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building Extraordinary Packages

Building Extraordinary Packages

Back in the day, we had PEAR packages. These were often very well written, but due to PEARs lack of popularity we ended up just using mega-frameworks and writing bundles, modules, cells and sparks for that framework. Since then Composer has been a bit of a savior, but the way in which we make these packages is still new and scary.

There are a lot of talks about building good code, and writing OOP well, but how do you make a Composer package that is as high in quality as you can? Things like SemVer, avoiding NIH syndrome verses knowing WHEN to fork or make a new package, responsible deprecation and loads more.

The League of Extraordinary Packages is a group of developers who have banded together to build solid, well tested PHP packages using modern coding standards. The name might be a little silly, but the group dedicates itself to active maintenance, handing over projects when a lead has to step aside, working together and an absolute dedication to following and supporting standards.

Phil Sturgeon

May 31, 2015

More Decks by Phil Sturgeon

Other Decks in Programming


  1. You will learn, a lot Contributing an open source package

    will push you as a developer. GIT GitHub Issues Pull Requests Rebasing Testing TDD Semantic Versioning Code Coverage Composer Packagist Coding Standards PHP-FIG PSR DocBlocks Travis Scrutinizer CI Changelogs Licensing Code Sniffer Jekyll Shields.io Code Quality Milestones Releases Dependency Injection Coupling Cohesion
  2. // Create the transport $transport = Swift_SmtpTransport::newInstance('smtp.example.org', 25); $transport->setUsername('your username');

    $transport->setPassword('your password'); // Create the email $message = Swift_Message::newInstance(); $message->setSubject('Your subject'); $message->setFrom(array('[email protected]' => 'John Doe')); $message->setTo(array('[email protected]')); $message->setBody('Here is the message itself'); $message->attach(Swift_Attachment::fromPath('document.pdf')); // Send the email $mailer = Swift_Mailer::newInstance($transport); $result = $mailer->send($message); Send an email with Swift
  3. // Current library $whoops = new Whoops\Run; $whoops->pushHandler(new Whoops\Handler\PrettyPageHandler); $whoops->register();

    // Better class name $whoops = new Whoops\ErrHandler; $whoops->pushHandler(new Whoops\Handler\PrettyPageHandler); $whoops->register(); // Better example variable $errHandler = new Whoops\ErrHandler; $errHandler->pushHandler(new Whoops\Handler\PrettyPageHandler); $errHandler->register(); Whoops
  4. composer.json { "name": "league/fractal", "description": "Handle the output of complex

    data structures ready for API output.", "homepage": "http://fractal.thephpleague.com/", "license": "MIT", "author": [{ "name": “Phil Sturgeon”, "email": “[email protected]" }], "autoload": { "psr-4": { "League\\Fractal\\": "src" } } }
  5. Listen to those actually using it Lots of people will

    have opinions, but have they ever used your package?
  6. What to do when you lose interest Pass off to

    someone with a vested interest.