Download the PHP package philippgrashoff/handlerforatk without Composer

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

atkdatamodelbroker - a broker to subscribe to Model::save() hooks

Why this repository?

I need to handle quite some actions when models are saved. My code often looked like

There some points I really do not like about this: 1) The model itself needs to know what additional actions should happen when it is saved/deleted. 2) Meaning that the model handles control flow along other models. I like my Models rather "stupid", focussing on properties management, sensible helper functions and their relations to other models. 3) As the model needs to call all actions that should happen after insert/update/delete, this also means that the code for these additional actions needs to be in the same repository. This is possibly leading to a huge monolith. I rather prefer splitting a bigger application into several repositories. This enforces good structuring and clear APIs.

This simple repository is there to change these downpoints. It is an implementation for atk4/data. This very nice framework does not implement a pattern like MVC but has very strong Models. However, the logic of this repository can be simply adapted. It is a mix of a Singleton (could also be done by DI) and Hook Pattern.

How this repository works

The ModelBroker is something which acts a bit like a MQTT Broker: Models can "publish" events like after insert, after update or after delete. Other classes can "subscribe" to these events and act upon them. The result is that:

There are 2 files in this repository which implement the logic:

How to use it

Of course, this means that all additional actions need to be registered before the Model save is executed. So, e.g. in App::init(), some code like this needs to be added:

Coupling of Model and ModelBroker

The ModelBroker is invoked in the hook spots of Model::save(). This means that all the additional actions will be inside the same transactions as the save() itself. Thus, if one of the additional actions fails, the complete save() is rolled back.

Several Models publishing the same event

If several models publish() the same event, any subscriber will receive this event from all these models.

Maybe in the future, the possibility to filter directly within subscribe() might be added.

Installation

The easiest way to use this repository is to add it to your composer.json in the 'require' section:

Versioning

The version numbers of this repository correspond with the atk4\data versions. So 5.0.x is compatible with atk4\data 5.0.x and so on.


All versions of handlerforatk with dependencies

PHP Build Version
Package Version
Requires php Version 8.*
atk4/data Version 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 philippgrashoff/handlerforatk contains the following files

Loading the files please wait ...