Download the PHP package aternos/model without Composer

On this page you can find all versions of the php package aternos/model. 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 model

PHP Model

PHP library for simple and complex database models.

About

This library was created to provide a flexible, but yet easy to use Model system, which can be used for new projects but also integrated into existing projects. Every part of the library can be overwritten and replaced separately for custom logic.

In contrast to other model libraries, this library is not tied to any specific database backend, instead every model can contain custom logic for accessing different databases, e.g. for a different cache or search backend. Therefore, this library does not provide any provisioning functionality.

Note: This library is still in development and some features especially regarding more driver functions will be added in the future.

Installation

Basic usage

Driver

The library includes some drivers, but you can also create your own drivers and use them in your project or submit them to be added to the library.

Currently included drivers are:

All of these drivers require additional extensions or packages, see "suggest" in composer.json.

Most drivers will work out of the box with a local database set up without password, but for most use cases you have to use different credentials. To do that with the included drivers, you can create a new instance and set the credentials using the constructor

or fluent setters

or create a new driver class extending the library driver and overwrite the protected credential properties (either in the class itself or in the constructor), e.g.:

After that you have to register the class in the DriverRegistry:

All drivers have an ID to identify and if necessary overwrite existing drivers. Usually it is recommended to use a unique ID for each driver type, but if you need multiple drivers of the same type (e.g. if you have two different Mysql databases), you can create and register multiple drivers with different IDs. You can set the ID using the setId() fluent setter on any driver or by overwriting the getId() function in your own class.

Model

Now you can create a model class. All model classes have to follow the ModelInterface. This library includes two different abstract model classes to make the model creation easier:

It's recommended to start with the GenericModel since it already implements multiple drivers and you can enable which drivers you need for each model or for all models (by using your own parent model for all your models).

This is an example implementation of a model using the GenericModel with a Mysqli database as backend and caching. The driver configuration is an ordered array $drivers with driver IDs, the first driver is used first to get the model. The drivers for the other actions depend on the $drivers array (e.g. reversed for save() and delete()), but can be individually configured, e.g. setting the $saveDrivers array.

Use your model

You can now use your model in your code:

Query

You can query the model using a SelectQuery. It allows different syntax possibilities such as simple array/string/int values directly passed to the constructor or building all parameters as objects based on the QueryResult object, which is iterable and countable.

Select

Update

Delete

Testing

This library includes a TestDriver which can be used to write tests without a database. It uses a simple array as storage and is not persistent. It supports most basic operations and queries, but might not work for all use cases yet especially not for database specific queries.

You can just add test data to your model which will also enable the test driver for that model.

Alternatively, you can also add data to the test driver directly.

If you add data to the driver directly, you still have to enable the test driver for each model that you want to test.

Advanced usage

More information about more advanced usage, such as writing your own drivers, driver factory or models will be added in the future, in the meantime just take a look at the source code.


All versions of model with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ext-json Version *
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 aternos/model contains the following files

Loading the files please wait ....