PHP code example of modera / file-repository-bundle

1. Go to this page and download the library: Download modera/file-repository-bundle 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/ */

    

modera / file-repository-bundle example snippets

 php

// config/bundles.php

return [
    // ...
    Knp\Bundle\GaufretteBundle\KnpGaufretteBundle::class => ['all' => true], // if you still don't have it
    Modera\FileRepositoryBundle\ModeraFileRepositoryBundle::class => ['all' => true],
];
 php


/* @var \Modera\FileRepositoryBundle\Repository\FileRepository $fr */
$fr = $container->get('modera_file_repository.repository.file_repository');

$repositoryConfig = array(
    'filesystem' => 'local_fs'
);

$fr->createRepository('my_repository', $repositoryConfig, 'My dummy repository');

$dummyFile = new \SplFileInfo('dummy-file.txt');

/* @var \Modera\FileRepositoryBundle\Entity\StoredFile $storedFile */
$storedFile = $fr->put('my_repository', $dummyFile);
 php


/* @var \Modera\FileRepositoryBundle\Repository\FileRepository $fr */
$fr = $container->get('modera_file_repository.repository.file_repository');

$repositoryConfig = array(
    'filesystem' => 'local_fs',
    'interceptors' => [
        \Modera\FileRepositoryBundle\ThumbnailsGenerator\Interceptor::ID,
    ],
    'thumbnail_sizes' => array(
        array(
            'width' => 300,
            'height' => 150
        ),
        array(
            'width' => 32,
            'height' => 32
        )
    )
);

$fr->createRepository('vacation_pictures', $repositoryConfig, 'Pictures from vacation');