PHP Class Puli\Repository\OptimizedJsonRepository
The generated JSON file is described by res/schema/repository-schema-1.0.json.
Resources can be added with the method {@link add()}:
php
use Puli\Repository\OptimizedJsonRepository;
$repo = new OptimizedJsonRepository('/path/to/repository.json', '/path/to/project');
$repo->add('/css', new DirectoryResource('/path/to/project/res/css'));
When adding a resource, the added filesystem path is stored in the JSON file
under the key of the Puli path. The path is stored relatively to the base
directory passed to the constructor. Directories will be expanded and all
nested files will be added to the mapping file as well:
json
{
"/css": "res/css",
"/css/style.css": "res/css/style.css"
}
Mapped resources can be read with the method {@link get()}:
php
$cssPath = $repo->get('/css')->getFilesystemPath();
You can also access nested files:
php
echo $repo->get('/css/style.css')->getBody();
Since nested files are searched during {@link add()} and added to the JSON
file, this repository does not detect any files that you add to a directory
after adding that directory to the repository. This means that accessing
files is very fast, but also that the usage of this repository implementation
can be cumbersome in development environments. There you are recommended to
use {@link JsonRepository} instead.
Afficher le fichier
Open project: puli/repository
Méthodes publiques
Méthode |
Description |
|
clear ( ) |
|
|
Méthodes protégées
Method Details
addFilesystemResource()
protected méthode
protected addFilesystemResource ( $path, Puli\Repository\Api\Resource\FilesystemResource $resource ) |
$resource |
Puli\Repository\Api\Resource\FilesystemResource |
|
getReferencesForGlob()
protected méthode
getReferencesForPath()
protected méthode
getReferencesForRegex()
protected méthode
getReferencesInDirectory()
protected méthode
insertReference()
protected méthode
removeReferences()
protected méthode