PHP code example of lucid / resource

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

    

lucid / resource example snippets



use Lucid\Resource\Locator;

$locator = new Loacor(['/path/to/dirA', '/path/to/dirB']);

foreach ($locator->locate('config.php') as $resource) {
	$resource->... // do stuff
}



use Lucid\Resource\FileResource;

$res = new FileResource($file);
$res->getResource(); // returns "/path/file"

$res->isValid($time) // if not mofified since $time


use Lucid\Resource\ObjectResource;
use Acme\MyObject;

$res = new ObjectResource(new MyObject);
$res->getResource(); // returns "/path/to/Acme/MyObject.php

$res->isValid($time) // if not mofified since $time


use Lucid\Resource\Collection;
use Lucid\Resource\FileResource;
use Lucid\Resource\ObjectResource;

$resources = new Collection();

$resources->addResource(new ObjectResource($onject));
$resources->addResource(new FileResource($file));

$resources->addObjectResource($object);
$resources->addFileResource($file);

$resources->all(); // [ObjectResource $resource, FileResource $resource, ... ]

$resources->isValid(time()); // bool

php >= 5.6