Download the PHP package dittto/doctrine-entity-factories without Composer

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

Entity factories for Doctrine

With it's usage of simple PHP objects for entities, Doctrine is a very easy-to-use ORM. It instantiates these entities using reflection. If you want to use entities that rely on another object via dependency injection, however, then you're stuck with setter injection.

This code allows you to pull new entities from a factory instead, allowing constructor injection and cleaner code.

How to use

First up, install this plugin.

Next, let's create a factory for our entity. These needs to implement EntityFactoryInterface.

The more-common framework to use Doctrine with is Symfony, but you can also use Doctrine with Laravel. The following are instructions for how to use it with both.

With Laravel

To use Doctrine with Laravel, you can use this helpful plugin:

We're going to use a custom provider and one that exists within this plugin. The custom one is as follows:

This provider defers all objects. You can also convert that new TestEntityFactory into another object easily by extending register() and provides().

Next, we'll add the providers to the main app config:

Lastly, we'll need to alter the doctrine config to use our plugin:

With Symfony

As with most things with Symfony, we can use config for pretty much most things.

To start with, we're going to want to tell Symfony to use our metadata factory instead of the default Doctrine one:

If you're using multiple entity managers, this may change a bit, but you'll probably also have the understanding to make this work for your code.

Laravel, above, allows us to easily load additional code via it's service providers. For Symfony, we're going to take a slightly different approach and decorate Doctrine's EntityManager. The aim of both of these approaches is the same - to add our entity factories to it before Doctrine starts creating entities.

For Symfony, we're going to add some new services:

It's here we'll use the calls definition to add in as many entity factories as we require. The first field is the full class name of the entity to be created by the factory.

The namespaces here look non-standard for Symfony, but that's purely to tie into the example above.

Testing

This plugin comes with it's own tests. To run these, clone the code and navigate to the directory. Then run the following:


All versions of doctrine-entity-factories with dependencies

PHP Build Version
Package Version
No informations.
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 dittto/doctrine-entity-factories contains the following files

Loading the files please wait ....