Download the PHP package w3c/lifecycle-events-bundle without Composer

On this page you can find all versions of the php package w3c/lifecycle-events-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 lifecycle-events-bundle

Build Status Coverage Status SensioLabsInsight

lifecycle-events-bundle

This Symfony bundle is meant to capture and dispatch events that happen throughout the lifecycle of entities:

Doctrine already provides such events, but using them directly has a few shortcomings:

This bundle aims at circumventing these issues by providing means to fire entity creation, deletion and update events after a successful flush or whenever needed.

It also provides a set of annotation to configure what events should be sent and when.

This bundle was partially inspired by @kriswallsmith's talk "Matters of State".

Installation

Simply run assuming you have installed composer.phar or composer binary:

Finally, enable the bundle in the kernel:

That's it!

Usage

Annotations

For this bundle to do anything interesting, it is necessary to annotate entities you want to monitor. There are five annotations. Three of them apply to classes (@Create, @Delete and @Update) and the remaining two to properties (@Change, @IgnoreClassUpdates).

All annotations live in the namespace W3C\LifecycleEventsBundle\Annotation, so it is recommended to import it:

@On\Create

Monitors the creation of new entities. It accepts the following parameters:

@On\Delete

Monitors the deletion (or soft deletion, if you use Doctrine Extensions) of entities. It accepts the following parameters:

@On\Update

Monitors updates to entities. It accepts the following parameters:

@On\Change

Monitors whenever an entity field (property or collection) changes. It accepts the following parameters:

and for collections:

@On\IgnoreClassUpdates

This annotation is a bit different. When placed on a field (property or collection), it prevents @On\Update from firing events related to this field. @On\Change ones will still work. This annotation does not allow any parameters.

Example class

With such a class, the following events will be fired:

Disabling automatic dispatching of events

Lifecycle events are dispatched by default after a successful flush. If needed, this can be disabled:

Events can then be dispatched manually using the following:

Special case: inheritance

If you use inheritance in your entities, make sure to set fields of the parent class(es) protected (or public) so that changes to those can be monitored as belonging to subclasses.

Failing to do so may lead to \ReflectionException exceptions such as:

Even if those fields are not monitored!


All versions of lifecycle-events-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4|>=8.0
symfony/http-kernel Version ^4.4|^5.0|^6.0
symfony/config Version ^4.4|^5.0|^6.0
symfony/dependency-injection Version ^4.4|^5.0|^6.0
symfony/yaml Version ^4.4|^5.0|^6.0
symfony/event-dispatcher Version ^4.4|^5.0|^6.0
doctrine/orm Version ^2.0
doctrine/persistence Version ^1.3|^2.0|^3.0
doctrine/annotations Version ^1.13
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 w3c/lifecycle-events-bundle contains the following files

Loading the files please wait ....