SvgConverterManager
Laratusk\Larasvg\SvgConverterManager
The manager class is responsible for provider selection, file opening, and creating converter instances.
Constructor
public function __construct(Application $app)Receives the Laravel application container.
Methods
open(string $path): Provider
Open a local file for processing.
$converter = $manager->open(resource_path('svg/file.svg'));- Verifies the file exists
- Creates a converter instance using the current provider
- Throws:
SvgConverterExceptionif the file does not exist
openFromDisk(string $disk, string $path): Provider
Open a file from a Laravel filesystem disk.
$converter = $manager->openFromDisk('s3', 'designs/logo.svg');- Downloads the file to a temporary location
- Temporary files are cleaned up automatically
- Throws:
SvgConverterExceptionif the file does not exist on the disk
openFromContent(string $content, string $extension = 'svg'): Provider
Open from raw file content (string).
$converter = $manager->openFromContent($svgString);- Writes content to a temporary file
- Temporary files are cleaned up automatically
using(string $provider): static
Switch provider for the next operation.
$manager->using('inkscape')->open(resource_path('svg/file.svg'));The provider resets to the default after the next open() / openFromDisk() / openFromContent() call.
version(?string $provider = null): string
Get the version string of the given or default provider.
$version = $manager->version();
$version = $manager->version('inkscape');actionList(): string
Get the list of available Inkscape actions. Only works with the Inkscape provider.
- Throws:
SvgConverterExceptionif the current provider is not Inkscape
getBinary(?string $provider = null): string
Get the configured binary path for the given or default provider.
$binary = $manager->getBinary(); // 'resvg'
$binary = $manager->getBinary('inkscape'); // 'inkscape'getTimeout(?string $provider = null): int
Get the configured timeout in seconds for the given or default provider.
$timeout = $manager->getTimeout(); // 60getDefaultDisk(): string
Get the configured default filesystem disk name.
$disk = $manager->getDefaultDisk(); // 'local'