---
title: "Library Skeleton"
description: "Skeleton of a Derafu Library"
type: "docs"
category: "doc"
tags: [php]
authors: [Anonymous]
date: "2026-10-08"
last_update: "2026-10-08"
time_minutes: 2
draft: false
unlisted: false
url: "https://www.derafu.dev/docs/core/library-skeleton"
---

# Skeleton of a Derafu Library

[![GitHub](https://img.shields.io/badge/github-derafu%2Flibrary--skeleton-blue?logo=github)](https://github.com/derafu/library-skeleton)

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

```shell
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](https://www.derafu.dev/docs/core/library-skeleton/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](https://www.derafu.dev/docs/core/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`](https://www.derafu.dev/docs/core/foundation), and it has no templates, `public/` or assets. To start a web site use [`derafu/website-skeleton`](https://www.derafu.dev/docs/core/website-skeleton).


## Pages in this section

- [Code Quality](https://www.derafu.dev/docs/core/library-skeleton/code-quality)

---
Last updated on 08/10/2026
#php
