Skip to content

o6web/AssetManager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AssetManager

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.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages