storage-common, blob, and file-share packages) reinforces its modular design. This change reduces duplication and centralizes timestamp formatting, aligning better with Laravel’s principle of single responsibility per component. The shared helper can be injected into Laravel’s service container as a singleton, ensuring consistency across all Azure Storage interactions.config/services.php by allowing a single configuration point for SAS token generation (e.g., config('services.azure.sas_expiry')). This reduces boilerplate in controllers/services that generate pre-signed URLs.sas.token.generated) for audit logging or analytics, though this requires custom integration.Log facade and HttpClient implementations.Storage facade or custom filesystem adapters (e.g., AzureBlobFilesystem). Example:
use App\Services\AzureSasGenerator;
$sasToken = app(AzureSasGenerator::class)->generate(
container: 'my-container',
blob: 'file.txt',
expiry: now()->addHours(1)
);
storage-common layer changes. Risk: Potential for cascading updates if the shared helper’s API evolves.AzureSasGenerator in your test suite.config/services.php override the shared helper’s default expiry or permissions (e.g., read-only vs. read-write)?Filesystem adapter for SAS-generated URLs (e.g., storage_disk('azure')->url($path))?InvalidArgumentException)?.env:
AZURE_SAS_EXPIRY_MINUTES=60
AZURE_SAS_PERMISSIONS=rwdl # Read, write, delete, list
Bind to Laravel’s config:
'azure' => [
'sas' => [
'expiry' => env('AZURE_SAS_EXPIRY_MINUTES', 60),
'permissions' => env('AZURE_SAS_PERMISSIONS', 'rwdl'),
],
],
$this->app->singleton(AzureSasGenerator::class, fn() => new AzureSasGenerator(
config('services.azure.connection_string'),
config('services.azure.sas')
));
FilesystemManager to support SAS URLs:
// app/Providers/AzureFilesystemServiceProvider.php
public function register()
{
Storage::extend('azure-sas', function () {
return new AzureSasFilesystem(
Storage::disk('azure'),
app(AzureSasGenerator::class)
);
});
}
AzureSasGenerator in Laravel’s Mockery tests:
$mockSas = Mockery::mock(AzureSasGenerator::class);
$mockSas->shouldReceive('generate')->andReturn('shared-sas-token');
$this->app->instance(AzureSasGenerator::class, $mockSas);
config/services.php to use centralized SAS settings.azure-sas disk driver for temporary shared URLs.$url = Storage::disk('azure-sas')->url('file.txt');
deprecated() helper.if (method_exists($this, 'legacyGenerateSas')) {
deprecated('legacyGenerateSas()', '2024-12-01');
}
composer.json to require the new package versions:
"require": {
"vendor/azure-storage-common": "^2.1.1",
"vendor/azure-storage-blob": "^2.1.0"
}
$sasToken = Cache::remember("sas:{$container}:{$blob}", now()->addHours(1), fn() =>
app(AzureSasGenerator::class)->generate($container, $blob)
);
AzureSasGenerator singleton and configure it via config/services.php.app(AzureSasGenerator::class)->generate()).Storage facade works with the new azure-sas disk driver.php artisan optimize:clear and check for deprecation warnings.storage-common package for changes to the shared helper. Action: Subscribe to its GitHub releases and test updates in a staging environment.deprecated() helper to phase out old methods.app(AzureSasGenerator::class)").AZURE_SAS_EXPIRY_MINUTES and AZURE_SAS_PERMISSIONS.tap() to inspect SAS tokens:
$token = app(AzureSasGenerator::class)->generate(...)->tap(fn($token) => Log::debug('Generated SAS:', ['token' => substr($token, 0, 20)]));
laravel for better tracking.phpbench in a Laravel context.How can I help you explore Laravel packages today?