Str::length()) by adding binary-safe operations (critical for handling raw bytes, e.g., in file uploads or network protocols).spatie/laravel-permission, laravel/sanitizer), but could augment them for niche use cases (e.g., protocol buffers, custom serialization).binarySafeStrlen()) can be bolted into existing code without major refactoring.hash_equals alternatives).binarySafeStrlen() are not encryption or validation tools—misuse could introduce vulnerabilities (e.g., treating sanitized input as secure).binarySafeStrlen() in a Sanitizer facade).strlen behavior changes).Str::length() already handles binary data in Laravel 9+. What specific gap does this fill?paragonie/sodium_compat, defuse/security) with active maintenance?App\Http\Middleware\TrimStrings)?mb_strlen or Stringable helpers?hash_equals alternatives).strlen($rawInput) → binarySafeStrlen($rawInput)).composer require ircmaxell/security-lib:dev-main).// app/Providers/SecurityServiceProvider.php
public function register() {
$this->app->singleton('security', function () {
return new \SecurityLib\Security();
});
}
strlen calls with app('security')->binarySafeStrlen().strlen("\xFF") vs. binarySafeStrlen("\xFF")).Str::of($bytes)->length()).composer.json autoload to avoid conflicts (e.g., SecurityLib\Security → App\Security\LegacySecurity).hash_equals → hash_equals() with hash_algos() checks).create_function (removed in PHP 7.2).booting/booted lifecycle.| Phase | Task | Dependencies |
|---|---|---|
| Discovery | Map all strlen/strpos usages in codebase. |
Code search tools (e.g., PHPStan). |
| Proof of Concept | Replace 1–2 critical paths with SecurityLib utilities. |
Manual testing. |
| Service Layer | Wrap utilities in Laravel services/facades. | Service Provider registration. |
| Testing | Fuzz test binary edge cases; compare with Laravel’s Str helpers. |
Custom test suites. |
| Deprecation | Phase out original strlen calls; monitor for regressions. |
CI/CD pipeline. |
| Maintenance | Fork and patch if upstream is abandoned. | GitHub mirror setup. |
SecurityLib exceptions will lack framework context.binarySafeStrlen).strlen fails for UTF-8).How can I help you explore Laravel packages today?