Download the PHP package mmauksch/json-repositories without Composer
On this page you can find all versions of the php package mmauksch/json-repositories. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mmauksch/json-repositories
More information about mmauksch/json-repositories
Files in mmauksch/json-repositories
Package json-repositories
Short Description Basic implementation of the repository pattern that stores its content in serialized json files. Intended use is for testing or prototyping! NOT INTENDED FOR PRODUCTION USE!
License MIT
Informations about the package json-repositories
JSON File Repository
A lightweight PHP library implementing the repository pattern with JSON file persistence. This library provides an easy way to create repositories that store data in JSON files, making it ideal for integration tests, Symfony web tests, and application prototyping.
๐ Overview
JSON File Repository offers a simple solution for temporary data persistence without the need for a full database setup. It implements the standard repository pattern, providing familiar interfaces for storing, retrieving, and managing collections of objects.
โ ๏ธ Note: This library is intended for testing and prototyping purposes only and is not suitable for production workloads.
๐ Installation
Install the library via Composer:
๐ง Usage
Basic Usage
Extending AbstractRepository
Instead of using GenericJsonRepository as an instance, you can also extend the AbstractJsonRepository class to create your own repository implementation:
Using Traits Selectively
You can also build your own repository implementation by selectively importing the traits that provide specific functionality:
Using Filters
Using Sorters
Using with Symfony Tests
For Application Prototyping
You can also simply let the dependency injection container provide the filesystem and serializer. In Symfony YAML configuration:
๐ Key Features
- Simple Repository Pattern Implementation - Follows standard repository interfaces
- JSON File Persistence - Stores entities as JSON files without database setup
- Flexible Storage Location - Configure where your JSON files are stored
- Advanced Filtering - Filter entities using both Filter objects and closures
- Custom Sorting - Sort entities using Sorter objects or custom comparison closures
- Type Safety - Repositories are typed to specific entity classes
- Symfony Integration - Works with Symfony Filesystem and Serializer components
๐ก Best Practices
- Use a dedicated directory for test storage that is cleared between test runs
- For integration tests, create fresh repositories in your test setup
- Implement proper cleanup in tearDown() methods or use a test framework's isolation features
- Consider using memory-only repositories for very simple tests
๐งช When to Use
- โ Writing integration tests
- โ Developing Symfony web tests
- โ Prototyping applications or features
- โ Demos and proof of concepts
- โ Production applications
- โ High-performance requirements
- โ Applications with complex database requirements
๐ License
This project is licensed under the MIT License - see the LICENSE.md file for details.
๐ค Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
All versions of json-repositories with dependencies
symfony/serializer Version *
symfony/finder Version *
symfony/filesystem Version *
ext-json Version *