Skip to content

Commit

Permalink
Doc
Browse files Browse the repository at this point in the history
  • Loading branch information
lennyrouanet committed Apr 29, 2022
1 parent 7b896c1 commit 6afff76
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,38 +34,15 @@ And this code when calling your assets :

## Exemple with a cache manager


Exemple with Symfony FilesystemAdapter :

```php
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Phant\AssetsVersions\AssetsVersions;


// cache

$cache = new FilesystemAdapter( 'my-app-cache' );


// assets versions

$callbackLoadCache = function() use ( $cache ): ?array {
return $cache->getItem( $item )->get( 'assets-versions' );
};

$callbackSaveCache = function( ?array $assetVersionCollection ) use ( $cache ) {
$cacheItem = $cache->getItem( 'assets-versions' );
$cacheItem->set( $assetVersionCollection );
$cacheItem->expiresAfter( 30 * 86400 ); // 30 days
$cache->save( $cacheItem );
};
use Phant\Cache\SimpleCache;

$assetsVersions = new AssetsVersions(
'public/', // path to be processed
[ 'css', 'js' ], // extensions to be processed
[ 'node_modules/' ], // path to be ignored in path to be processed
$callbackLoadCache, //callback load cache
$callbackSaveCache //callback save cache
new SimpleCache( '/my-cache-path/', 'my-app-cache', 30 * 86400 ) // cache adapter
);
```

Expand Down

0 comments on commit 6afff76

Please sign in to comment.