Download the PHP package digipolisgent/doctrine-extra without Composer

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

Doctrine Extra's

1. Example's

In this package a BaseManager is included that uses the Assert en Resolvable trait. If we use this Manager we can do the following code examples ;

Select all new & processing orders paginated

Select all 'new' & 'processing' orders as an iterator

Count all 'new' & 'processing' orders

Add an extra parameter to an existing query

More example's are available below in the docs.

2. Filters

Create Filter objects to easily filter your repository. This package contains two default Filter objects to use ; 'AggregateFilter' and 'PropertyFilter'. Both are multipurpose but is is recommended to extend the AbstractFilter and create your own.

The filtering itself can be done by any class that uses the Resolver trait, and uses the Doctrine QueryBuilder object as a starting point.

Lets take the following example ;

We have an OrderRepository that implements the Resolver trait, and has a method "filter" that accepts an array of Doctrine Filters or one DoctrineFilter.

Using the PropertyFilter

The property filter can be used to filter on any entity's property. Lets Imagine an order has a "category" property, we want to filter on.

By now we have filtered orders for a certain category. We can also pass multiple filters as an array into the filter() method as an argument, they will all be combined in an andX expression.

Using the AggregateFilter

In case we want to use multiple filters in an orX expression, we can use the AggregateFilter. In the following example we will filter all 'new' or 'finished' orders;

We can combine multiple AggregateFilters to make a more complex expression. In the following example we will filter all 'new' or 'finished' orders that have 'multimedia' or 'books' as a category

Creating a custom DoctrineFilter

Simple property filter

We can also implement CategoryFilter if more entities have category as a property and we want to use it often.

If we want to create our own CategoryFilter, which is the most basic form of filtering by filtering on a single direct property we can do it this way ;

We only need to implement the CreateExpression() method, and create a simple expression that will be used in the Where clause in the QueryBuilder. Now this filter can be usd on all entities with the "category" property.

Sometimes we will need a more complex filter. Assume our Order entity has a relationship with User, and User has a username. We want to filter all orders by a user's username. We can create the following filter ;

More advanced example

This Filter is a bit more complex. Since we are not filtering a direct property of Order, but instead filter on a property of User which has a association with our Order object, we need to implement two more methods.

The function getAlias() will return a string, the alias defines the object's alias that has the property we are filtering on. In this case its 'user' because we will filter on user.email.

The AddAlias() method will be triggered by the Resolver when it checks if the 'user' alias is present in the QueryBuilder, an alias is present when it is OR selected OR joined. In this case we Left join our User object to our 'root' object, in this example 'Order'.

Now we have finished our UserEmailFilter, we can use this filter on any object that has User as a relation. We can for example have a Reservation entity and a Ticket entity that both have an association with User.

So by now we can do the following ;

3. Assert Results

This package includes the Assertable trait, which allows any class to pass a QueryBuilder object and retrieve different results from that same QueryBuilder object.

For example, we have a repository that uses the Assertable trait, we the following code ;

Because we use the assertable trait, and we pass our QueryBuilder object through the assertResult() method, we can manipulate what kind of result this function will return. By default this function will act as expected and return an array with all Order entities by a certain category.

If we want to retrieve the orders paginated, we can simply call the builder() method before calling getOrdersByCategory and the Assert trait will assert that the result passed as a result will be a Paginator object;

To see all possible outcomes of the assertResult() method, take the following code ;

The above code is located in the Assert trait.


All versions of doctrine-extra with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.9
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 digipolisgent/doctrine-extra contains the following files

Loading the files please wait ....