PHP code example of contenir / contenir-asset
1. Go to this page and download the library: Download contenir/contenir-asset library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
contenir / contenir-asset example snippets
// Your asset entity: the standard columns come from BaseAssetEntity.
#[Table('asset')]
final class Asset extends BaseAssetEntity
{
#[Column('entry_id')]
public ?int $entryId = null;
}
// config/autoload/asset.global.php
return ['asset' => ['entity' => Asset::class]];
// In a controller or service:
$asset = $assetManager->addAsset($entry, $currentUser); // links entry_id and user_id
$assetManager->storeAsset($asset, $entry, 'image', $_FILES['photo'], '1200x800');
<!-- In a view -->
<img src="<?= $this->escapeHtmlAttr($this->asset($id)?->imageLg ?? "")