PHP code example of 00f100 / fcphp-repository

1. Go to this page and download the library: Download 00f100/fcphp-repository 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/ */

    

00f100 / fcphp-repository example snippets


namespace Path\To
{
    use FcPhp\Repository\Repository;

    class ExampleRepository extends Repository
    {

    }
}


use Exception;
use FcPhp\Di\Facades\DiFacade;
use FcPhp\Datasource\Factories\Factory;
use FcPhp\Cache\Facades\CacheFacade;
use FcPhp\Datasource\Interfaces\IQuery;

$di = DiFacade::getInstance();
$factory = new Factory($di);
$cache = CacheFacade::getInstance('path/to/cache');

use Path\To\ExampleRepository;

// See: github.com/00f100/fcphp-datasource
$datasource = new Datasource();

$callbackError = function(IQuery $query, Exception $e) {
    $this->assertInstanceOf(IQuery::class, $query);
    $this->assertInstanceOf(Exception::class, $e);
};

$instance = new ExampleRepository($datasource, $cache, $factory, $callbackError);

// Query
$query = $instance->getQuery();