Download the PHP package makinacorpus/generated-hydrator-bundle without Composer

On this page you can find all versions of the php package makinacorpus/generated-hydrator-bundle. 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 generated-hydrator-bundle

ocramius/generated-hydrator Symfony >=6.x bundle

Integrates ocramius/generated-hydrator library with Symfony.

It also brings some new features:

Installation

First install the dependency:

Then add into your config/bundles.php file:

Configuration

Change generated PHP file location

Default configuration will attempt to write generated hydrator code into the %kernel.project_dir%/hydrator folder. For this to work, you probably want to add in your composer.json file:

You can change the target by adding the following config/packages/generated-hydrator.yaml file:

Blacklist classes from hydration

You may experience bugs at some point when the hydrator attempts for example to hydrate PHP core classes. In order to avoid this from happening, you can completely disable hydration attempts on any PHP type, by using the following configuration:

This will prevent the nested object hydrator from those classes hydration attempt.

Pre-generate class hydrators for production

You can setup a list of class for which you need to pre-generate hydrators:

This will allow the generated-hydrator:generate command to pre-generate all hydrators.

Autowiring

You can use the GeneratedHydrator\Bridge\Symfony\HydratorAware interface and set it on services, which will make this bundle autoconfigure the service injection for you.

You can also use the GeneratedHydrator\Bridge\Symfony\HydratorAwareTrait if you don't want to implement the setObjectHydrator() method by yourself.

Usage

Basic usage

Inject the generated_hydrator service, or type hint with GeneratedHydrator\Bridge\Symfony\Hydrator for auto-wiring.

In order to hydrate an object:

Or extract its values:

Value hydrator

Let's consider you have the following class:

And use it as an identifier class for the following entity class:

If you need to hydrate some Foo instance using the following data from database:

This will fail because the $id parameter cannot accept a string value.

If you use the same pattern all over your site, you might want to use a global value hydrator, as such:

And register it either by explicitely setting the generated_hydrator.value_hydrator service tag, or by adding into the container using autowiring and autoconfiguration set to true on this service:

Once this set, each property value that needs to be hydrated implementing your App\Entity\Identifier interface will have its value correctly instanciated automatically.

Some notes

For the nested hydrator to work, it needs to be able to use introspection on you classes for finding the properties types.

If for some reason introspection fails, you can explicitely install the symfony/property-access component, which may find some types that this API is unable to find using reflection.

Roadmap

Reach alpha release (mandatory):

Industrialisation (1.0):

Far far away:


All versions of generated-hydrator-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ocramius/generated-hydrator Version ^4.3
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 makinacorpus/generated-hydrator-bundle contains the following files

Loading the files please wait ....