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

Package development #phpday

Package development #phpday

Registering your new awesome package to packagist is easy. But what about maintainability? What dependencies should you avoid? Have you considered reducing download size? How will you keep your users up to date with changes in newer versions? How do you best handle releases? How do you manage your package to behave in an optimal way both in other people's production environment as in your local package development environment?

These and many other tips for medium to high quality packages are included in this talk.

Hannes Van De Vreken

May 17, 2016
Tweet

More Decks by Hannes Van De Vreken

Other Decks in Technology

Transcript

  1. "

  2. BEGINNER STEPS - VERSIONS Class Sdk { public function __construct(Framework\Config)

    { … } } /** * Register method. */ public function register() { // Register SDK class. $this->container->share('twilio', function () { return new Sdk($this->container->make('config')) }); }
  3. BEGINNER STEPS - VERSIONS Class Sdk { public function __construct(array

    $options) { … } } /** * Register method. */ public function register() { // Register SDK class. $this->container->share('twilio', function () { $config = $this->app->get('config'); return new Sdk($config->get('services.twilio')); }); }
  4. BEGINNER STEPS - CHANGELOG # Change Log All notable changes

    to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased][unreleased] ### Changed - Improve argument against commit logs. ## [0.0.8] - 2015-02-17 ### Changed - Update year to match in every README example. - Reluctantly stop making fun of Brits only, since most of the world writes dates in a strange way. ### Fixed - Fix typos in recent README changes. - Update outdated unreleased diff link.
  5. BEGINNER STEPS - README.MD // open an image file $img

    = Image::make('public/foo.jpg'); // resize image instance $img->resize(320, 240); // insert a watermark $img->insert('public/watermark.png'); // save image in desired format $img->save('public/bar.jpg');
  6. BEGINNER STEPS - HINT 1 $ construct generate --help Arguments:

    name The vendor/project name Options: --test (-t) Testing framework (default: "phpunit") --license (-l) License (default: "MIT") --namespace (-s) Namespace for project (default: "Vendor\\Pro --git (-g) Initialize an empty Git repo --phpcs (-p) Generate a PHP Coding Standards Fixer config --keywords (-k) Comma separated list of Composer keywords --vagrant Generate a Vagrantfile
  7. BEGINNER STEPS - HINT 2 $ studio load --help Usage:

    load <path> Arguments: path The path where the package files are located
  8. INTERMEDIATE TIPS - ENVIRONMENTS - DEV & CI not in

    production: composer require --dev also installs require-dev dependencies
  9. INTERMEDIATE TIPS - ENVIRONMENTS - CI phpunit --coverage-html=/tmp/coverage/; vs phpunit

    --coverage-clover=/tmp/coverage.xml; ocular code-coverage:upload /tmp/coverage.xml;
  10. INTERMEDIATE TIPS - CLEAN DISTS "autoload": { "psr-4": { "GuzzleHttp\\":

    "src/" } }, "autoload-dev": { "psr-4": { "GuzzleHttp\\Stubs\\": "tests/stubs/" } }
  11. INTERMEDIATE TIPS - CODE STYLE $container = new Container; $container

    = new Container(); $options = [ 'ssl' => true, 'redirects' => false, ];
  12. concept virtual package is a high level placeholder for a

    dependency on a more low level implementation STABILITY - DECOUPLING
  13. company/sdk requires (1.0.0) psr/cache-implementation provides (1.0.0) requires (1.0.0) application requires

    (x.y.z) requires (0.5.0) requires (1.0.0) cache/doctrine-adapter psr/cache requires (^1.3) doctrine/cache
  14. DECOUPLING - OTHER CASES - File system (Flysystem) - Logging

    (PSR-3) - HTTP (PSR-7) - Caching (PSR-6)