Installation
composer require windwalker/utilities ^4.0
Ensure your composer.json includes the package under require.
First Use Case
Import and use the StringHelper for common string manipulations:
use Windwalker\Utilities\Helper\StringHelper;
$result = StringHelper::slugify('Hello World!'); // Returns 'hello-world'
Where to Look First
Helper directory for utility classes.tests folder for practical usage patterns.$slug = StringHelper::slugify('Laravel 10 Guide');
$shortened = StringHelper::truncate('A very long string...', 10);
$merged = ArrayHelper::mergeRecursive(
['a' => 1, 'b' => 2],
['a' => 2, 'c' => 3]
); // Returns ['a' => [1, 2], 'b' => 2, 'c' => 3]
$values = ArrayHelper::pluck($collection, 'key');
$normalized = PathHelper::normalize('/path/with/../duplicates');
$isImage = FileHelper::isImage('image.jpg');
$formatted = DateHelper::format('2023-10-01', 'Y-m-d H:i:s');
$timeAgo = DateHelper::timeAgo('2023-10-01 12:00:00');
// config/app.php
'aliases' => [
'StringHelper' => Windwalker\Utilities\Helper\StringHelper::class,
],
use Windwalker\Utilities\Facades\StringHelperFacade;
$slug = StringHelperFacade::slugify('Test String');
slugify + truncate).$this->app->singleton(StringHelper::class, function () {
return new StringHelper();
});
Namespace Conflicts
Windwalker\Utilities namespace. Ensure no conflicts with other Windwalker packages or custom namespaces.config/app.php.Performance Overhead
ArrayHelper::mergeRecursive) may be slower for large datasets.Undocumented Methods
Laravel-Specific Assumptions
FileHelper) assume filesystem operations are Laravel-compatible.Enable Strict Typing
If using PHP 7.4+, enable declare(strict_types=1) at the top of your file to catch type-related issues early.
Log Helper Outputs
For complex operations (e.g., ArrayHelper::mergeRecursive), log intermediate results:
\Log::debug('Merged array:', $mergedArray);
Check for Deprecations
The package follows semantic versioning (^4.0). Monitor the changelog for breaking changes.
Custom Helpers Extend existing helpers by creating child classes:
use Windwalker\Utilities\Helper\StringHelper;
class CustomStringHelper extends StringHelper {
public static function customSlugify($string) {
return parent::slugify($string) . '-custom';
}
}
Add New Utilities Contribute by adding methods to existing helpers or creating new ones. Follow the contribution guidelines.
Facade Integration Create a facade for easier access (if not already provided):
// app/Facades/CustomHelperFacade.php
namespace App\Facades;
use Illuminate\Support\Facades\Facade;
class CustomHelperFacade extends Facade {
protected static function getFacadeAccessor() {
return 'custom.helper';
}
}
Register in a service provider:
$this->app->bind('custom.helper', function () {
return new \Windwalker\Utilities\Helper\StringHelper();
});
PathHelper, ensure paths are resolved relative to Laravel’s base_path() if needed:
$absolutePath = base_path($relativePath);
How can I help you explore Laravel packages today?