PHP code example of sarcio / shim

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

    

sarcio / shim example snippets


use Sarcio\Shim\Cache\ApcuRouteSetCache;
use Sarcio\Shim\Shim;
use Sarcio\Shim\Transport\InMemoryPatchCache;
use Sarcio\Shim\Transport\PullTransport;

$transport = new PullTransport('https://acme.sarcio.io', 'pk_your_site', 'sk_your_site', new InMemoryPatchCache());
$shim = new Shim('', 'pk_your_site', new ApcuRouteSetCache(), transport: $transport);

$ctx = $request->attributes->get('sarcio'); // ['skipValidations' => [...], 'config' => [...]]
if (!in_array('referralCodeRequired', $ctx['skipValidations'] ?? [], true)) {
    // enforce the rule as normal
}

new FileSwapApplier($dsn, $siteKey, $appRoot, $backupDir, 1.0, $token,
    new Sarcio\Shim\State\JsonFileSwapState('/var/lib/sarcio/state.json'));