Download the PHP package oasis/doctrine-addon without Composer

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

oasis/doctrine-addon component

Doctrine is the most popular vendor for PHP database components. The core projects under this name are a Object Relational Mapper (ORM) and the Database Abstraction Layer (DBAL) it is built upon.

The oasis/doctrine-addon component provides a few useful features to extend the doctrine/orm component:

Installation

Install the latest version with command below:

AutoIdTrait

The AutoIdTrait defines an id property and the getter method getId(). It can be used in any entity class that uses id as its primary index.

Cascade Removal Solution

When cache is presented for an ORM-enabled application, cache invalidation has always been an interesting topic to deal with. One most common exception in ORM is when you try to access a collection that contains out-dated entity. This problem is commonly referred to as the cascade removal problem. An exmaple is like below:

You have a Tean entity that holds a collection of its members, which are User entities. When you remove a User entity, without proper invalidation process, accessing the Team that holds reference to this User will throw an exception.

By default, doctrine/orm provides two ways to solve this problem:

However, either of the two solutions are not optimal. Needless to say, the manual removal is complex and will become a nightmare when you have a reference chain. On the other hand, using the cascade annotation is very effecient development wise, but extremely slow in performance especially when the relation map is complicated and dataset is large.

oasis/doctrine-addon introduces another solution to the cascade removal problem, by providing the CascadeRemoveTrait. Any entity that wants to utilise the CascadeRemoveTrait must:

Implementing the CascadeRemovableInterface further requires implementation of the following two methods:

A strongly related entity is an entity that should also be removed when the current entity is removed.

A loosely related entity is an entity that holds a reference to the current entity, either directly (To-One relation) or through a collection (To-Many relation). This reference should be invalidated when the current entity is removed.

The real removal of strongly related entity is achieved by database constraint, which must be ON DELETE CASCADE.

Code Sample (very simple CMS)

Imagine we have a simple CMS that has 3 types of entities: Categroy, Article and Tag. The system must meet the following requirements:

Below is the implementation:

NOTE: there is always one side and only one side in a bidirectional relation, that should be accessed by the outside users. In this example, you setCategory() on an Article, and you never call addArticle() directly on a Category. To further ensure this behavior and let the IDE helps us locate potential bug, we should decalre the hidden method @internal so that every call from outside will trigger a warning.

HOMEWORK: there is only addTag() method on an Article. You can try to write your implementation of removeTag() method to futher familiarize yourself with the ORM tool.


All versions of doctrine-addon with dependencies

PHP Build Version
Package Version
Requires oasis/logging Version ^1.1
doctrine/orm Version ^2.5
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 oasis/doctrine-addon contains the following files

Loading the files please wait ....