PHPackages                             ysocode/berry - 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. [Framework](/categories/framework)
4. /
5. ysocode/berry

ActiveLibrary[Framework](/categories/framework)

ysocode/berry
=============

Berry is easy, fast and extremely uncomplicated. Create and manage your routes

v6.0.0(2mo ago)044MITPHPPHP ^8.5

Since Oct 8Pushed 2mo agoCompare

[ Source](https://github.com/ysocode/berry)[ Packagist](https://packagist.org/packages/ysocode/berry)[ RSS](/packages/ysocode-berry/feed)WikiDiscussions 6.x Synced 1mo ago

READMEChangelog (9)Dependencies (16)Versions (12)Used By (0)

Berry - A Refined Routing Library for Modern PHP Applications
=============================================================

[](#berry---a-refined-routing-library-for-modern-php-applications)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3275f6aebc549d8ca2fa7757dd10a476df285b65b20a39f70f529257ce39e481/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f79736f636f64652f62657272792e7376673f7374796c653d666c6174)](https://packagist.org/packages/ysocode/berry)[![Downloads on Packagist](https://camo.githubusercontent.com/805755765ab7b8599e76693f566adeedf71630e0cdca4e14b4f784b6823b80eb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f79736f636f64652f62657272792e7376673f7374796c653d666c6174)](https://packagist.org/packages/ysocode/berry)[![License](https://camo.githubusercontent.com/2bf32fdb9402b0d182f403f723c5b00bc8689b6eed6902b18229afdebc60e8ec/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f79736f636f64652f6265727279)](LICENSE)

Introduction
------------

[](#introduction)

Berry is a refined and strongly-typed routing library for PHP, designed with a deep focus on **domain integrity**, **immutability**, and **clarity**.

Rather than simply following the PSR standards (11, 15, and 17), Berry **reimagines and enhances** them, applying concepts such as **Value Objects**, **Enums**, and **Clean Architecture principles** to provide a more expressive and robust core.

Its design encourages composition over inheritance, enforcing consistency across request, response, URI, and middleware handling.
The result is a minimal, elegant, and extensible router that keeps type safety and readability at the forefront.

Official Documentation
----------------------

[](#official-documentation)

### Web Servers

[](#web-servers)

#### Apache Configurations

[](#apache-configurations)

Ensure your `.htaccess` and `index.php` files are in the same public-accessible directory. The `.htaccess` file should contain this code:

```
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
```

To ensure that the `public/` directory does not appear in the URL, you should add a second `.htaccess` file above the `public/` directory with the following internal redirect rule:

```
RewriteEngine On
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
```

### Installation

[](#installation)

#### Install Berry:

[](#install-berry)

We recommend installing Berry via Composer. Navigate to your project’s root directory and run the following command:

```
composer require ysocode/berry
```

#### Bootstrapping Berry with a PSR-11 Container

[](#bootstrapping-berry-with-a-psr-11-container)

Berry requires a PSR-11 compatible container (such as PHP-DI) to handle dependencies. Once the container is ready, you can instantiate Berry, register routes, and run the application.

```
