Skeleton of a Derafu Library

GitHub

derafu/library-skeleton is the starting point of a new Derafu library. Everything is in its repository: there is no installer.

composer create-project derafu/library-skeleton my-library --stability=dev

What it has

  • composer.json with the scripts that every Derafu library has: tests, phpcs, phpcs-fix, phpstan and docs.
  • The tools and their configuration: PHP CS Fixer, PHPStan (level 5, over src and tests) and PHPUnit (strict: a warning, a risky test or a deprecation fails the run, and every test says what it covers). See Code Quality.
  • The CI (.github/workflows/ci.yml), the .gitignore and the LICENSE.
  • An example class with its test, src/Teapot.php and tests/src/TeapotTest.php. Delete them when the library has code of its own.
  • The pattern of the translations: the exceptions are translatable, the Spanish catalogue is in resources/translations/errors+intl-icu.es.php, the provider is src/Translation/ProjectTranslationResourceProvider.php, the wiring for symfony/dependency-injection is in resources/config/project-services.yaml, and tests/src/Translation/ProjectMessagesTest.php audits that every message has its translation, that the catalogue has nothing unused and that every exception is translatable. See Translation.

To use it

  1. Edit composer.json: change the name, the description and the namespaces (Derafu\Project\ and Derafu\TestsProject\), and change "type": "project" to "type": "library". The skeleton is a project so it can be created with composer create-project, but the library you write is a library. Then change the names in the files of src and tests.
  2. Rename ProjectTranslationResourceProvider and its catalogue.
  3. Write the library. The message of an exception is a literal in English (the id of the translation) with its parameters, and has its entry in the catalogue.
  4. Run composer tests, composer phpstan and composer phpcs.

A site is not a library

derafu/library-skeleton does not depend on derafu/foundation, and it has no templates, public/ or assets. To start a web site use derafu/website-skeleton.

On this page

#php
Last updated on 08/10/2026 by Anonymous