PHP code example of bnine / filesbundle

1. Go to this page and download the library: Download bnine/filesbundle 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/ */

    

bnine / filesbundle example snippets


Bnine\FilesBundle\BnineFilesBundle::class => ['all' => true],

use Bnine\FilesBundle\Form\Type\IconUploadType;

$builder->add('avatar', IconType::class, [
    'label' => false,
    'r/0?path=&crop',
]);

class FileVoter extends AbstractFileVoter
{
    private const PUBLIC_DOMAINS = ['avatar', 'logo', 'icon'];

    protected function canView(string $domain, $id, TokenInterface $token): bool
    {
        if (in_array($domain, self::PUBLIC_DOMAINS)) {
            return true;
        }
        return $this->canManage($domain, $id, $token);
    }

    // canEdit, canDelete...
}
twig
<img src="{{ bninefile(user.avatar) }}" alt="Avatar">
<img src="{{ bninefile(group.logo) }}" alt="Logo">