1. Go to this page and download the library: Download jbernavaprah/eloquent-fs 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/ */
jbernavaprah / eloquent-fs example snippets
touch('efs://file.txt'); // file.txt will be ID of this file.
file_put_contents('efs://file.txt', "foobar\n");
echo file_get_contents('efs://file.txt'); // "foobar\n"
copy('efs://file.txt', 'efs://other_file.txt');
echo file_get_contents('efs://other_file.txt'); // "foobar\n"
unlink('efs://file.txt');
unlink('efs://other_file.txt');
use JBernavaPrah\EloquentFS\Models\FsFile;
$file = new FsFile();
$file->id = 'file.txt'; // if not provided, will generated as uuid
$file->write("foobar", $append=true); // 6
$file->read($offset =3, $length = 3); // "bar"
$file->read($offset =0, $length = 6); // "foobar"
$file->write("foobar", $append=true); // 6
$file->read(); // foobarfoobar
$file->delete(); // Delete