×
Copy
Open
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
Package development For PHP and Laravel
Slide 2
Slide 2 text
Hi, my name is Hannes.
Slide 3
Slide 3 text
• Belgium • Developer • Laravel since 4.0.0-BETA3 • @hannesvdvreken ABOUT ME
Slide 4
Slide 4 text
Laravel Brussels
Slide 5
Slide 5 text
Package development
Slide 6
Slide 6 text
37 031 packages registered on packagist.org
Slide 7
Slide 7 text
• Stand out • What not? • For who? PACKAGE DEVELOPMENT
Slide 8
Slide 8 text
• Required steps • Recommended steps • Framework support STEPS
Slide 9
Slide 9 text
1. Required steps
Slide 10
Slide 10 text
https:/ /getcomposer.org
Slide 11
Slide 11 text
• Setup folder structure REQUIRED STEPS - COMPOSER
Slide 12
Slide 12 text
REQUIRED STEPS - COMPOSER ! / |-- src | |-- Foo.php | +-- Bar.php |-- tests | |-- FooTest.php | +-- BarTest.php +-- composer.json
Slide 13
Slide 13 text
• Setup autoloading REQUIRED STEPS - COMPOSER
Slide 14
Slide 14 text
{ "name": "vendor/package", "description": "short desc", "license": "MIT", "type": "library", "autoload": { "psr-4": { "Vendor\\Package\\": "src/" } } }
Slide 15
Slide 15 text
https:/ /packagist.org
Slide 16
Slide 16 text
• Login | Create a new account • Submit package REQUIRED STEPS - PACKAGIST
Slide 17
Slide 17 text
No content
Slide 18
Slide 18 text
https:/ /packagist.org/packages/vendor/package
Slide 19
Slide 19 text
http:/ /git-scm.com/book
Slide 20
Slide 20 text
• git tag • version number • message • signed with identity • ref REQUIRED STEPS - VERSIONING - GIT
Slide 21
Slide 21 text
• semver.org • {major}.{minor}.{bug} REQUIRED STEPS - VERSIONING - SEMVER
Slide 22
Slide 22 text
• laravel/framework 4.2.* is 4.2.8 • laravel/framework 4.1.* is 4.1.30 REQUIRED STEPS - VERSIONING - SEMVER
Slide 23
Slide 23 text
• GitHub → Packagist • https:/ /github.com/ username/repo/settings/hooks REQUIRED STEPS - VERSIONING - WEB HOOK
Slide 24
Slide 24 text
No content
Slide 25
Slide 25 text
No content
Slide 26
Slide 26 text
No content
Slide 27
Slide 27 text
"require": { "vendor/package": "1.0.*" }
Slide 28
Slide 28 text
• composer.json • packagist • versioning REQUIRED STEPS - RECAP
Slide 29
Slide 29 text
2. Recommended steps
Slide 30
Slide 30 text
Testing
Slide 31
Slide 31 text
• Prove your code • Prove other people’s code • Documentation RECOMMENDED - TESTING - REASONS
Slide 32
Slide 32 text
• PHPUnit • PHPSpec • PHPUnit Mocks • Mockery RECOMMENDED - TESTING - TOOLS
Slide 33
Slide 33 text
• Custom mocks • Only test your own code • Keep it simple RECOMMENDED - TESTING - PITFALLS
Slide 34
Slide 34 text
https:/ /travis-ci.org
Slide 35
Slide 35 text
language: php php: - 5.4 - 5.5 - 5.6 - hhvm before_script: - composer self-update - composer install --prefer-source --dev script: - phpunit
Slide 36
Slide 36 text
POST /v3/repos/:owner/:repo/statuses/:sha Host: api.github.com RECOMMENDED - TESTING - TRAVIS
Slide 37
Slide 37 text
{ "status": "success", "context": "continuous-integration/travis-ci", "description": "The Travis CI build passed", "target_url": "https://travis-ci.org/username/ repo/builds/12345678" } RECOMMENDED - TESTING - TRAVIS
Slide 38
Slide 38 text
RECOMMENDED - TESTING - TRAVIS
Slide 39
Slide 39 text
RECOMMENDED - TESTING - TRAVIS
Slide 40
Slide 40 text
https:/ /coveralls.io
Slide 41
Slide 41 text
{ "name": "vendor/package", "description": "short desc", "license": "MIT", "type": "library", "autoload": { "psr-4": { "Vendor\\Package\\": "src/" } }, "require-dev": { "satooshi/php-coveralls": "0.6.*" } }
Slide 42
Slide 42 text
language: php php: - 5.4 - 5.5 - 5.6 - hhvm before_script: - composer self-update - composer install --prefer-source --dev script: - phpunit --coverage-clover build/logs/clo after_success: - php vendor/bin/coveralls -v
Slide 43
Slide 43 text
RECOMMENDED - TESTING - COVERAGE
Slide 44
Slide 44 text
• PHPCS • PHPMD RECOMMENDED - TESTING - EXTRA
Slide 45
Slide 45 text
Documentation
Slide 46
Slide 46 text
• Brief explanation: what/how RECOMMENDED - README
Slide 47
Slide 47 text
• Code examples RECOMMENDED - README
Slide 48
Slide 48 text
• License • Contributing • Website RECOMMENDED - README
Slide 49
Slide 49 text
RECOMMENDED - README - BADGES http:/ /shields.io
Slide 50
Slide 50 text
[] (https://travis-ci.org/username/repo) RECOMMENDED - README - BADGES
Slide 51
Slide 51 text
RECOMMENDED - README - BADGES
Slide 52
Slide 52 text
RECOMMENDED - DOCUMENTATION - EXTRA • CONTRIBUTING.md • CHANGELOG.md • UPGRADE.md
Slide 53
Slide 53 text
RECOMMENDED - RECAP • Add tests • Prove they cover good % • Documentation
Slide 54
Slide 54 text
3. Framework support
Slide 55
Slide 55 text
FRAMEWORK SUPPORT • Laravel wrapper packages
Slide 56
Slide 56 text
FRAMEWORK SUPPORT - EXAMPLES • Rocketeer, Envoy • AWS PHP SDK • Clockwork
Slide 57
Slide 57 text
No content
Slide 58
Slide 58 text
No content
Slide 59
Slide 59 text
FRAMEWORK SUPPORT - LARAVEL • ServiceProvider • Facade
Slide 60
Slide 60 text
FRAMEWORK SUPPORT - LARAVEL - ARTISAN • config:publish • asset:publish • view:publish • migrate --package="vendor/pack"
Slide 61
Slide 61 text
FRAMEWORK SUPPORT - LARAVEL • workbench • orchestra/testbench
Slide 62
Slide 62 text
FRAMEWORK SUPPORT - RECAP • Framework independent • Support classes in same package
Slide 63
Slide 63 text
• Publishing is easy • Document your packages • I want you to develop packages RECAP
Slide 64
Slide 64 text
Thanks! @hannesvdvreken https:/ /joind.in/11678
Slide 65
Slide 65 text
• https:/ /youtu.be/jV4iPSHbonk • https:/ /getcomposer.org • http:/ /www.php-fig.org/psr/psr-4/ • https:/ /packagist.org/statistics • http:/ /git-scm.com/book/en/Git-Basics-Tagging • https:/ /travis-ci.org • https:/ /coveralls.io • https:/ /developer.github.com/v3/repos/statuses • https:/ /shields.io • http:/ /laravel.com/docs/packages • https:/ /github.com/orchestral/testbench REFERENCES