PHP code example of aedart / athenaeum-flysystem-db

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

    

aedart / athenaeum-flysystem-db example snippets


use Aedart\Flysystem\Db\Adapters\DatabaseAdapter;
use Illuminate\Database\Capsule\Manager as Capsule;
use League\Flysystem\Filesystem;

// Establish database connection
$capsule = new Capsule;
$capsule->addConnection([
    'driver' => 'mysql',
    'host' => 'localhost',
    'database' => 'database',
    'username' => 'root',
    'password' => 'password',
    'charset' => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix' => '',
]);

$connection = $capsule->getConnection();

// Create Database Adapter instance
$adapter = new DatabaseAdapter(
    filesTable: 'files',
    contentsTable: 'files_contents',
    connection: $connection
);

// Finally, create filesystem instance
$filesystem = new Filesystem($adapter);