PHP code example of lechimp-p / flightcontrol

1. Go to this page and download the library: Download lechimp-p/flightcontrol 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/ */

    

lechimp-p / flightcontrol example snippets




League\Flysystem\Adapter\Local;
use \League\Flysystem\Filesystem;
use \Lechimp\Flightcontrol\Flightcontrol;

$adapter = new Local(__DIR__, LOCK_EX, Local::SKIP_LINKS);
$flysystem = new Filesystem($adapter);

$flightcontrol = new Flightcontrol($flysystem);




// base directory from the flysystem:
$root = $flightcontrol->get("/");
assert($root !== null);
assert($root instanceof \Lechimp\Flightcontrol\FSObject);

// the tests directory:
$tests = $flightcontrol->directory("/tests");
assert($tests !== null);
assert($tests instanceof \Lechimp\Flightcontrol\Directory);

// this file:
$readme = $flightcontrol->file("/README.md");  
assert($readme !== null);
assert($readme instanceof \Lechimp\Flightcontrol\File);




// properties of every filesystem object:
echo '$tests->path() == '.$tests->path()."\n";
assert($tests->path() == "/tests");
echo '$tests->name() == '.$tests->name()."\n";
assert($tests->name() == "tests");

// properties of files:
echo '$readme->timestamp() == '.$readme->timestamp()."\n";
assert(is_string($readme->timestamp()) || is_int($readme->timestamp()));
echo '$readme->mimetype() == '.$readme->mimetype()."\n";
assert($readme->mimetype() == "text/plain");
echo '$readme->content()'."\n";
assert(is_string($readme->content()));

// properties of directories:
$contents = $tests->contents();
echo '$tests->contents()'."\n";
assert(count($contents) > 0);
assert($contents[0] instanceof \Lechimp\Flightcontrol\FSObject);