PHP code example of prolix / file-system-bundle

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

    

prolix / file-system-bundle example snippets


$bundles = array(
    ...
    new Kitpages\FileSystemBundle\KitpagesFileSystemBundle(),
);



// use AdapterFile at the beginning of the file
use Kitpages\FileSystemBundle\Model\AdapterFile;

// get the adapter
$localAdapter = $this->get("kitpages_file_system.file_system.kitpagesFile");
$s3Adapter = $this->get("kitpages_file_system.file_system.kitpagesAmazon");

// private files (without direct public URL)
$adapter->copyTempToAdapter("/my_physical_dir/foo.txt", new AdapterFile("bar/foo.txt") );
$adapter->copyAdapterToTemp(new AdapterFile("bar/foo.txt"), "/my_physical_dir/foo.txt" );

// public files (with a direct URL given by the adapter)
$adapter->copyTempToAdapter("/my_physical_dir/foo.txt", new AdapterFile("bar/foo.txt", true) );
$url = $adapter->getFileLocation(new AdapterFile("bar/foo.txt", true));

// some functions of the adapter :
$adapterFile = new AdapterFile("bar/foo.txt");
$adapter->copyTempToAdapter("/my_physical_dir/foo.txt", $adapterFile );
$content = $adapter->getFileContent($adapterFile);
$adapter->sendFileToBrowser($adapterFile);
if ($adapter->isFile($adapterFile) ) {
    // if file exists in the adapter
}
 javascript
{
  "rvices/aws-sdk-for-php: ~1.5
  }
}
bash
cd Tests/app/web
php -S localhost:8888