A filesystem-like repository for storing arbitrary resources.

Related tags

Laravel repository
Overview

The Puli Repository Component

Build Status Build status Scrutinizer Code Quality Latest Stable Version Total Downloads Dependency Status

Latest release: 1.0.0-beta10

PHP >= 5.3.9

The Puli Repository Component provides an API for storing arbitrary resources in a filesystem-like repository:

use Puli\Repository\InMemoryRepository;
use Puli\Repository\Resource\DirectoryResource;

$repo = new InMemoryRepository();
$repo->add('/config', new DirectoryResource('/path/to/resources/config'));

// /path/to/resources/config/routing.yml
echo $repo->get('/config/routing.yml')->getBody();

The following ResourceRepository implementations are currently supported:

The following Resource implementations are currently supported:

Authors

Installation

Follow the [Getting Started] guide to install Puli in your project.

Documentation

Read the Puli Documentation to learn more about Puli.

Contribute

Contributions to Puli are always welcome!

Support

If you are having problems, send a mail to [email protected] or shout out to @webmozart on Twitter.

License

All contents of this package are licensed under the MIT license.

Comments
  • Fix real files removal in FilesystemRepository::clear with symlinks enabled

    Fix real files removal in FilesystemRepository::clear with symlinks enabled

    Fix puli/issues#178

    The build cli command do two things: clear the repository and rebuild it. To clean the repository, the manager call the method clear of the configured repository (in our case FilsystemRepository).

    In the FilesystemRepository, clear calls removeResource on all the resources in the repository. When using the FilesystemRepository with symlinks, it means removeResource is called on all the links present in .puli/path-mappings. However, removeResource is, for the moment, always recursive: all the children of the given path will be removed before trying to remove the path itself.

    When trying to remove a directory link, removeResource list all its children to remove them: however, the children of a directory link are the real children in the filesystem. So the real files are removed.

    This PR fixes this.

    opened by tgalopin 21
  • [READY] Implement PathMappingRepository (development version of OptimizedPathMappingRepository)

    [READY] Implement PathMappingRepository (development version of OptimizedPathMappingRepository)

    Following the OptimizedPathMapping repository (puli/repository#27), I implemented a development version of this repository, as proposed by @webmozart in puli/issues#80. This pull-request is a place to debate over the code.

    I did three main things:

    1. Create the repository

    https://github.com/tgalopin/repository/blob/dev-path-mapping/src/PathMappingRepository.php

    The repository follows these rules:

    • When a resource is added, the association repositoryPath => filesystemPath is stored in the KeyValueStore, and the parents of the repositoryPath are created as virtual resources ;
    • When a resource is fetched (using get() or other methods), its repositoryPath is resolved to a filesystemPath: the repository find the list of virtual resources matching the searched resource repositoryPath and try to find a real directory / file corresponding to the resource in each of these virtual resources ;

    This technique is much slower than the optimized version (obviously :) ) but it's a really useful tool for development as the structure inside virtual resources can change without having to "recreate" the puli repository.

    2. Add a build structure system in tests

    https://github.com/tgalopin/repository/blob/dev-path-mapping/tests/AbstractRepositoryTest.php#L62

    This repository was not possible to test using the exact same tests as before as when we are requesting a resources, it can be either a virtual or a real one, and tests have to check for both at the same time.

    I had to create a real valid structure on filesystem according to the tests: I couldn't without altering a bit the existing tests.

    I added a buildStructure method, called on each built resources (for instance https://github.com/tgalopin/repository/blob/dev-path-mapping/tests/AbstractRepositoryTest.php#L102) that by default return the root resource to be compatible with other repositories tests.

    But in the PathMappingRepository tests, this method create the structure (https://github.com/tgalopin/repository/blob/dev-path-mapping/tests/PathMappingRepositoryTest.php#L113) for tests to work properly.

    3. Create the specific tests for the PathMappingRepository

    Once the built structure ready, I fixed the repository to pass the tests (https://github.com/tgalopin/repository/blob/dev-path-mapping/tests/PathMappingRepositoryTest.php).

    I'm very open to modifications, expecially on how find() and contains() work as I'm not sure it's the best algorithm possible.

    opened by tgalopin 18
  • * failing test to show problem with resolving childrens file systempaths

    * failing test to show problem with resolving childrens file systempaths

    This PR shows a problem with resolving children filesystempaths.

    PathMappingRepository.php Line 226
    $filesystemPath = substr_replace($path, rtrim($filesystemBasePath, '/').'/', 0, strlen($basePath));
    

    If you use find to resolve the children, the filesystemPath contains after this line potential '//' in the path and this doesn't match than in the "getFilesystemPathChildren" method and so no correct repository path is set.

    Potential Bugfix is to replace all '//' with '/' in the filesystemPath

    opened by Engerim 10
  • Introduce ChangeStream and ResourceStack for resources versionning

    Introduce ChangeStream and ResourceStack for resources versionning

    Fix https://github.com/puli/issues/issues/90.

    This PR aims to introduce two concepts:

    • the ChangeStream that log every resource modification on all the repositories (it's shared between repositories)
    • the ResourceStack which is a ResourceCollection representing all the versions of a resource over the time

    The ChangeStream, when provided in a repository, store as a simple array a representation of all the resources given to it by the repositories. Using simple arrays let PHP remove old resources objects.

    If you want to retreive previous versions of a resource, you can access a classical resource and use the method getStack() on it:

    $repository->get('/tgalopin/foo/bar')->getStack();
    

    Internally, this method calls the ChangeStream to build a ResourceStack for the given resource path (here /tgalopin/foo/bar).

    This PR is a work in progress but the main last thing to do is testing.

    opened by tgalopin 9
  • Fix Windows symlink time information

    Fix Windows symlink time information

    On Windows, symlink does not work like on Unix, the OS think it is a real file like another. So for time operations, it only see changes on the symlink file and not the original one. That mean fileXtime functions get info about the symlink file too.

    So if you make some changes in the original file, Puli will not seen anything if this file is register in the repository as a symlink. It work as espected for files in a symlink directory.

    opened by WedgeSama 9
  • Implement auto-resolvment of directories links

    Implement auto-resolvment of directories links

    Fix https://github.com/puli/issues/issues/125.

    As suggested by @webmozart, it should be possible to access the children of a directory link seemlessly, ie something like:

    $repo = new InMemoryRepository();
    $repo->add('/dir', new DirectoryResource('/some/directory'));
    $repo->add('/dir-link', new LinkResource('/dir'));
    $repo->get('/dir-link/file');
    

    This PR aims to implement this.

    opened by tgalopin 8
  • Implement OptimizedPathMappingRepository

    Implement OptimizedPathMappingRepository

    As explained in puli/issues#80, I implemented an optmized version of the PathMappingRepository. This pull-request is not ready for the moment, please do not merge it now. It's just a place for dicussion about the code.

    I want to explain what I did and what I plan to do to discuss, especially with @webmozart :) .

    1. Create the repository ✓

    https://github.com/puli/repository/compare/1.0...tgalopin:path-mapping?diff=unified&name=path-mapping#diff-55bbc453f8c7d643ba2cd09cc280c00f

    As discussed with @webmozart, optimized and not optimized versions of the PathMappingRepository are completely different in code, it makes sense to separate them. I created the optimized version only for the moment and I'll open another pull-request for the classical one.

    2. Create a GenericFilesystemResource ✓

    https://github.com/puli/repository/compare/1.0...tgalopin:path-mapping?diff=unified&name=path-mapping#diff-2ba3bf2e348a04a316173aba204de2d9

    It's the best solution I found to store a virtual directory in the repository. Here is the problem:

    • I want to store only FilesystemResource instances in the repository ;
    • However, when someone add the path /webmozart/puli/file1, the paths /webmozart and /webmozart/puli should be created if they does not exist. But they don't have to represent a real file on the system ;

    So I created this class to represent a generic, virtual filesystem resource usable in the repository while not having any real file / directory behind it. Perhaps are there better ways or just a better name for this class, please tell me if you think of something :) .

    3. Externalize test resources creation in order to be able to override it ✓

    https://github.com/puli/repository/compare/1.0...tgalopin:path-mapping?diff=unified&name=path-mapping#diff-59ad75cfaee83a692af80d3634224473

    As my repository only handle FilesystemResource instances, I needed to create specific testing objects. I had to externalize this creation, so I edited the abstract tests in order to do so.

    4. Add specific tests for the optimized version ✓

    https://github.com/puli/repository/blob/a25287982a5d2c64c0ed507532110af89bd614b8/tests/OptimizedPathMappingRepositoryTest.php

    Test that the adding of a single directory does add all the children of this directory in the right place.

    Do you think of other specific test I could have forgotten?

    opened by tgalopin 8
  • normalize path for windows machines

    normalize path for windows machines

    Normalize path to fix windows backslash issues.

    Tests are still red... This only fixes a general backslash bug, that prevents me from using puli on windows.

    opened by Big-Whoop 7
  • Create LinkResource and implement it in repositories

    Create LinkResource and implement it in repositories

    Fix https://github.com/puli/issues/issues/107.

    This is a work in progress.

    Small question: what happen for a LinkResource in the FilesystemRepository? How do we store it? Do we create a symlink?

    opened by tgalopin 5
  • [WIP] Support deletion in PathMappingRepository

    [WIP] Support deletion in PathMappingRepository

    Pull request for https://github.com/puli/issues/issues/105

    A question I'm asking myself is what to do if a resource is not found for deletion. For the moment, if the remove() method does not found any path to remove, it returns 0, which seems fine. However, as it's a specific context (PathMapping repository does only supports remove on mapped directories), we might want to throw a BadMethodException on invalid remove call.

    What do you think?

    opened by tgalopin 5
  • [WIP] Rethink the PathMappingRepository

    [WIP] Rethink the PathMappingRepository

    The beta6 version of the PathMappingRepository was a beginning, but it's clear now that I didn't thought it well enough to take all the use-cases into account.

    This PR aim to introduce a new, simpler and more efficient version of the PathMappingRepository to fix the issues https://github.com/puli/repository/pull/40 and https://github.com/puli/repository/pull/39. Once this PR will be ready, I'll also work on the windows problems (https://github.com/puli/issues/issues/102), the link resources (https://github.com/puli/issues/issues/107) and the versionning (https://github.com/puli/issues/issues/90).

    opened by tgalopin 4
Releases(1.0.0-beta10)
  • 1.0.0-beta10(Feb 5, 2016)

  • 1.0.0-beta9(Jan 14, 2016)

    • made compatible with Symfony 3.0
    • added JSON schema for path mapping files: path-mappings-schema-1.0.json
    • upgraded to webmozart/glob 4.1 to improve performance
    • renamed Resource to PuliResource
    • renamed AbstractPathMappingRepository to AbstractJsonRepository
    • renamed PathMappingRepository to JsonRepository
    • renamed OptimizedPathMappingRepository to OptimizedJsonRepository
    • changed constructor arguments of JSON repositories from KeyValueStore to paths of JSON files
    • added AbstractEditableRepository
    • added ChangeStream
    • added VersionList
    • added NoVersionFoundException
    • added InMemoryChangeStream
    • added KeyValueStoreChangeStream
    • added JsonChangeStream
    • added PuliResource::getVersions()
    • added ResourceRepository::getVersions()
    • added LinkResource::getTarget()
    • made LinkResource serializable
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-beta8(Oct 5, 2015)

  • 1.0.0-beta7(Aug 24, 2015)

    • improved Windows compatibility
    • fixed minimum package versions in composer.json
    • switched to webmozart/glob 3.1 to fix Windows issues
    • fixed resource overriding in the PathMappingRepository
    • supported removal of path mappings in PathMappingRepository
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-beta6(Aug 12, 2015)

    • added PathMappingRepository
    • added OptimizedPathMappingRepository
    • fixed repository building on Windows
    • upgraded to webmozart/glob 3.0 for enhanced performance of file iteration
    • added AbstractRepository and AbstractPathMappingRepository
    • fixed reading of file modification time for symlinks
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-beta5(May 29, 2015)

  • 1.0.0-beta4(Apr 13, 2015)

  • 1.0.0-beta3(Mar 19, 2015)

    • added Resource::getPayload()
    • removed DetachedException
    • replaced Assert by webmozart/assert
    • added support for relative symlinks to FilesystemRepository
    • FilesystemRepository now falls back to copies if symlinks are not supported
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-beta2(Jan 27, 2015)

    • added NullRepository
    • removed dependency to beberlei/assert
    • symfony/filesystem is now an optional dependency that is only needed when using the FilesystemRepository
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-beta(Jan 27, 2015)

    • renamed Selector to Glob and moved it to package "webmozart/glob"
    • removed AttachableResourceInterface
    • removed DirectoryResourceInterface
    • removed FileResourceInterface
    • removed OverriddenPathLoaderInterface
    • removed Interface suffix of all interfaces
    • ResourceRepository::find() now matches directory separators "/" when given a wildcard "*"
    • merged AbstractResource and DirectoryResource into GenericResource
    • renamed LocalDirectoryResource to DirectoryResource
    • renamed LocalFileResource to FileResource
    • removed LocalResource::getAllLocalPaths
    • rename LocalResource::getLocalPath to LocalResource::getFilesystemPath
    • renamed LocalResource to FilesystemResource
    • renamed LocalResourceCollection to FilesystemResourceCollection
    • removed createAttached() from GenericResource, FileResource and DirectoryResource
    • removed tagging
    • renamedResourceRepository to InMemoryRepository
    • renamed ResourceCollection to ArrayResourceCollection
    • renamed RecursiveResourceIterator to RecursiveResourceIteratorIterator
    • renamed ManageableResourceRepository to EditableRepository
    • removed UriRepository
    • added $scheme argument to ResourceStreamWrapper::register() and ResourceStreamWrapper::unregister()
    • added ResourceNotFoundException::forPath()
    • added NoDirectoryException::forPath()
    • moved contents of Puli\Repository\Filesystem\Iterator to Puli\Repository\Iterator
    • moved contents of Puli\Repository\Filesystem\Resource to Puli\Repository\Resource
    • moved FilesystemRepository to Puli\Repository
    • removed PhpCacheRepository
    • added domain-specific Assert class
    • moved API interfaces to Api sub-namespace
    • removed notions of "directories" and "files". All resources can have children and a body now.
    • added ResourceRepository::listChildren() and hasChildren()
    • added ResourceMetadata and FilesystemMetadata
    • added methods to Resource:
      • getChild()
      • hasChild()
      • hasChildren()
      • listChildren()
      • getMetadata()
      • getRepository()
      • getRepositoryPath()
      • attachTo()
      • detach()
      • isAttached()
      • createReference()
      • isReference()
    • made Resource extend Serializable
    • added EditableRepository::clear()
    • removed backend repositories from InMemoryRepository and FilesystemRepository
    • added symlink support to FilesystemRepository
    • removed FilesystemException
    • removed InvalidPathException
    • removed UnsupportedSchemeException
    • replaced NoDirectoryException by UnsupportedOperationException
    • removed CompositeRepository from the 1.0 branch
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-alpha4(Jan 27, 2015)

    • moved extensions to separate repositories in https://github.com/puli
    • moved documentation to separate repository: https://github.com/puli/docs
    • moved Path to "webmozart/path-util" package
    • moved all code to Puli\Repository namespace
    • rearranged the directory structure
    • added ResourceCollectionIterator
    • added ResourceIteratorInterface
    • added RecursiveResourceIterator
    • added RecursiveResourceIteratorInterface
    • added ResourceFilterIterator
    • renamed ResourceRepositoryInterface to ManageableRepositoryInterface
    • renamed ResourceLocatorInterface to ResourceRepositoryInterface
    • renamed all "locators" to "repositories"
    • moved all filesystem specific code to Filesystem namespace
    • made ResourceInterface independent of the filesystem. The filesystem specific methods are now in LocalResourceInterface
    • getAlternativePaths() is now called getAllLocalPaths()
    • added getContents(), getSize(), getLastAccessedAt() and getLastModifiedAt() to FileResourceInterface
    • removed all pattern-related classes. This logic is now provided by the Selector class
    • ResourceRepository::remove(), tag() and untag() now return the number of affected resources
    • added UriRepository::getDefaultScheme() and setDefaultScheme()
    • renamed getByTag() to findByTag()
    • added merge() to ResourceCollectionInterface
    • added CompositeRepository
    • removed LazyDirectoryResource
    • fixed ResourceRepository::add() to be deterministic when selectors are passed. Closes #17
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-alpha3(Jan 27, 2015)

    • renamed PhpResourceLocator to PhpCacheLocator
    • renamed PhpResourceLocatorDumper to PhpCacheDumper
    • added FilesystemLocator
    • removed ResourceDiscoveringInterface
    • a base ResourceLocatorInterface can now be passed to ResourceRepository
    • instead of arrays, ResourceCollection objects are now returned everywhere
    • renamed ResourceInterface::getPath() to getRealPath()
    • renamed ResourceInterface::getRepositoryPath() to getPath()
    • added an extension for the templating engine Twig
    • added an extension for the Symfony Config and HttpKernel components
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-alpha2(Jan 27, 2015)

    • fixed "Maximum function nesting level" error on Windows
    • pushed minimum PHP version to 5.3.9
    • removed TagInterface and descending classes
    • added support for dot segments ("." and "..")
    • removed CreationNotAllowedException
    • removed RemoveNotAllowedException
    • removed RenameNotAllowedException
    • added UnsupportedOperationException
    • added Path
    • added Uri
    • added UriLocatorInterface and UriLocator
    • changed ResourceStreamWrapper::register() to take a UriLocatorInterface instance instead of a scheme and a resource locator
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-alpha1(Jan 27, 2015)

Owner
Puli
Modules for PHP
Puli
Database Repository / PHP Repository / Laravel Repository

Database Repository / PHP Repository / Laravel Repository Installation Use following command to add this package to composer development requirement.

Bakery 6 Dec 21, 2022
A simple Content Moderation System for Laravel 5.* that allows you to Approve or Reject resources like posts, comments, users, etc.

Laravel Moderation A simple Moderation System for Laravel 5.* that allows you to Approve or Reject resources like posts, comments, users, etc. Keep yo

Alex Kyriakidis 509 Dec 30, 2022
Fast and simple implementation of a REST API based on the Laravel Framework, Repository Pattern, Eloquent Resources, Translatability, and Swagger.

Laravel Headless What about? This allows a fast and simple implementation of a REST API based on the Laravel Framework, Repository Pattern, Eloquent R

Julien SCHMITT 6 Dec 30, 2022
Razorpay payment gateway integration in laravel with submit form and storing details in payment table.

Integrating razorpay payment gateway in laravel with submit form and storing payment details in payment table. How to settup the project in your local

Mohammed-Thamnees 3 Apr 15, 2021
This package tracks if products exist in Magento by storing the status locally in the DB.

Magento Products This package tracks if products exist in Magento by storing the status locally in the DB. We developed this to prevent multiple calls

JustBetter 14 Nov 11, 2022
Google Cloud Storage filesystem driver for Laravel

Google Cloud Storage filesystem driver for Laravel Google Cloud Storage filesystem driver for Laravel. This started as a fork from Superbalist/laravel

Spatie 88 Dec 16, 2022
This package provides an integration with FFmpeg for Laravel. Laravel's Filesystem handles the storage of the files.

Laravel FFMpeg This package provides an integration with FFmpeg for Laravel 6.0 and higher. Laravel's Filesystem handles the storage of the files. Lau

Protone Media 1.3k Jan 1, 2023
Eloquent Befriended brings social media-like features like following, blocking and filtering content based on following or blocked models.

Laravel Befriended Eloquent Befriended brings social media-like features like following, blocking and filtering content based on following or blocked

Renoki Co. 720 Jan 3, 2023
Auto-generated Interface and Repository file via Repository pattern in Laravel

Auto-generated Repository Pattern in Laravel A repository is a separation between a domain and a persistent layer. The repository provides a collectio

Ngo Dinh Cuong 11 Aug 15, 2022
Use Laravel's built-in ORM classes to query cloud resources with Steampipe.

Laravel Steampipe Use Laravel's built-in ORM classes to query cloud resources with Steampipe, an open source CLI to instantly query cloud APIs using S

Renoki Co. 13 Nov 8, 2022
A base API controller for Laravel that gives sorting, filtering, eager loading and pagination for your resources

Bruno Introduction A Laravel base controller class and a trait that will enable to add filtering, sorting, eager loading and pagination to your resour

Esben Petersen 165 Sep 16, 2022
Filter resources with request parameters

FilterWhere Filter resources with request parameters Author: Thomas Jakobi [email protected] License: GNU GPLv2 Features With this MODX Revolu

Thomas Jakobi 1 Jul 12, 2022
This Laravel Nova settings tool based on env, using nativ nova fields and resources

Nova Settings Description This Laravel Nova settings tool based on env, using nativ nova fields and resources Features Using native Nova resources Ful

Artem Stepanenko 21 Dec 28, 2022
cybercog 996 Dec 28, 2022
Livewire component that brings Spotlight/Alfred-like functionality to your Laravel application.

About LivewireUI Spotlight LivewireUI Spotlight is a Livewire component that provides Spotlight/Alfred-like functionality to your Laravel application.

Livewire UI 792 Jan 3, 2023
A Simple MOFH clientarea for free like infinityfree and minimal functionality

Project Hustal Project Hustal is a free of cost MOFH clientarea for account management and support services. It have easy to use features and a much l

Mahtab Hassan 10 Feb 15, 2022
An extended laravel eloquent WHERE method to work with sql LIKE operator.

Laravel Eloquent WhereLike An extended laravel eloquent WHERE method to work with sql LIKE operator. Inspiration The idea of this package comes from o

Touhidur Rahman 33 Aug 6, 2022
It's like React for PHP. Powered by Laravel, Livewire, Tailwind, & Alpine.

Tailwire It's like React for PHP. Powered by Laravel, Livewire, Tailwind, & Alpine. Features: Use a custom view component class namespace Declare rout

null 5 Dec 12, 2021
Removes whitelisted unnecessary files (like tests/docs etc.) from vendor directory

Composer vendor cleanup This is a simple script for the Composer to remove unnecessary files (documentation/examples/tests etc.) from included vendor

Chris 2 Nov 14, 2022