Download the PHP package tomkyle/repository-persistence without Composer

On this page you can find all versions of the php package tomkyle/repository-persistence. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package repository-persistence

Repository · Persistence

Packagist PHP version PHP Composer

Scaffold for Repository-and-Persistence design pattern.


Installation

Setup

The repository needs a persistence.

In this example, the Persistence works on a directory path/to/json in which the items are stored in JSON files named by their ID. — Example: john-doe.json

Usage

Get item. This method may throw \OutOfBoundsException

Output will be like:

Find one item by criteria. This method may return null.

Get all items:

Find items by criteria

Update item

Delete item

Create new item

If you need the new ID onbeforehand in your App controller, e.g. for redirecting the client to the new resource, you can obtain a new ID from the repo. It then looks exactly like updating, but the Repository implementation will figure out if the item has to be created or updated.


Persistence

Inside a repository, the Persistence actually manages the data storage.

Instantiation

Methods API

Method Parameters Return Description
create array data string¦int New ID
read string¦int id array The record
readAll array All records
update array data int Affected rows
delete string¦int int Affected rows

Special implementations

FrontmatterFilePersistence

If your JSON or YAML files have frontmatters:

PersistenceChain

InMemoryPersistence

An empty Persistence you can write and read to.

NoPersistence

Mock implementation of Persistence that simulates data persistence operations without actually storing data. Note that read method will always throw \OutOfBoundsException as it does not contain any data!


Repository

The repository is the thing you work with in your app.

Methods API

Method Required Parameters Optional Return Description
get string¦int id array¦object The record
findOneBy array criteria array¦object¦null One record
findAll iterable All records
findBy array criteria ?array orderBy,
?int limit
?int offset
iterable Some records
save array¦object entity bool
delete array¦object entity bool

Development

Install requirements

Watch source and run various tests

This will watch changes inside the src/ and tests/ directories and run a series of tests:

  1. Find and run the according unit test with PHPUnit.
  2. Find possible bugs and documentation isses using phpstan.
  3. Analyse code style and give hints on newer syntax using Rector.

Run all tests

Choose to your taste:


All versions of repository-persistence with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
nette/utils Version ^4.0.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tomkyle/repository-persistence contains the following files

Loading the files please wait ....