PHPackages                             achrafbardan/simple-resources - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. achrafbardan/simple-resources

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

achrafbardan/simple-resources
=============================

This is my package simple-resources-for-laravel

2.0.0(2y ago)0596MITPHPPHP ^8.0|^8.1|^8.2|^8.3

Since Apr 28Pushed 2y ago1 watchersCompare

[ Source](https://github.com/AchrafBardan/simple-resources-for-laravel)[ Packagist](https://packagist.org/packages/achrafbardan/simple-resources)[ Docs](https://github.com/AchrafBardan/simple-resources-for-laravel)[ RSS](/packages/achrafbardan-simple-resources/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (6)Versions (5)Used By (0)

Simple resources for Laravel
============================

[](#simple-resources-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0e7689429b25ac1491956a78ac22ef2e5783c87068abe4a833f1a25961220828/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f41636872616642617264616e2f73696d706c652d7265736f75726365732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/achrafbardan/simple-resources)[![GitHub Tests Action Status](https://camo.githubusercontent.com/9fbbf671be3d82c4158bac9c3424b665f2176a552578c0f9e82980521b740e56/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f41636872616642617264616e2f73696d706c652d7265736f75726365732d666f722d6c61726176656c2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/AchrafBardan/simple-resources-for-laravel/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/4e229b7448c3e9042fa44d20d3a48342a5db1a2e91415639401fc59908253dc5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f41636872616642617264616e2f73696d706c652d7265736f75726365732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/achrafbardan/simple-resources)

This is a small package that simplifies resource usage. It is used to auto guess and link resources to models. Paginated collections are also auto wrappable in the resource.

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

[](#installation)

You can install the package via composer:

```
composer require AchrafBardan/simple-resources-for-laravel
```

You can publish the config file with:

```
php artisan vendor:publish --tag="simple-resources-for-laravel-config"
```

This is the contents of the published config file:

```
return [
    "model_namespace" => "App\\Models",
    "resource_namespace" => "App\\Http\\Resources",

    /**
     * When this is set to false, you have to add the \AchrafBardan\SimpleResources\Contracts\HasResource interface to your models.
     * When set to true you can still optionally add the interface to your models, this interface will than be used instead of the guesser.
     */
    "guess_resource" => true
];
```

Optionally, you can publish the views using

```
php artisan vendor:publish --tag="simple-resources-for-laravel-views"
```

Usage
-----

[](#usage)

Before returning a model or collection you pass it trough the ResourceFactory. The resource factory finds the resource for your model, collection or even a paginated collection.

```
use AchrafBardan\SimpleResources\ResourceFactory;
...
$resource = ResourceFactory::make($model);
return response()->json($resource);
```

You can also use the helper function `resource` which is the same as `ResourceFactory::make`

```
use function AchrafBardan\SimpleResources\resource;
...
$resource = resource($model);
return response()->json($resource);
```

It also intended to be used inside a resource for child models and collections, see the following example.

```
// App/Http/Resources/TestResource.php
...
class TestResource extends JsonResource
{
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'child' => resource($this->whenLoaded('child'))
        ];
    }
}
```

Testing
-------

[](#testing)

```
composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Achraf Bardan](https://github.com/AchrafBardan)
- [OWOW Agency](https://github.com/owowagency)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

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

Total

4

Last Release

780d ago

Major Versions

v1.x-dev → 2.0.02024-05-13

PHP version history (2 changes)1.0.0PHP ^8.0

2.0.0PHP ^8.0|^8.1|^8.2|^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/37a4fee54c8648eba744877a046633962519a1ea55f0e0d22ccd11d9fb75bf8a?d=identicon)[AchrafBardan](/maintainers/AchrafBardan)

---

Top Contributors

[![AchrafBardan](https://avatars.githubusercontent.com/u/72659310?v=4)](https://github.com/AchrafBardan "AchrafBardan (1 commits)")

---

Tags

laravelAchrafBardansimple-resources-for-laravel

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/achrafbardan-simple-resources/health.svg)

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

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M46](/packages/spatie-laravel-pdf)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

329530.5k29](/packages/codewithdennis-filament-select-tree)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

124603.0k](/packages/worksome-exchange)[stephenjude/laravel-wallet

A simple wallet implementation for Laravel

26611.9k](/packages/stephenjude-laravel-wallet)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3913.7k](/packages/rawilk-profile-filament-plugin)[tarfin-labs/event-machine

Event-driven state machines for Laravel with event sourcing, type-safe context, and full audit trail.

199.4k](/packages/tarfin-labs-event-machine)

PHPackages © 2026

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