PHPackages                             frictionlessdigital/macros - 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. frictionlessdigital/macros

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

frictionlessdigital/macros
==========================

Frictionless Solutions | Macros

12.0.0(2y ago)0516MITPHPPHP ^7.4 || ^8.0

Since Oct 5Pushed 1y ago5 watchersCompare

[ Source](https://github.com/Frictionlessdigital/macros)[ Packagist](https://packagist.org/packages/frictionlessdigital/macros)[ RSS](/packages/frictionlessdigital-macros/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (9)Dependencies (11)Versions (11)Used By (0)

FLS :: Macros
=============

[](#fls--macros)

Ass some common macroses that Frictionless uses in their daily life.

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

[](#installation)

```
composer require "frictionlessdigital/macros":"^1.0"
```

Note that root namespace for the package is `Fls` not `Frictionlessdigital`.

### Config

[](#config)

To publish configuration file, run

`php artisan vendor:publish --tag=fls.macros-config`

The package will publish `fls.macros.php` file:

```
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Collection;
use Illuminate\Routing\Router;
use Laravel\Dusk\Browser;

return [

    /*
    |--------------------------------------------------------------------------
    | Laravel\Dusk\Browser Macros
    |--------------------------------------------------------------------------
    | To install
    | composer require laravel/dusk
    |
    */
    Browser::class => [
        // 'firstWindow' => \Fls\Macros\Macros\Browser\FirstWindow::class,
        // 'lastWindow' => \Fls\Macros\Macros\Browser\LastWindow::class,
        // 'switchToFirstWindow' => \Fls\Macros\Macros\Browser\SwitchToFirstWindow::class,
        // 'switchToLastWindow' => \Fls\Macros\Macros\Browser\SwitchToLastWindow::class,
        // 'windows' => \Fls\Macros\Macros\Browser\Windows::class,
    ],

    /*
    |--------------------------------------------------------------------------
    | Illuminate\Database\Eloquent\Builder
    |--------------------------------------------------------------------------
    | Enabled by default
    |
    */
    Builder::class => [
        'toSqlWithBindings' => \Fls\Macros\Macros\Builder\ToSqlWithBindings::class,
    ],

    /*
    |--------------------------------------------------------------------------
    | Carbon\Carbon
    |--------------------------------------------------------------------------
    | startOfFiscalYear($at = null) will return the return of fiscal year
    |
    */
    Carbon::class => [
        'fiscalYearForHumans' => \Fls\Macros\Macros\Carbon\FiscalYearForHumans::class,
        'startOfFiscalYear' => \Fls\Macros\Macros\Carbon\StartOfFiscalYear::class,
        'endOfFiscalYear' => \Fls\Macros\Macros\Carbon\EndOfFiscalYear::class,
        'isFiscalYear' => \Fls\Macros\Macros\Carbon\IsFiscalYear::class,
    ],

    /*
    |--------------------------------------------------------------------------
    | Illuminate\Support\Collection
    |--------------------------------------------------------------------------
    | oxford() required Coduo\Humanize package
    | composer require coduo/php-humanizer
    |
    */
    Collection::class => [
        // 'ofxord' => \Fls\Macros\Macros\Collection\Oxford::class,
    ],

    /*
    |--------------------------------------------------------------------------
    | Illuminate\Database\Eloquent\Factories\Factory Macros
    |--------------------------------------------------------------------------
    | Enabled by default
    |
    */
    Factory::class => [
        'empty' => \Fls\Macros\Macros\Factory\EmptyFactory::class,
    ],

    /*
    |--------------------------------------------------------------------------
    | Illuminate\Routing\Router Macros
    |--------------------------------------------------------------------------
    | livewireResource() is just a shortcut to have a resource with [index, create, show, edit] methods only
    | but if you want to install LiveWire
    | composer require livewire/livewire
    |
    */
    Router::class => [
        'livewireResource' => \Fls\Macros\Macros\Router\LiveResource::class,
    ],
];
```

Configuration structure is simple: root key is the name of the class you need to add the macro to and the array is the macros that are being added.

You will notice that some are commented out: the package does not insist you have those, and does tno silently pull them, to avoid surprises (with Dusk, for instance). As there is no need to pull extra packages when you dont need them - you should integrate them within your repo.

The list of packages is suggested in `composer.json`:

- [coduo/php-humanizer](https://github.com/coduo/php-humanizer) - Humanize values
- [laravel/dusk](https://github.com/laravel/dusk) - Laravel Testing tool

Integration
-----------

[](#integration)

The package automatically registers with Laravel.

If you want to manually register it, add to your `composer.json`:

```
    "extra": {
        "laravel": {
            "dont-discover": [
                "frictionlessdigital/macros"
            ]
        }
    },
```

and add to `config\app.php`:

```
    'providers' => [
        /*
         * Package Service Providers...
         */
        Fls\Macros\MacrosServiceProvider::class,
```

Usage
-----

[](#usage)

The package offers extension for Builder, Carbon, Router, Collection and Dusk Browser.

### \\Carbon\\Carbon Macros

[](#carboncarbon-macros)

**fiscalYearForHumans($formatter=null)**will get readable representation for the fiscal year.

```
$x = Carbon::now()->fiscalYearForHumans()
// $x = 'Fiscal year ending March 31, 2022';
```

`fiscalYearForHumans` accepts closure formatter:

```
$x = Carbon::now()->fiscalYearForHumans(fn($at) => new HtmlString(''.$at->year.''));
// $x = HtmlString('2022');
```

**startOfFiscalYear**will modify the date to the start of the fiscal year

```
Carbon::startOfFiscalYear();
// Carbon instance at April 1, 2021 0:0:0;
```

**endOfFiscalYear**will modify the date to the end of the fiscal year

```
Carbon::endOfFiscalYear();
// Carbon instance at March 31, 2022 25:59:59;
```

**isFiscalYear**Will check if the date is within the provided (int) fiscal year

```
// assuming now is
Carbon::parse('March 31, 2022')->isFiscalYear(2021);
// true
Carbon::parse('April 1, 2022')->isFiscalYear(2021);
// false
```

### Laravel\\Dusk\\Browser Macros

[](#laravelduskbrowser-macros)

\*Requires Laravel Dusk:

```
composer require laravel/dusk
```

- firstWindow() - to get the first window
- lastWindow() - to get the last window
- switchToFirstWindow() - switch Browser to the first window
- switchTolastWindow() - switch Browser to the last window
- windows() - get all current Browser windows

### Illuminate\\Database\\Eloquent\\Builder Macros

[](#illuminatedatabaseeloquentbuilder-macros)

- toSqlWithBindings - get the SQL from the builder, hydrated with values

### Illuminate\\Support\\Collection Macros

[](#illuminatesupportcollection-macros)

Optionally, many need Coduo Humanizer, tested with version 4

```
composer require coduo/php-humanizer
```

- oxford - list values with Ofxord coma.

### Illuminate\\Database\\Eloquent\\Factories\\Factory Macros

[](#illuminatedatabaseeloquentfactoriesfactory-macros)

- empty() - will return a Factory where every value in definition is `null`

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Cyrill N Kalita](https://github.com/nickfls)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

---

[![](./resources/docs/gramma.png)](http://frictionlesssolutions.com "Fricitonless Solutions Inc.")

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 87.1% 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 ~141 days

Recently: every ~182 days

Total

10

Last Release

458d ago

Major Versions

1.5.0 → 12.0.02024-04-09

1.5.1 → v12.x-dev2025-04-01

PHP version history (2 changes)1.0.0PHP ^7.3 || ^8.0

1.1.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/d6897fa24df64545b665dc9b4707e5f69d766ab4d2a1b5b13041e22d7eb8b30d?d=identicon)[cyrill@frictionlesssolutions.com](/maintainers/cyrill@frictionlesssolutions.com)

---

Top Contributors

[![nickfls](https://avatars.githubusercontent.com/u/12013206?v=4)](https://github.com/nickfls "nickfls (27 commits)")[![Purnendu-extreme](https://avatars.githubusercontent.com/u/26261727?v=4)](https://github.com/Purnendu-extreme "Purnendu-extreme (4 commits)")

---

Tags

laravelmacrosfls

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.8k3](/packages/defstudio-telegraph)[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k9.0M69](/packages/spatie-laravel-responsecache)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5021.9k](/packages/simplestats-io-laravel-client)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)[masterix21/laravel-licensing

Laravel licensing package with polymorphic assignment to any model, activation keys, expirations/renewals, and seat control via LicenseUsage. Supports offline verification with public-key–signed tokens, a CLI to generate/rotate/revoke keys, and an extensible architecture via config and contracts.

1563.1k4](/packages/masterix21-laravel-licensing)

PHPackages © 2026

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