PHPackages                             chiiya/laravel-utilities - 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. chiiya/laravel-utilities

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

chiiya/laravel-utilities
========================

Common utilities for laravel projects

5.10.0(1mo ago)19.1k↓64.4%[1 PRs](https://github.com/chiiya/laravel-utilities/pulls)1MITPHPPHP ^8.2CI passing

Since Dec 17Pushed 1w ago1 watchersCompare

[ Source](https://github.com/chiiya/laravel-utilities)[ Packagist](https://packagist.org/packages/chiiya/laravel-utilities)[ Docs](https://github.com/chiiya/laravel-utilities)[ GitHub Sponsors](https://github.com/chiiya)[ RSS](/packages/chiiya-laravel-utilities/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (6)Dependencies (20)Versions (42)Used By (1)

Laravel Utilities
=================

[](#laravel-utilities)

[![Latest Version on Packagist](https://camo.githubusercontent.com/16e48447cf80f2684b7fec10c7ae10527ececfa4af3ac32ab595faae438a178c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6368696979612f6c61726176656c2d7574696c69746965732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/chiiya/laravel-utilities)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/30a511c501e26bafe6d4a13b9de3ef263da88191990307bcccd43b145e65b1c5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6368696979612f6c61726176656c2d7574696c69746965732f6c696e743f6c6162656c3d636f64652532307374796c65)](https://github.com/chiiya/laravel-utilities/actions?query=workflow%3Alint+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/ae23af8f617f75f024993ec198b973851a21f07bc322035338fe05ae60da8367/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6368696979612f6c61726176656c2d7574696c69746965732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/chiiya/laravel-utilities)

Common classes and utilities for Laravel projects.

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

[](#installation)

You can install the package via composer:

```
composer require chiiya/laravel-utilities
```

You can optionally publish the config file with:

```
php artisan vendor:publish --tag="utilities-config"
```

This is the contents of the published config file:

```
return [
    /*
    |--------------------------------------------------------------------------
    | Temporary path
    |--------------------------------------------------------------------------
    | Used for downloads and unzipping files.
    */
    'tmp_path' => storage_path('tmp'),
];
```

Usage
-----

[](#usage)

 `TimedCommand` - Print command execution time
Simple extension of the Laravel `Command` that prints execution time after completion.

```
use Chiiya\Common\Commands\TimedCommand;

class SendEmails extends TimedCommand
{
    protected $signature = 'mail:send {user}';

    public function handle(DripEmailer $drip)
    {
        $drip->send(User::find($this->argument('user')));
    }
```

```
$ php artisan mail:send 1
> Execution time: 0.1s
```

 `SetsSender` - Set sender for mailables
Trait to set the sender (return path) for mailables for e.g. bounce handling.

```
use Chiiya\Common\Mail\SetsSender;

class OrderShipped extends Mailables
{
    use SetsSender;

    public function build(): self
    {
        return $this
            ->subject('Order shipped')
            ->markdown('emails.orders.shipped')
            ->sender('return@example.com');
    }
}
```

 `PresentableTrait` - View presenters for eloquent models
View presenter similar to the no longer maintained [`laracasts/presenter`](https://github.com/laracasts/Presenter)package. Useful for doing some manipulations before displaying data.

```
use Chiiya\Common\Presenter\Presenter;

/** @extends Presenter */
class UserPresenter extends Presenter
{
    public function name(): string
    {
        return $this->first_name.' '.$this->last_name;
    }
}
```

```
use Chiiya\Common\Presenter\PresentableTrait;

class User extends Model
{
    /** @use PresentableTrait */
    use PresentableTrait;

    protected string $presenter = UserPresenter::class;
}
```

```
Hello, {{ $user->present()->name }}
```

 `AbstractRepository` - Base repository for the repository pattern
Base repository for usage of the repository pattern. It provides `get`, `find`, `index`, `search`, `count`, `create`, `update` and `delete` methods for the configured `$model`. Most methods accept an optional `$filters` parameter, that may be used to apply the filters configured in the `applyFilters` method to your queries.

A general recommendation is to only use repositories as a place to store your complex queries and/or queries that are used repeatedly in multiple places, since otherwise they might be considered an anti-pattern. For more complex queries it can however be useful to separate them from your services. Repositories also serve as a way to self-document those queries by using descriptive method names. This way developers don't have to parse database queries and try to understand their purpose when going through your application logic.

```
use Chiiya\Common\Repositories\AbstractRepository;

/**
 * @extends AbstractRepository
 */
class PostRepository extends AbstractRepository
{
    protected string $model = Post::class;

    /**
     * @return Collection
     */
    public function postsDiscussedYesterday()
    {
        return $this->newQuery()
            ->whereHas('comments', function (Builder $builder) {
                $builder
                    ->where('created_at', '>=', now()->subDay()->startOfDay())
                    ->where('created_at', 'service->import(storage_path('app/exports'));
        // Generate specified amount of random codes using the given pattern and character set
        $this->service->generate(
            1_000_000,
            '####-####-####',
            CodeService::SET_NUMBERS_AND_UPPERCASE,
        );
        // Get generated codes for further processing
        $codes = $this->service->getCodes();
        // ... e.g. bulk insert $codes into database
        // Export newly generated codes into (batched) CSV files. Optionally specify the amount of codes per file
        $this->service->export(storage_path('app/exports'));
        $this->service->export(path: storage_path('app/exports'), perFile: 500_000);
    }
}
```

 `CsvReader` - Read CSV files
Small wrapper around the [`openspout/openspout`](https://github.com/openspout/openspout) csv reader for high-performance reading of CSV files:

```
$reader = resolve(\Chiiya\Common\Services\CsvReader::class);
$reader->open('/path/to/file.csv');
foreach ($reader->rows() as $row) {
    $values = $row->toArray();
}
$reader->close();
```

 `CsvWriter` - Write CSV files
Small wrapper around the [`openspout/openspout`](https://github.com/openspout/openspout) csv writer:

```
$writer = resolve(\Chiiya\Common\Services\CsvWriter::class);
$writer->open('/path/to/file.csv');
$writer->write(['Value 1', 'Value 2']);
$writer->close();
```

 `ExcelReader` - Read XLS/XLSX files
Small wrapper around the [`openspout/openspout`](https://github.com/openspout/openspout) excel reader for high-performance reading of XLS/XLSX files:

```
$reader = resolve(\Chiiya\Common\Services\ExcelReader::class);
$reader->open('/path/to/file.xlsx');
foreach ($reader->getSheetIterator() as $sheet) {
    foreach ($sheet->getRowIterator() as $row) {
        $values = $row->toArray();
    }
}
$reader->close();
```

 `ExcelWriter` - Write XLX/XLSX files
Small wrapper around the [`openspout/openspout`](https://github.com/openspout/openspout) excel writer:

```
$writer = resolve(\Chiiya\Common\Services\ExcelWriter::class);
$writer->open('/path/to/file.xlsx');
$writer->setCurrentSheetName('Sheet 1');
$writer->addHeaderRow(['Name', 'Email']);
$writer->write(['John Doe', 'john.doe@example.com']);
$writer->addSheet('Sheet 2');
$writer->write(['Value 1', 'Value 2']);
$writer->close();
```

 `FileDownloader` - Download remote files
Utility class for downloading files from a remote URL.

```
$downloader = resolve(\Chiiya\Common\Services\FileDownloader::class);
$file = $downloader->download('https://example.com/path/to/file.txt');
dump($file->getPath());
$file->delete();
```

 `Zipper` - Zip and unzip .zip files
Utility class for zipping and unzipping .zip files.

```
// Unzipping
$zipper = resolve(\Chiiya\Common\Services\Zipper::class);
$location = $zipper->unzip('/path/to/file.zip');

// Zipping
$zipper->create('documents.zip')->addDirectory('/path/to/directory')->close();
$path = $zipper->getZipPath();

// Or with files
$zipper
    ->create('documents.zip')
    ->addFiles([
        '/path/to/file1',
        '/path/to/file2',
    ])
    ->close();
$path = $zipper->getZipPath();
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

License
-------

[](#license)

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

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance96

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 69.5% 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 ~53 days

Recently: every ~14 days

Total

38

Last Release

37d ago

Major Versions

1.5.0 → 2.0.02021-12-10

2.1.0 → 3.0.02022-02-22

3.1.0 → 4.0.02022-03-22

4.5.0 → 5.0.02023-01-10

PHP version history (4 changes)1.0.0PHP ^7.2|^8.0

2.0.0PHP ^8.0

4.0.0PHP ^8.1

5.2.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15029301?v=4)[Elisha](/maintainers/chiiya)[@chiiya](https://github.com/chiiya)

---

Top Contributors

[![chiiya](https://avatars.githubusercontent.com/u/15029301?v=4)](https://github.com/chiiya "chiiya (66 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (19 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (10 commits)")

---

Tags

laravelcommonutilities

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/chiiya-laravel-utilities/health.svg)

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

###  Alternatives

[nativephp/mobile

NativePHP for Mobile

1.1k75.1k97](/packages/nativephp-mobile)[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M167](/packages/spatie-laravel-health)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/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)[unopim/unopim

UnoPim Laravel PIM

10.5k2.4k](/packages/unopim-unopim)[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.

5022.0k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

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