Download the PHP package fom/module-annotations without Composer

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

M2 Coding Standard M2 Mess Detector M2 PHPStan

Annotations for Magento 2

During the development of extensions, we often encounter a situation where some plugin or observer should be executed only on certain Magento versions and Magento editions. To solve this problem, we usually inject \Magento\Framework\App\ProductMetadataInterface and then use additional checks for versions and editions.

Annotations for Magento 2 will help solve this problem and provide flexible configuration for conditions combination.

Requirements

How to install

Install via composer (recommended)

Run the following command in Magento 2 root folder:

Developer Guide

In Magento 2, all plugins and observers using \Magento\Framework\App\ProductMetadataInterface to check the current version and edition still continue to be instantiated, executed, and use memory and processor. Annotations for Magento 2 module uses an optimized approach, plugins and observers that should not be executed for the current version and edition will be disabled at the stage of building the configuration of plugins and observers. This means that checking whether the plugin or the observer should be executed will be performed ONLY once, at the stage of cache building, which will slightly reduce stack traces, and this in turn should have a positive impact on performance.

Attributes (for PHP >= 8.0) or Doctrine Annotations (for PHP >= 7.1) are used to configure plugins and observers.

Annotations for Magento 2 provides two attribute classes:

Fom\Annotations\Attribute\Platform

The attribute is used to describe the edition, version, and comparison operator for the Magento. This attribute is repeatable, and can be added to the class several times.

Parameters:

Fom\Annotations\Attribute\Operator

The attribute is used if the Platform list. This attribute is optional and can be applied to a class only 1 time.

Parameters:

Examples

In the examples we will demonstrate observers, but the exact same declaration is used for plugins.

Observer with PHP8 Attributes

Let's disable observer for Any Magento Edition with versions lower than 2.4.4.

We can also import our attributes to use a short class name.

Observer with Doctrine Annotations (PHP < 8.0).

Let's do the same, but with a docblock section to allow use for older PHP versions.

We can still import our attributes to use a short class name.

Observer with a combined declaration, PHP 8 Attribute and Doctrine annotations, allowing this module to be used with different PHP versions.

We have to use the one-line PHP8 Attribute notation. In this case, our PHP8 Attribute will be interpreted as a comment for older PHP versions, since it starts with #.

Example without using the Operator attribute

Since Operator::OPERATOR_AND by default, we can omit it in the following cases:

We use only one platform condition

We use several platform conditions, but all their conditions must be satisfied at the same time

Example of using Operator::OPERATOR_AND

In rare cases, we may need to use specific conditions when a plugin or an observer must work on different versions and editions at the same time, in this case we can describe several necessary platform conditions and summarize them using Operator::OPERATOR_AND. In this case, if at least one of the conditions is met, our observer or plugin will be executed.

In the example below, the observer will be executed on Magento Community Edition = 2.4.3 or on Magento Commerce Edition = 2.4.2, on any other versions or editions, this observer will be disabled.

Additional Tools

Copyright

Copyright © FriendsOfMagento


All versions of module-annotations with dependencies

PHP Build Version
Package Version
Requires magento/framework Version ~102.0.0||~103.0.0
spiral/attributes Version ~2.9.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 fom/module-annotations contains the following files

Loading the files please wait ...