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

Zero to The PHP League - The story of Plates

Zero to The PHP League - The story of Plates

It's one thing to write a quick library that you and maybe a few coworkers will only ever use. It's an entirely different thing to put your work out there for the entire PHP community to analyze, test, poke, benchmark and critique. While there is potential for this process to be incredibly rewarding it can also be quite intimidating. Wouldn't it be nice to see what this looks like before you jump in? Come see how Plates (platesphp.com) became a thing last year while at the same time learning how to make your first open-source PHP package a success.

Jonathan Reinink

November 07, 2014
Tweet

More Decks by Jonathan Reinink

Other Decks in Programming

Transcript

  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. Example of a unit test public function testSetDirectory() { $this->assertInstanceOf(

    'League\Plates\Engine', $this->engine->setDirectory(vfsStream::url('templates')) ); ! $this->assertEquals( $this->engine->getDirectory(), vfsStream::url('templates') ); }
  5. composer.json { "name": "league/plates", "description": "Plates, the native PHP template…",

    "homepage": "http://platesphp.com", "license": "MIT", "autoload": { "psr-4": { "League\\Plates\\": "src" } } }
  6. Example of DocBlocks /** * Add a new template folder

    for grouping templates into namespaces. * @param string $name * @param string $directory * @param boolean $fallback * @return Engine */ public function addFolder($name, $directory, $fallback = false) { $this->folders->add($name, $directory, $fallback); ! return $this; }
  7. composer.json { "require": { "league/plates": "3.*" } } Via a

    command composer require league/plates
  8. Project Name © Copyright your tagline goes here Topic Page

    name Page name Page name Page name Topic Page name Page name Page name Page name Topic Page name Page name Page name Page name Page name Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  9. Listen to those actually using it Lots of people will

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

    someone with a vested interest.