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

Package Development Brussels-PHP

Package Development Brussels-PHP

Intermediate and advanced tips for PHP package development. Laracon EU try-out.

Rates on https://joind.in/talk/view/14898

Hannes Van De Vreken

July 22, 2015
Tweet

More Decks by Hannes Van De Vreken

Other Decks in Technology

Transcript

  1. - Naming - Setup github, packagist & ci - Version

    your code - Write tests BEGINNER STEPS - RECAP
  2. - README - Code samples - Badges (stable, coverage, …)

    - License - Changelog BEGINNER STEPS - RECAP
  3. BEGINNER STEPS - HINT $ vendor/bin/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
  4. INTERMEDIATE TIPS - CLEAN DISTS "autoload": { "psr-4": { "GuzzleHttp\\":

    "src/" } }, "autoload-dev": { "psr-4": { "GuzzleHttp\\Stubs\\": "tests/stubs/" } }
  5. DECOUPLING - HTTP EXAMPLE /** * @param \Http\Adapter\HttpAdapter $adapter */

    public function __construct(HttpAdapter $adapter) { $this->adapter = $adapter; }
  6. DECOUPLING - HTTP EXAMPLE /** * @param \Psr\Http\Message\RequestInterface $request *

    @return \Psr\Http\Message\ResponseInterface */ private function send(RequestInterface $request) { return $this->adapter->send($request); }
  7. DECOUPLING - INTERFACES concept virtual package is a placeholder to

    be able to define a dependency on some implementation