Download the PHP package parable-php/orm without Composer

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

Parable ORM

Workflow Status Latest Stable Version Latest Unstable Version License

Parable ORM is a light-weight repository-pattern based ORM.

Install

Php 8.0+ and composer are required.

Usage

Repositories are used to find, save and delete entities, which represent rows from your MySQL/Sqlite database. Parable ORM attempts to combine queries to be as efficient as possible.

Entities are relatively straight-forward PHP data objects, and are expected to offer setters and getters for all values associated with that entity. Example:

As you can see, the entity itself doesn't really need much. The Repository set up for this entity type, however, will contain some metadata so it knows how to handle them.

If you want to support automatic setting of a created at or updated at value, it's as simple as implementing either the SupportsCreatedAt or SupportsUpdatedAt interfaces. The repository will automatically pick up on it and attempt to call markCreatedAt() or markUpdatedAt(), leaving the specific property/column names up to you. Example:

Here's the Repository to handle the above Entity:

As mentioned, both entities and repositories are intended to be as simple and straightforward as possible. Entities and Repositories use parable-php/di, meaning they can use constructor-based injected dependencies.

Basic Repository use

Condition-based repository use

For advanced (and possibly complex) where conditions, we use a callable which is given a properly set up Query object. This allows for fine-grained control with a very low barrier to do so.

This ends up building the following query:

The methods where, whereNull, whereNotNull and whereCallable will use AND to combine the clauses. To do otherwise, all have an or-version. orWhere, orWhereNull, orWhereNotNull, orWhereCallable, and by using those specifically, an OR clause can be created.

In many cases you'll want to either only use or-clauses, or, to use an OR clause in an otherwise AND-oriented where list, use a callable to make sure they're grouped appropriately.

Saving and deleting entities

To save an entity, simply tell the repository to do so:

Or save multiple:

You can also easily defer a save, so that the entity is prepared for a save but not actually saved until you decide to do so. When this is done, all entities that need to be updated are saved individually as they are found in the deferred save list, but all entities that are new (aka to be INSERTed) are combined into a single INSERT query instead.

If $newEntities contains 10 entities that are all new, one query will now insert all 10 in one go. If, for example, $newEntities contains 5 new and 5 pre-existing entities, saveDeferred will build the single INSERT query for the 5 new ones, and as it comes across them, save the updates immediately.

Deleting works the same:

And deferred deletes are also possible, and will attempt to delete all deferred entities in a single query:

For both deferred saves and deletes, the currently stored entities to be saved or deleted can be cleared by calling either clearDeferredSaves() or clearDeferredDeletes().

How to connect to a database

You didn't think I'd ever forget this, do you? 2 database types are currently supported, MySQL and Sqlite3.

To connect to a MySQL server:

Or:

And to connect to a Sqlite3 file:

Or:

Contributing

Any suggestions, bug reports or general feedback is welcome. Use github issues and pull requests, or find me over at devvoh.com.

License

All Parable components are open-source software, licensed under the MIT license.


All versions of orm with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ext-pdo Version *
ext-json Version *
parable-php/di Version ^1.0
parable-php/query Version ^1.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 parable-php/orm contains the following files

Loading the files please wait ....