Skeleton of a Derafu Library
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.jsonwith the scripts that every Derafu library has:tests,phpcs,phpcs-fix,phpstananddocs.- The tools and their configuration: PHP CS Fixer, PHPStan (level 5, over
srcandtests) 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.gitignoreand theLICENSE. - An example class with its test,
src/Teapot.phpandtests/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 issrc/Translation/ProjectTranslationResourceProvider.php, the wiring forsymfony/dependency-injectionis inresources/config/project-services.yaml, andtests/src/Translation/ProjectMessagesTest.phpaudits that every message has its translation, that the catalogue has nothing unused and that every exception is translatable. See Translation.
To use it
- Edit
composer.json: change the name, the description and the namespaces (Derafu\Project\andDerafu\TestsProject\), and change"type": "project"to"type": "library". The skeleton is aprojectso it can be created withcomposer create-project, but the library you write is alibrary. Then change the names in the files ofsrcandtests. - Rename
ProjectTranslationResourceProviderand its catalogue. - 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.
- Run
composer tests,composer phpstanandcomposer 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