Exemple #1
0
use FileSystem\Disk;
use FileSystem\Disks\Manager as Disks;
use FileSystem\File;
use FileSystem\FileSystem;
use FileSystem\FileTree;
use FileSystem\Manager;
use FileSystem\Root;
use function FileSystem\inside;
require __DIR__ . '/../vendor/autoload.php';
$disks = new Disks();
$disks->add(new Disk('local', __DIR__ . '/root', new LocalFileSystem()));
$manager = new Manager($disks);
$tree = new FileTree();
$fileSystem = new FileSystem($tree, $manager);
$root = new Root();
$application = new Directory('application', $root);
$fileSystem->make($application);
$dashboard = new File('dashboard.php', $application);
$dashboard->write('awesome content');
$fileSystem->write($dashboard);
$themes = new Directory('themes', $root);
$eyedouble = new Directory('eyedouble', $root);
$fileSystem->make($themes);
$fileSystem->make($eyedouble, inside($themes));
$storage = new Directory('storage', $root);
$store = new File('store.php', $root);
$fileSystem->make($storage);
$fileSystem->write($store, inside($storage));
$store->write('my awesome stored content');
$fileSystem->write($store);
dump($fileSystem->findFilesIn($application));
<?php

use FileSystem\Directory;
use FileSystem\File;
use FileSystem\Root;
require __DIR__ . '/../vendor/autoload.php';
$root = new Root();
$application = new Directory('application', $root);
$dashboard = new File('dashboard.php', $application);
$dashboard->moveTo($root);
// $application->remove ( $dashboard );
$dashboard->renameTo('new-dashboard.php');
dump($root->objects['application']->parent);
dump($dashboard->name);
<?php

/*
|--------------------------------------------------------------------------
| Somewhere within your application.
|--------------------------------------------------------------------------
|
| This is just an example of what you can do. Input is the input the user of 
| your application provided.
*/
use FileSystem\File;
$application->bind('FileSystem\\File', function (Input $input) {
    $file = new File($input->get('name'));
    $file->write($input->get('contents'));
    return $file;
});
/*
|--------------------------------------------------------------------------
| Your business logic.
|--------------------------------------------------------------------------
*/
use FileSystem\File;
when('i want to read a file', then(apply(a(function (File $file) {
    echo $file->contents;
}))));