PHPackages                             luccpl/sonata - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. luccpl/sonata

ActiveLibrary

luccpl/sonata
=============

v0.2.1(8mo ago)01.0kMITPHP

Since May 27Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/Luc-cpl/sonata)[ Packagist](https://packagist.org/packages/luccpl/sonata)[ RSS](/packages/luccpl-sonata/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (9)Versions (5)Used By (0)

Sonata for Orkestra
===================

[](#sonata-for-orkestra)

Sonata is the base package for the persistence layer in [Orkestra](https://packagist.org/packages/luccpl/orkestra), providing essential functionalities for authentication, session management, and optionally, database interactions through Doctrine ORM.

Installation
------------

[](#installation)

To install Sonata, use Composer:

```
composer require luccpl/sonata
```

Configuration
-------------

[](#configuration)

### Session Management

[](#session-management)

Sonata provides a session interface that currently supports PHP's default session handling. To use it, register the `Sonata\Sessions\SessionsProvider` in your providers list.

### Authentication Configuration

[](#authentication-configuration)

To configure authentication guards, add the `sonata.auth_guards` configuration. This configuration maps guard keys to their respective drivers and repositories:

```
$app->config()->set('sonata.auth_guards', [
    'guard_key' => [
        'driver' => 'session',  // the driver to use for authentication
        'repository' => YourRepository::class,  // An implementation of Sonata\Repositories\Interfaces\Partials\IdentifiableRepositoryInterface
    ],
]);
```

Set the default authentication guard using the `sonata.default_guard` configuration:

```
['sonata.default_guard', 'guard_key'];
```

#### Custom Session Interface

[](#custom-session-interface)

Optionally, you can change the session interface by setting the `sonata.session` configuration:

```
['sonata.session', YourCustomSessionInterface::class];
```

### Added Middleware

[](#added-middleware)

With the session provider registered, you gain access to the `auth` middleware, which can be used to protect routes with the existing guards:

```
return function (RouterInterface $router): void {
    $router->get('/protected', function ($request, $response) {
        return ['message' => 'This is a protected route'];
    })->middleware('auth');
};
```

optionally you can specify a guard key to use a specific guard:

```
return function (RouterInterface $router): void {
    $router->get('/protected', function ($request, $response) {
        return ['message' => 'This is a protected route'];
    })->middleware('auth', ['guard' => 'web']);
};
```

Optional: Doctrine ORM Integration
----------------------------------

[](#optional-doctrine-orm-integration)

If you wish to use Doctrine ORM for database interactions, install the necessary Doctrine packages:

```
composer require doctrine/orm doctrine/dbal doctrine/migrations symfony/cache
```

Then add the `Sonata\Doctrine\DoctrineProvider` to the Orkestra providers list.

#### Default Configuration

[](#default-configuration)

By default, Doctrine is configured to use SQLite. You can configure it to use other databases supported by Doctrine by setting the `doctrine.connection` configuration in Orkestra following the [Doctrine configuration format](https://www.doctrine-project.org/projects/doctrine-dbal/en/4.0/reference/configuration.html).

```
[
	'doctrine.connection' => [
		'dbname' => 'mydb',
		'user' => 'user',
		'password' => 'secret',
		'host' => 'localhost',
		'driver' => 'pdo_mysql',
	],
];
```

#### Entities and Migrations

[](#entities-and-migrations)

You can specify the directories for your entities and migration classes using the `doctrine.entities` and `doctrine.migrations` configurations:

```
[
	'doctrine.entities' => [
		'App\Entities' => '/path/to/entities'
	],
	'doctrine.migrations' => [
		'/path/to/migrations'
	],
];
```

By default, Sonata will use the `App\Entities` namespace for entities and the `App\Migrations` namespace for migrations in `./migrations` directory.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance62

Regular maintenance activity

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~82 days

Total

3

Last Release

242d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0e533ec73731a75d790e8720ede3f291a13151fd1a97b211b54d956f55f792c9?d=identicon)[Luc-cpl](/maintainers/Luc-cpl)

---

Top Contributors

[![Luc-cpl](https://avatars.githubusercontent.com/u/20001157?v=4)](https://github.com/Luc-cpl "Luc-cpl (59 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/luccpl-sonata/health.svg)

```
[![Health](https://phpackages.com/badges/luccpl-sonata/health.svg)](https://phpackages.com/packages/luccpl-sonata)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[liuggio/fastest

Simple parallel testing execution... with some goodies for functional tests.

4825.6M26](/packages/liuggio-fastest)[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[doctrine/phpcr-odm

PHP Doctrine Content Repository Object Document Mapper (ODM) provides transparent persistence for PHP objects.

1811.5M97](/packages/doctrine-phpcr-odm)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
