wyxos / harmonie
Backend utilities for Laravel and @wyxos/vision
Requires
- php: >=8.1 || ^8.2
- laravel/framework: ^11.31 || ^12.0
- laravel/scout: ^10.6
- league/csv: ^9.0
- phpoffice/phpspreadsheet: ^2.2
- dev-main
- 1.6.4
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- v1.5.14
- v1.5.13
- v1.5.12
- v1.5.11
- v1.5.10
- v1.5.9
- v1.5.8
- v1.5.7
- v1.5.4
- v1.5.3
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.1
- v1.4.0
- v1.3.17
- v1.3.16
- v1.3.15
- v1.3.14
- v1.3.13
- v1.3.12
- v1.3.11
- v1.3.10
- v1.3.9
- v1.3.8
- v1.3.7
- v1.3.6
- v1.3.5
- v1.3.4
- v1.3.3
- v1.3.2
- v1.3.1
- 1.3.0.x-dev
- v1.3.0
- v1.2.15
- v1.2.14
- v1.2.13
- v1.2.12
- v1.2.11
- v1.2.10
- v1.2.9
- v1.2.8
- v1.2.7
- v1.2.6
- v1.2.5
- v1.2.4
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.16
- v1.1.15
- v1.1.14
- v1.1.13
- v1.1.12
- v1.1.11
- v1.1.10
- v1.1.9
- v1.1.8
- v1.1.7
- v1.1.6
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
This package is auto-updated.
Last update: 2025-06-09 09:37:25 UTC
README
Backend utilities for Laravel and @wyxos/vision.
Description
Harmonie is a comprehensive package that provides a set of utilities to streamline backend development in Laravel applications, especially when working with the @wyxos/vision frontend library. It offers tools for handling data listings, imports, exports, and resource management.
Requirements
- PHP 8.1 or higher
- Laravel 11.31+ or 12.0+
- league/csv 9.0+
- laravel/scout 10.6+
- phpoffice/phpspreadsheet 2.2+
Installation
You can install the package via composer:
composer require wyxos/harmonie
The package will automatically register its service providers.
Configuration
Publish the configuration file:
php artisan vendor:publish --tag=harmonie:harmonie-config
Features
Listing
The Listing component provides a powerful way to handle data listings with filtering, pagination, and formatting. It supports both Eloquent and Scout (search) queries.
Example usage:
use Wyxos\Harmonie\Listing\ListingBase; use Illuminate\Database\Eloquent\Builder; use Laravel\Scout\Builder as ScoutBuilder; class UserListing extends ListingBase { public function baseQuery() { return User::query(); } public function filters(Builder|ScoutBuilder $base) { $this->whereLike($base, 'search', 'name'); $this->whereIn($base, 'roles'); $this->whereRange($base, 'created_at'); } public function filterLabels(): array { return [ 'search' => 'Search', 'roles' => 'Roles', 'created_from' => 'Created From', 'created_to' => 'Created To', ]; } public function load($pagination) { $pagination->load('roles'); } }
Export
The Export component allows you to export data to CSV files with support for chunking large datasets.
Example usage:
use Wyxos\Harmonie\Export\ExportBase; use Illuminate\Database\Eloquent\Builder; class UserExport extends ExportBase { public function filename($parameters = []) { return 'users-export-' . now()->format('Y-m-d'); } public function query(array $parameters = []): Builder { return User::query(); } public function format($row) { return [ 'ID' => $row->id, 'Name' => $row->name, 'Email' => $row->email, 'Created At' => $row->created_at->format('Y-m-d H:i:s'), ]; } public function chunkQuery(): Builder { return $this->query(); } }
Import
The Import component provides functionality for importing data from CSV files with support for validation and error handling.
Resource
The Resource component extends Laravel's resource functionality with additional features for API development.
Commands
Harmonie includes several useful Artisan commands:
php artisan harmonie:clear-all-cache
- Clears various cache typesphp artisan harmonie:flush-redis
- Clears Redis cachephp artisan harmonie:generate-administrator
- Creates an admin userphp artisan harmonie:scout-reset
- Resets Laravel Scout indexesphp artisan harmonie:make-model
- Custom model generatorphp artisan harmonie:install-git-hook
- Installs a git pre-push hook that runs testsphp artisan harmonie:uninstall-git-hook
- Uninstalls the git pre-push hook
License
The MIT License (MIT). Please see License File for more information.