sinarajabpour1998/alpha-helper
Alpha Helper is a small Laravel/PHP helper package providing convenient utility functions and shortcuts to speed up common tasks. Designed to be lightweight and easy to drop into existing projects for everyday development helpers.
Installation
composer require sinarajabpour1998/alpha-helper
Publish the config (if applicable):
php artisan vendor:publish --provider="AlphaHelper\AlphaHelperServiceProvider"
First Use Case
AlphaHelper::slugify('Hello World') directly in controllers/views.AlphaHelper::validateAlphaNumeric($request->input('field')).Where to Look First
vendor/sinarajabpour1998/alpha-helper/README.md for function lists.AlphaHelper facade provides all helper methods (e.g., AlphaHelper::randomString()).AlphaHelperServiceProvider for bootstrapped helpers.String Manipulation
// Slugify in a controller
$slug = AlphaHelper::slugify($request->title);
// Random string generation
$token = AlphaHelper::randomString(16);
Validation Integration
// Custom rule in FormRequest
$this->validate($request, [
'username' => ['required', 'string', AlphaHelper::class . '@validateAlphaNumeric']
]);
Array/Collection Helpers
// Flatten nested arrays
$flatArray = AlphaHelper::flattenArray($nestedArray);
// Merge arrays with custom logic
$merged = AlphaHelper::mergeArrays($array1, $array2, ['key' => 'custom_merge']);
Date/Time Utilities
// Format dates consistently
$formatted = AlphaHelper::formatDate($date, 'Y-m-d H:i:s');
// Timezone conversions
$utcTime = AlphaHelper::convertTimezone($date, 'UTC');
API Response Wrapping
// Standardized API responses
return AlphaHelper::apiResponse($data, 'Success', 200);
$this->app->bind('custom.helper', function () {
return new AlphaHelper();
});
Blade::directive('slugify', function ($expression) {
return "<?php echo AlphaHelper::slugify({$expression}); ?>";
});
public function handle()
{
$cleanData = AlphaHelper::sanitizeInput($this->data);
// Process $cleanData
}
Namespace Collisions
AlphaHelper facade, ensure no other package/class shadows the namespace.\AlphaHelper\AlphaHelper::slugify()).Validation Rule Conflicts
validateAlphaNumeric) may conflict with Laravel’s built-in rules.alpha|alpha_numeric).Performance Overhead
Undocumented Methods
vendor/sinarajabpour1998/alpha-helper/src/) for undocumented features.\Log::debug('Slugified:', ['input' => $input, 'output' => AlphaHelper::slugify($input)]);
null, or malformed inputs (e.g., AlphaHelper::slugify(null)).// Override in tests
AlphaHelper::shouldReceive('slugify')->andReturn('test-slug');
Custom Helpers
namespace App\Helpers;
use AlphaHelper\AlphaHelper as BaseHelper;
class AppHelper extends BaseHelper {
public static function customHelper($input) {
return parent::slugify($input) . '-app';
}
}
Configuration Overrides
'slugify' => [
'separator' => '-',
'lowercase' => true,
],
Macro Support
AlphaHelper facade for reusable logic:
AlphaHelper::macro('customMacro', function ($arg) {
return "Processed: {$arg}";
});
Testing
$this->partialMock(AlphaHelper::class, ['slugify'])
->shouldReceive('slugify')
->andReturn('mocked-slug');
How can I help you explore Laravel packages today?