Download the PHP package chocochaos/propel-rulable-behavior without Composer

On this page you can find all versions of the php package chocochaos/propel-rulable-behavior. 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 propel-rulable-behavior

Rulable behavior for Propel 2

When writing real-world applications, you often have to deal with complex business rules. Maintaining these rules can be tedious and prone to errors, especially if they have to be checked in multiple places. It is easy to miss one implementation of a rule while making changes.

In propel you can already add your own methods to query and object classes. Even then, you are still defining the same logic in multiple places: in the query classes to filter your query results based on a rule, and in the models themselves, to check if a specific object meets a certain rule.

This behavior allows you to define business rules in centralised classes. Both your query filters and your model checks can be defined in one place. Upon building the schemas, convenient methods for checking these rules are added to the query and model classes, resulting in cleaner and more easily maintainable code.

Installation

composer require chocochaos/propel-rulable-behavior

Usage

Defining a rule

To define a rule, first create a new directory in your models directory called Rules. This directory should be on the same level as the Base and Map directories generated by Propel.

Screenshot of the directory structure.

Next, create a new class for your rule in this directory (with proper namespacing of course). For example:

As you can see, there are three methods you need to implement:

In the example above, RuleInterface was implemented. This is not required, I would actually recommend not doing so in most cases, as not implementing the interface allows you to apply proper type hinting instead of having to check the types manually in your methods. The example above could be simplified to:

Add behavior to your schema and build

Finally, add the rulable behavior to your schema, and set the correct parameters:

Use the generated methods

In the example above, Active was supplied as the PHPName for the rule. The following method will now be available:

Other options

There are a few things not yet covered above:

License

See the LICENSE file.


All versions of propel-rulable-behavior with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1.0
propel/propel Version @dev
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 chocochaos/propel-rulable-behavior contains the following files

Loading the files please wait ....