o6web/asset-manager

There is no license information available for the latest version (4.1.0) of this package.

System for handling assets on O6 Web Properties sites

Installs: 14

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/o6web/asset-manager

4.1.0 2025-12-26 17:44 UTC

README

Package for managing asset files used by O6 Web Properties sites. Prior to version 4.0.0, this was an internal package. We've opened it up in case it proves helpful for anyone else but future development will be based on O6's needs.

Usage

use o6web\AssetManager\AssetManager;
use o6web\AssetManager\AssetSource;

$assetManager = new AssetManager($pdo);

// Asset sources can be local paths or S3 buckets

// Source type "static" is meant for files where the filename is unique and the contents don't typically change 
$source = new AssetSource(['path' => '/path/to/static/files/']);
$assetManager->setSource($source, AssetSource::TypeStatic);

// Source type "dynamic" is meant for files that change often or need to be associated with a database record, such as user-uploaded files
$source = new AssetSource(['s3Client' => $s3Client, 'bucket' => $bucket]);
$assetManager->setSource($source, AssetSource::TypeDynamic);

// Check if an asset exists
$assetManager->assetFileExists($asset_path);

// Delete a dynamic asset and remove its record in the `asset` table
$assetManager->deleteDynamicAsset($asset_id);

// Upload a dynamic asset and create a record for it in the `asset` table
$assetManager->uploadDynamicAssetFile($source_path);

// Get a local copy of an asset (if necessary)
$assetPath = $assetManager->getAssetLocalPath($asset_path, AssetSource::TypeDynamic);

// Get the path of the local asset
$assetPath->getPath();

Installation

  1. Add a dependency on o6web/asset-manager to your composer.json file if you use Composer to manage the dependencies of your project:
composer require o6web/asset-manager

Although it's recommended to use Composer, you can actually include the file(s) any way you want.

  1. Run the deploy/install.sql script to create the necessary database tables.

License

AssetManager is MIT licensed.