PHPackages                             lyre/lyre - 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. [Admin Panels](/categories/admin)
4. /
5. lyre/lyre

ActiveLibrary[Admin Panels](/categories/admin)

lyre/lyre
=========

One minute CRUD with a simple command to create all resources

2.0.4(3mo ago)23738MITPHPPHP ^8.2

Since Apr 15Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/kigathi-chege/lyre)[ Packagist](https://packagist.org/packages/lyre/lyre)[ RSS](/packages/lyre-lyre/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (125)Used By (8)

[![Lyre](https://camo.githubusercontent.com/db2893e37a74a93718175d2c493a5cd68e68fe90aba6ba48e92e181f75d7690a/68747470733a2f2f656e2e77696b74696f6e6172792e6f72672f77696b692f6c797265232f6d656469612f46696c653a4c7972655f28505346292e706e67)](https://camo.githubusercontent.com/db2893e37a74a93718175d2c493a5cd68e68fe90aba6ba48e92e181f75d7690a/68747470733a2f2f656e2e77696b74696f6e6172792e6f72672f77696b692f6c797265232f6d656469612f46696c653a4c7972655f28505346292e706e67)

[![License](https://camo.githubusercontent.com/4a64c31c71966d152c876eea1f35e85fbd33d57ddf5754260a41f053aa72c5b2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c61726176656c2f6672616d65776f726b)](https://packagist.org/packages/laravel/framework)

About Lyre
----------

[](#about-lyre)

Lyre is a php package built for Laravel. Lyre works together with the rich Laravel ecosystem, and goes hand in hand with its philosophy of expressive, elegant syntax. It takes enjoyable and creative development a step further and makes you feel the harmony of it all as the elements come together. Lyre utilizes the following to create the rhythm of the future:

- [Repositories, as hinted at in Laravel's container docs](https://laravel.com/docs/11.x/container).
- [Eloquent resources to automatically transform your responses](https://laravel.com/docs/11.x/eloquent-resources).
- Abstracted resource [controllers](https://laravel.com/docs/11.x/controllers#api-resource-routes) with all your basic CRUD, maximizing on a naturally RESTFUL API.
- Comes out of the box with [spatie roles and permissions](https://spatie.be/docs/laravel-permission/v6/introduction) configured with [Laravel policies](https://laravel.com/docs/11.x/authorization#creating-policies).
- Another out of the box feature: [spatie activity log](https://spatie.be/docs/laravel-activitylog/v4/introduction) configured with [Eloquent observers](https://laravel.com/docs/11.x/eloquent#observers).
- And finally, [Artisan console commands](https://laravel.com/docs/11.x/artisan#main-content) to rule them all.

Lyre is accessible, powerful, and it is your next favorite tool.

Get started right away
----------------------

[](#get-started-right-away)

```
composer require lyre/lyre
```

- Add `LyreServiceProvider` to your providers array under `bootstrap` &gt; `providers.php`
- Add `use BaseModelTrait` to your existing models.
- Run `php artisan vendor:publish --provider="Lyre\Providers\LyreServiceProvider"` to publish Lyre configuration.
- Clear configuration cache

```
php artisan lyre:all Post
```

- Add your columns to your migration and migrate
- Enable API routing (If using Laravel &gt; 10)

```
php artisan install:api
```

- Add your model to your routes file

```
Route::apiResource('posts', PostController::class);
```

- Consume your API!
- Guess what? That's it.

Dependencies
------------

[](#dependencies)

- **[PHP 8.2](https://www.php.net/releases/8.2/en.php)**
- **[Spatie Activity Log](https://spatie.be/docs/laravel-activitylog/v4/introduction)**
- **[Spatie Laravel Permission](https://spatie.be/docs/laravel-permission/v6/introduction)**

Digging Deeper
--------------

[](#digging-deeper)

### RESTFULNESS

[](#restfulness)

- Lyre is naturally RESTFUL, meaning that after adding your apiResource or resource in your routes file, you will be able to create, update, and delete all records using these routes, borrowed from the above example:

    ```
     GET|HEAD        posts
     POST            posts
     GET|HEAD        posts/{post}
     PUT|PATCH       posts/{post}
     DELETE          posts/{post}

    ```

#### Hidden Gem

[](#hidden-gem)

- Lyre comes with a bulkUpdate option that also follows the RESTFUL convention for batch operations, allowing you to efficiently update multiple records in a single request.
- All you need to do is comma separate the values in your PUT|PATCH request.
- For example:

##### Single Update

[](#single-update)

```
   posts/1

```

##### Bulk Update

[](#bulk-update)

```
   posts/1,2,3

```

### Filters

[](#filters)

#### Easily Handle Relationships

[](#easily-handle-relationships)

- To return a model with all its relationships, simply chain a with method that takes an array of relations when querying the repository like so:
- (Note that Lyre automatically creates repository helpers for you so that you do not have to inject or declare repository objects.)

```
$data = postRepository()->with(['author', 'comments'])->all();
```

- All you need to do is define the relationships in your model:

```
public function author()
{
       return $this->belongsTo(User::class, 'user_id');
}

public function comments()
{
       return $this->hasMany(Comment::class);
}
```

- Run this command to automatically detect model relationships:

```
php artisan cache:relationships
```

- If you need more control, you can always override the loadResources method of the Posts resource in app&gt;Http&gt;Resources&gt;Post

```
public static function loadResources(): array
{
       return [
              'author' => User::class,
              'comments' => Comment::class
       ];
}
```

- Now you will be able to get your model with these relationships using a simple query string

    ```
     posts/1?with=author,comments

    ```

### Filters

[](#filters-1)

#### Column Filters

[](#column-filters)

- Easily return data filtered by a specific column

```
$data = postRepository()->columnFilters(['status' => 'active'])->all();
```

#### Range Filters

[](#range-filters)

- Easily filter your data by range, for example, created\_at!

```
$data = postRepository()->rangeFilters(['created' => [now()->subHours(24), now()])->all();
```

#### Relation Filters

[](#relation-filters)

- You can even return your data filtered by specific relationships!

```
$data = postRepository()->relationFilters('author' => 'id,1')->all();
```

#### Search Query

[](#search-query)

- Search through your repository!

```
$data = postRepository()->searchQuery(['search' => 'lyre'])->all();
```

### Method Chaining

[](#method-chaining)

- What is more? You can chain all these methods to fine tune your query!

```
$data = postRepository()->with(['author', 'comments'])
       ->columnFilters(['status' => 'active'])
       ->rangeFilters(['created' => [now()->subHours(24), now()])
       ->relationFilters('author' => 'id,1')
       ->searchQuery(['search' => 'lyre'])
       ->all()
```

### API Query Strings

[](#api-query-strings)

Lyre provides the following query string filters to filter all your data the way you want!

- **with** - A comma separated list of all the relationships that you want to return in your response
- **paginate** - This boolean value determines whether pagination is set, default is `true`
- **page** - Changes the current page in a paginated request
- **per\_page** - Changes the number of items returned in the request
- **latest** - Returns the latest `value` items
- **order** - Returns ordered items, e.g. `/subjects?order=name,asc`
- **relation** - Filter by a column in a related table, i.e. `/subjects?relation=courses,english` returns only the Subjects that belong to an English course
- **search** - Search through all columns for a string match, e.g. `/subjects?search=physics`
- **startswith** - Get all rows whose `NAME_COLUMN` startswith substring, e.g. `/subjects?startswith=b`
- **withcount** - Get the count of a relationship, e.g. `/subjects?withcount=tasks` returns with a `tasks_count` field containing the number of tasks for each subject.
- **wherenull** - Provide comma separated columns whose value should be `NULL`
- **doesnthave** - Provide comma separated relations that must be empty
- **limit / offset / random / first** - Fine tune record counts and ordering without writing SQL

### Further Reading

[](#further-reading)

- [Architecture &amp; Query Guide](docs/cursor/architecture-and-query-guide.md) — deep dive into `Model`, `Repository`, `Controller`, `Resource`, and facet query patterns.

Known Issues
------------

[](#known-issues)

### Installation

[](#installation)

- All models must use BaseModelTrait, otherwise throws error: Call to a member function connection() on null
- Fails to publish stubs, creates empty folder. Stubs must be copied from **[STUBS](https://github.com/kigathi-chege/lyre/tree/master/src/stubs)**

Collaboration
-------------

[](#collaboration)

- Update version in [composer.json](https://github.com/kigathi-chege/lyre/blob/master/composer.json)
- Push changes to github, push tag to update **[Packagist](https://packagist.org/packages/lyre/lyre)**

```
       git tag x.x.x
       git push origin x.x.x
```

USING SPATIE
============

[](#using-spatie)

Using Activity Log
------------------

[](#using-activity-log)

Publish the migration with:

```
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="activitylog-migrations"
```

Using Roles and Permissions
---------------------------

[](#using-roles-and-permissions)

Publish the migrations and the configs with:

```
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
```

Add the Spatie\\Permission\\Traits\\HasRoles trait to your User model(s):

```
use Illuminate\Foundation\Auth\User as Authenticatable;
use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable
{
    use HasRoles;

    // ...
}
```

Clear Model Classes Cache
-------------------------

[](#clear-model-classes-cache)

Whenever you add a new model, you need to clear the `app_model_classes` cache to ensure `get_model_classes` always returns the most up to date list.

```
php artisan cache:forget app_model_classes
```

License
-------

[](#license)

Lyre is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance79

Regular maintenance activity

Popularity18

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity71

Established project with proven stability

 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 ~5 days

Total

123

Last Release

110d ago

Major Versions

1.7.2 → 202510172329.x-dev2025-10-17

1.11.2 → 2.0.0-beta12026-01-24

2.0.0 → 202601271610.x-dev2026-01-27

202601271610.x-dev → 202601271812.x-dev2026-01-27

### Community

Maintainers

![](https://www.gravatar.com/avatar/f0511efb73ed8430a35329cad343d23590eb2d8bc191fc40e2535839631e7141?d=identicon)[Kigathi](/maintainers/Kigathi)

---

Top Contributors

[![kigathi-chege](https://avatars.githubusercontent.com/u/30687709?v=4)](https://github.com/kigathi-chege "kigathi-chege (158 commits)")

---

Tags

phplaravellaravel 10laravel 11laravel 12SimplegithubcrudresourcesRelationshipsopen-sourcelyre

### Embed Badge

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

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

###  Alternatives

[goodway/laravel-nats

Nats jetstream queue driver with client for Laravel

304.8k](/packages/goodway-laravel-nats)[prismaticoder/maker-checker-laravel

A package for simplifying the integration of a maker-checker approval process to your Laravel application.

232.7k](/packages/prismaticoder-maker-checker-laravel)[inani/nova-resource-maker

A Laravel Nova package to help you generate resources fields

2513.7k](/packages/inani-nova-resource-maker)

PHPackages © 2026

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