PHP code example of phlib / flysystem-pdo

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

    

phlib / flysystem-pdo example snippets


use Phlib\Flysystem\Pdo\PdoAdapter;
use League\Flysystem\Filesystem;

$pdo        = new \PDO('mysql:host=hostname;dbname=database_name', 'username', 'password');
$adapter    = new PdoAdapter($pdo);
$filesystem = new Filesystem($adapter);

use League\Flysystem\Config;

$config = new Config([
    'enable_compression' => false,
    'visibility'         => AdapterInterface::VISIBILITY_PUBLIC
]); 
$adapter->writeStream('/path/to/file.zip', $handle, $config);

use League\Flysystem\Config;

$config = new Config([
    'table_prefix'            => 'flysystem',
    'enable_compression'      => true,
    'chunk_size'              => 1048576,
    'temp_dir'                => '/var/tmp',
    'disable_mysql_buffering' => true
]);
$adapter = new PdoAdapter($pdo, $config);

$config = new Config(['expiry' => date('Y-m-d H:i:s', strtotime('+2 days'))]);
$adapter->write($path, $content, $config);

$data = $adapter->getMetadata($path);
[
    'path' => '...',
    '...',
    'expiry' => ''
]

$config = new Config(['meta' => ['owner' => 'John Smith', 'permissions' => 600]]);
$adapter->write($path, $content, $config);

$data = $adapter->getMetadata($path);
[
    'path' => '...',
    '...',
    'meta' => [
        'owner' => 'John Smith',
        'permissions' => 600
    ]
]