Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

Phil Sturgeon Framework Interoperability Advocate

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

How to successfully release an open-source PHP package (and become a better developer for it)

Slide 7

Slide 7 text

1. Make 2. Market 3. Maintain The goods

Slide 8

Slide 8 text

Things to consider before you start Why you should and why you shouldn’t.

Slide 9

Slide 9 text

Does it exist already? Don’t clone, send pull requests instead.

Slide 10

Slide 10 text

Share your unique way of solving a problem Push the status quo.

Slide 11

Slide 11 text

Do you have the time? Releasing open source code requires a time commitment.

Slide 12

Slide 12 text

You will meet people Yay for nerd friends!

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

1. Make

Slide 15

Slide 15 text

Design an API developers will want to use The cornerstone to a successful package.

Slide 16

Slide 16 text

// 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

Slide 17

Slide 17 text

Mail::send('emails.welcome', $data, function ($message) { $message->subject('Welcome!') ->from('[email protected]', 'John Doe') ->to('[email protected]') ->attach('document.pdf'); }); Send an email with Laravel

Slide 18

Slide 18 text

Name things right It’s easy, like cache validation.

Slide 19

Slide 19 text

// 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

Slide 20

Slide 20 text

Have a clear focus Pull in other libraries when needed.

Slide 21

Slide 21 text

Utilize common design patterns Techniques like dependency injection make your library easier use, maintain, read and test.

Slide 22

Slide 22 text

Break apart large classes Create more focused classes, and more of them.

Slide 23

Slide 23 text

Framework agnostic Don’t limit yourself to just one framework.

Slide 24

Slide 24 text

What versions of PHP should I support? Is PHP 5.3 worth the effort?

Slide 25

Slide 25 text

Source code on GitHub Sorry Bitbucket, Google Code & SourceForge.

Slide 26

Slide 26 text

Write tests Automated tests allow you to make stress-free changes.

Slide 27

Slide 27 text

Composer & Packagist The primary delivery mechanism for your library.

Slide 28

Slide 28 text

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" } } }

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

.gitattributes /tests export-ignore /.gitattributes export-ignore /.gitignore export-ignore /.scrutinizer.yml export-ignore /.travis.yml export-ignore /phpunit.xml export-ignore

Slide 32

Slide 32 text

Semantic Versioning Allows developers to upgrade versions safely. MAJOR.MINOR.PATCH BREAKING.NEW-FEATURES.BUG-FIXES

Slide 33

Slide 33 text

Coding Standards Adhere to PSR-2 as the coding style guide.

Slide 34

Slide 34 text

DocBlocks Allows for automated API documentation.

Slide 35

Slide 35 text

Continuous Integration Automate tests, PSR compliance checks, code coverage analysis & more.

Slide 36

Slide 36 text

Have a license An important step to protect your hard work.

Slide 37

Slide 37 text

Contributor instructions Help them, help you!

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

2. Market

Slide 40

Slide 40 text

Choosing a name Memorable, short and cool (without being too hipster).

Slide 41

Slide 41 text

The documentation Your most important marketing tool.

Slide 42

Slide 42 text

“Read the code” is an acceptable answer to“Where are the docs?” Documentation myth #1

Slide 43

Slide 43 text

Documentation myth #2 “Auto-generated docs are good enough”

Slide 44

Slide 44 text

“All you need a README file” Documentation myth #3

Slide 45

Slide 45 text

“Documentation is easy.” Documentation myth #4

Slide 46

Slide 46 text

Documentation “must- haves” How to do documentation right!

Slide 47

Slide 47 text

The elevator speech What it is and why it matters, in 160 characters or less.

Slide 48

Slide 48 text

The simple example Show me the code!!!

Slide 49

Slide 49 text

Installation instructions Make it easy for someone to get started.

Slide 50

Slide 50 text

$ composer require league/fractal Via Composer

Slide 51

Slide 51 text

Keep a changelog Include upgrade instructions for backwards breaking changes.

Slide 52

Slide 52 text

Links to source & author This is open source after all, make yourself available!

Slide 53

Slide 53 text

Badges! Badges help full in real-time information about your project.

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

Some helpful design tools Just a few of my favourites.

Slide 63

Slide 63 text

Tell people! Reddit Twitter Hacker News SitePoint phpweekly.com phpdeveloper.org

Slide 64

Slide 64 text

3. Maintain

Slide 65

Slide 65 text

Watch it spread See how your package is actually being used in the real world.

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

No content

Slide 69

Slide 69 text

Issues and Pull Requests Open source collaboration is amazing.

Slide 70

Slide 70 text

Dealing with strong personalities Sometimes open source collaboration can suck.

Slide 71

Slide 71 text

Listen to those actually using it Lots of people will have opinions, but have they ever used your package?

Slide 72

Slide 72 text

Dealing with backwards compatibility How to make improvements when they will break existing code.

Slide 73

Slide 73 text

What to do when you lose interest Pass off to someone with a vested interest.

Slide 74

Slide 74 text

Thanks! Follow me on Twitter at @philsturgeon