PHPackages                             janpantel/laravel-fluent-plus - 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. janpantel/laravel-fluent-plus

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

janpantel/laravel-fluent-plus
=============================

A package that adds useful helpers to Laravel's Fluent class

13PHP

Since Jan 7Pushed 4y ago1 watchersCompare

[ Source](https://github.com/janpantel/laravel-fluent-plus)[ Packagist](https://packagist.org/packages/janpantel/laravel-fluent-plus)[ RSS](/packages/janpantel-laravel-fluent-plus/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Fluent Plus
===================

[](#laravel-fluent-plus)

This package extends Laravel's `Fluent` class to provide a supercharged experience like type casting and recursive Fluent access to sub-assocs.

Basic usage
-----------

[](#basic-usage)

Instead of extending `Illuminate\Support\Fluent` you extend `JanPantel\LaravelFluentPlus\FluentPlus` instead. As this class is a superset of Fluent it can be treated as a drop in replacement.

`FluentPlus` implements a `$casts` property that defines how the attributes of your assoc should be cast.

For the following example assume `NamesContainer`, `Price`and `StockLevel` to be classes extending `Fluent`or `FluentPlus` as well.

```
class MyContainer extends FluentPlus
{
    protected $casts = [
        // Use the contents of the `names` attribute
        // to initialize a new `NamesContainer` instance.
        'names' => NamesContainer::class,

        // Assumes that the `price` attribute contains
        // an array and initializes a new `Price` instance
        // for every item.
        'prices' => [Price::class],

        // The same as the array syntax but using
        // Laravel's `Collection` class instead.
        'stock' => [
            \Illuminate\Support\Collection::class,
            StockLevel::class
        ],
    ];
}
```

The resulting object now offers convenient property access:

```
$container = new MyContainer($sourceAssoc);

var_dump($container->names->english);
var_dump($container->prices[0]->amount);
var_dump($container->stock->get('store_1')->quantity);
```

The problem this package solves
-------------------------------

[](#the-problem-this-package-solves)

If you work with assocs a lot and like using property access over assoc access Laravel's `Fluent` class is a convenient way to do so.

The use case that made me write this package is working with responses fetched from 3rd party APIs. Since I want to use `@property` PHP docs to have "type safety" while not manually assigning properties.

Advanced usage
--------------

[](#advanced-usage)

### Recursive array casts

[](#recursive-array-casts)

`FluentPlus` casts sub-assocs that do not have a cast defined into other FluentPlus for infinite dimension property access.

```
$instance = new Fluent(['foo' => ['bar' => 'baz']]);
$instancePlus = new FluentPlus(['foo' => ['bar' => 'baz']]);

// breaks :(
var_dump($instance->foo->bar);
// works :)
var_dump($instancePlus->foo->bar);
```

You can turn this feature off by setting the `$recursive`property in your derived `FluentPlus` to `false` or using the `NonRecursiveFluentPlus` utility class if you want to inline it instead.

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6396c85945110cb7ee7e55dacd6d3e4a4ec5b515de581e79d0fafae4f3297d15?d=identicon)[JanPantel](/maintainers/JanPantel)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/janpantel-laravel-fluent-plus/health.svg)

```
[![Health](https://phpackages.com/badges/janpantel-laravel-fluent-plus/health.svg)](https://phpackages.com/packages/janpantel-laravel-fluent-plus)
```

PHPackages © 2026

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