Download the PHP package earc/data-primary-key-generator without Composer

On this page you can find all versions of the php package earc/data-primary-key-generator. 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 data-primary-key-generator

eArc-data-primary-key-generator

Primary key generator for the earc/data abstraction.

table of contents

installation

Install the earc/data-primary-key-generator library via composer.

basic usage

bootstrapping the primary key generator

Initialize the earc/data abstraction in your index.php, bootstrap or configuration script.

Then register the earc/data-primary-key-generator to the earc/data onAutoPrimaryKey event.

Now earc/data is ready to use earc/data-primary-key-generator to generate UUIDs as primary keys for your entities.

If you want to generate incremental primary keys, you have to decide where to cache the maximal keys of the entity classes. You can choose between the filesystem and a redis server.

using a redis server

To use the redis server, set the infrastructure parameter to USE_REDIS.

By default, earc/data-primary-key-generator uses localhost and the defaults of the php-redis-extension. You can overwrite these defaults:

This array is handed to the Redis::connect() method as arguments. Consult the phpredis documentation for valid values and configuration options.

Now earc/data is ready to use the earc/data-primary-key-generator to generate incremental primary keys for your entities.

using the filesystem

To use the filesystem, set the infrastructure parameter to USE_FILESYSTEM.

Then configure the data filesystem path for the earc/data-filesystem bridge.

Now earc/data is ready to use the earc/data-primary-key-generator to generate incremental primary keys for your entities.

determine the key generation strategy

There are two supported primary key generation strategies.

  1. using UUIDs
  2. incrementing a positive integer for each entity class

Each has its own advantages and downsides:

  1. The UUIDs are globally unique.
  2. The incremented integer keys require less space and give the entities a natural order, but this strategy requires an infrastructure to cache the maximal primary key for the classes.

The key generation strategy can be determined individually by implementing the AutoincrementPrimaryKeyInterface or the AutoUUIDPrimaryKeyInterface in the entity class.

Or it can be determined globally by setting the DEFAULT_INTERFACE parameter:

This provides a fallback if no interface is present. Of course the AutoPrimaryKeyInterface of the earc/data library has to be implemented to trigger the onAutoPrimaryKey event.

advanced usage

naming of the redis hash key

If you use the increment strategy together with the redis server, earc/data-primary-key-generator uses redis hashes to cache the maximal keys of the entity classes. By default, the hash-key is named earc-data-pk-gen. If you need another name to manage the redis namespace, you can overwrite the default:

naming of the filesystem directory

If you use the increment strategy together with the filesystem, earc/data-primary-key-generator uses the @earc-data-pk-gen postfix to extend the filesystem entity path of earc/data-filesystem to cache the maximal primary key of the entity class. You can change this by setting the DIR_NAME_POSTFIX parameter.

releases

release 0.0


All versions of data-primary-key-generator with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
earc/data Version ^0.0
earc/data-filesystem Version 0.0
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 earc/data-primary-key-generator contains the following files

Loading the files please wait ....