Download the PHP package consistence-community/consistence-doctrine-symfony without Composer

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

Symfony Bundle integrating Consistence library with Doctrine ORM

This package is a fork of consistence/consistence-doctrine-symfony maintained by community to support new PHP versions.


This is a Symfony bundle providing integration for the standalone package consistence-community/consistence-doctrine, if you are not using Symfony, follow instructions there.

This bundle provides integration of Consistence value objects for Doctrine ORM so that you can use them in your entities.

For now, the only integration which is needed is for Enums, see the examples below.

Usage

Enums represent predefined set of values and of course, you will want to store these values in your database as well. Since Enums are objects and you only want to store the represented value, there has to be some mapping.

You can see it in this example where you want to store sex for your Users:

Now you can use the Sex enum in your User entity. There are two important things to notice:

1) type="string_enum" in ORM\Column - this will be used for mapping the value to your database, that means if you have a string based enum (see values in Sex), use string_enum

You can specify any other parameters for ORM\Column as you would usually (nullability, length...).

There is also integer_enum, float_enum and boolean_enum which can be used respectively for their types.

2) @Enum(class=Sex::class) - this will be used for reconstructing the Sex enum object when loading the value back from database

The class annotation parameter uses the same namespace resolution process as other Doctrine annotations, so it is practically the same as when you specify a targetEntity in associations mapping.

Now everything is ready to be used, when you call flush, only female will be saved:

And when you retrieve the entity back from database, you will receive the Sex enum object again:

This means that the objects API is symmetrical (you get the same type as you set) and you can start benefiting from Enums advantages such as being sure, that what you get is already a valid value and having the possibility to define methods on top of the represented values.

Configuration

You can override services used internally, for example if you want to use a more effective cache in production (which is recommended), you can provide custom instance with an alias:

Installation

1) Install package consistence-community/consistence-doctrine-symfony with Composer:

2) Register the bundle in your application:

That's all, you are good to go!


All versions of consistence-doctrine-symfony with dependencies

PHP Build Version
Package Version
Requires php Version ~8.0
consistence-community/consistence-doctrine Version ^2.1.1
doctrine/doctrine-bundle Version ~2.2
symfony/config Version ^5.4|^6.0
symfony/dependency-injection Version ^5.4|^6.0
symfony/http-kernel Version ^5.4|^6.0
symfony/yaml Version ^5.4|^6.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 consistence-community/consistence-doctrine-symfony contains the following files

Loading the files please wait ....