FileServiceInterface ​
File: src/Services/FileLibrary/FileServiceInterface.php
Contract that all FileLibrary drivers must implement. Currently defines a single method for retrieving a file URL by its stored identifier.
Interface Definition ​
php
interface FileServiceInterface
{
public function getUrl(string $id): string;
}Methods ​
| Method | Signature | Description |
|---|---|---|
getUrl | getUrl($id): string | Returns the public URL for the file identified by $id |
Implementing a Custom Driver ​
php
use Unusualify\Modularous\Services\FileLibrary\FileServiceInterface;
class MyCloudStorage implements FileServiceInterface
{
public function getUrl($id): string
{
return 'https://cdn.example.com/files/' . $id;
}
}Register the custom driver in a service provider:
php
$this->app->bind('fileService', MyCloudStorage::class);Facade ​
The FileService Laravel Facade resolves to whatever class is bound to fileService in the container. The default binding is the Disk driver.
php
use Unusualify\Modularous\Facades\FileService;
$url = FileService::getUrl($file->uuid);