zairakai / laravel-essentials
Essential helpers and macros that should be in Laravel but aren't - zero duplicates, pure value
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Forks: 0
pkg:composer/zairakai/laravel-essentials
Requires
- php: ^8.3|^8.4
- illuminate/collections: ^11.0|^12.0
- illuminate/support: ^11.0|^12.0
- laravel/framework: ^11.0|^12.0
- spatie/laravel-collection-macros: ^7.0|^8.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.27
- orchestra/testbench: ^9.0|^10.0
- phpstan/phpstan: ^2.0
- zairakai/laravel-dev-tools: ^2.12
This package is not auto-updated.
Last update: 2026-01-20 19:10:40 UTC
README
Essential helpers and macros that should be in Laravel but aren't - zero duplicates, pure value.
Features
- Helper Functions - Array, boolean, filesystem, format, math, string, and validation utilities
- Str Macros - Validation macros for
Str::andStringablethat don't exist in Laravel - Collection Macros - Includes spatie/laravel-collection-macros
- Zero Duplicates - Only adds what Laravel doesn't have
Installation
composer require zairakai/laravel-essentials
The service provider is auto-discovered. No additional configuration required.
Helpers
Array
// Replace values recursively in array
recursive_array_replace('foo', 'bar', $array);
// Replace in keys instead of values
recursive_array_replace('foo', 'bar', $array, true);
Boolean
// Strictly true (not truthy)
is_true($value);
// Strictly false (not falsy)
is_false($value);
Filesystem
// Sanitize filename for safe storage
sanitize_filename('my file@#$.txt'); // "myfile.txt"
Format
// Format number with French locale (default)
number_format_locale(1234.56, 2); // "1 234,56"
// With custom locale
number_format_locale(1234.56, 2, 'en_US'); // "1,234.56"
Math
is_even(4); // true
is_odd(3); // true
String
// Generate random string with character set
generate_random_string(10, 'ALPHA'); // "ABCDEFGHIJ"
generate_random_string(10, 'ALPHA_LOWER'); // "abcdefghij"
generate_random_string(10, 'NUMERIC'); // "1234567890"
generate_random_string(10, 'ALPHANUMERIC'); // "A1b2C3d4E5"
Validation
is_valid_email('test@example.com'); // true
is_valid_ip('192.168.1.1'); // true (IPv4 and IPv6)
is_valid_mac('00:1A:2B:3C:4D:5E'); // true
is_valid_base64('SGVsbG8='); // true
Str Macros
Validation macros that don't exist in Laravel's Str class:
use Illuminate\Support\Str;
// Static methods
Str::isEmail('test@example.com'); // true
Str::isIp('192.168.1.1'); // true
Str::isMac('00:1A:2B:3C:4D:5E'); // true
Str::isBase64('SGVsbG8='); // true
// Fluent methods (Stringable)
Str::of('test@example.com')->isEmail(); // true
Str::of('192.168.1.1')->isIp(); // true
Str::of('00:1A:2B:3C:4D:5E')->isMac(); // true
Str::of('SGVsbG8=')->isBase64(); // true
Note: For JSON/URL/UUID validation, use Laravel's native methods:
Str::isJson(),Str::isUrl(),Str::isUuid()
Collection Macros
This package includes spatie/laravel-collection-macros which adds many useful collection methods. See their documentation for the full list.
Requirements
Documentation
- Contributing - Contribution guidelines and workflow
- Security - Security policies and vulnerability reporting
- Code of Conduct - Community standards and expectations
Getting Help
Built with ❤️ by the Zairakai team for Laravel developers