arcanedev/support
ARCANEDEV Support provides shared helpers and utilities for ARCANEDEV and Laravel projects. A lightweight toolkit of common support classes and convenience functions, compatible across Laravel 5.1 through 10.x.
Installation Add the package via Composer:
composer require arcanedev/support
Publish the config (if needed):
php artisan vendor:publish --provider="ArcaneDev\Support\ArcaneDevSupportServiceProvider" --tag="config"
Key Entry Points
ArcaneDev\Support\Facades\Support: The main facade for utility methods.config/arcane-dev-support.php: Centralized configuration for package settings.app/Providers/ArcaneDevSupportServiceProvider.php: Registers macros, helpers, and bindings.First Use Case
Use the Support::str() helper to sanitize and manipulate strings:
use ArcaneDev\Support\Facades\Support;
$cleaned = Support::str()->slug('Hello World!'); // Returns "hello-world"
String Manipulation Chain methods for robust string handling:
Support::str()
->trim(' extra spaces ')
->slug('User Input')
->toUpper();
Collection Enhancements Extend Laravel collections with custom methods:
$collection = collect([1, 2, 3]);
$chunked = $collection->chunkBy(2); // [[1, 2], [3]]
Model/Query Helpers Add scopes or accessors dynamically:
// In a model:
use ArcaneDev\Support\Traits\HasScopes;
class Post extends Model
{
use HasScopes;
public function scopePublished($query)
{
return $query->where('published_at', '<=', now());
}
}
Request/Response Utilities Validate and transform requests/responses:
$validated = Support::request()->validate([
'email' => 'required|email',
]);
Macros & Customization
Register global helpers in AppServiceProvider:
Support::macro('customHelper', function ($input) {
return strtolower($input) . '_suffix';
});
HasScopes, HasAccessors, or HasMutators in models for reusable logic.config/arcane-dev-support.php (e.g., default_locale, timezone).Support facade in tests:
$this->mock(Support::class)->shouldReceive('str()->slug')->andReturn('test-slug');
Facade vs. Helper Confusion
Support::str() for chaining, but direct helpers like Support::slug() may not chain.Collection Method Conflicts
chunkBy() → arcaneChunkBy()) or namespace them.Overriding Default Config
config/arcane-dev-support.php.Macro Scope Leaks
AppServiceProvider can affect all tests.Support::macro() sparingly or reset macros in setUp():
public function setUp(): void
{
Support::macro('customHelper', null); // Unregister
parent::setUp();
}
dd(Support::getMacroMethods()); // List all registered macros
dd(collect([])->getMethods()); // Debug available methods
debug to true in config to log helper usage (helpful for troubleshooting).Add Custom Helpers
Extend the Support facade in a service provider:
Support::extend('custom', function () {
return new class {
public function example($input) { return $input * 2; }
};
});
Usage:
Support::custom()->example(5); // Returns 10
Create Reusable Traits
Build domain-specific traits (e.g., HasSoftDeletesWithAudit) and share them across projects.
Override Default Behaviors
Replace core helpers by redefining them in your AppServiceProvider:
Support::macro('slug', function ($string) {
return strtolower(preg_replace('/[^a-z0-9]+/', '-', $string));
});
Localization Support
Use the trans helper with custom fallback logic:
Support::trans('messages.welcome', [], 'en', 'Default Welcome');
How can I help you explore Laravel packages today?