Download the PHP package mbunge/php-attributes without Composer

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

PHP Attributes

Total Downloads Total Downloads Latest Stable Version License

This package provides an easy way to use and apply PHP 8 Attributes and allows quick real-world implementations meta-data or annotation related features like Routes, Events, DB Relations.

Features

See Upcoming features of next release.

Concept

php-attributes uses a decorated composer autoloader and notifies a handler with loaded class name. The attributes for class components get resolved using reflections.

This package supports attributes for

Install

Via Composer

Usage

Instantiate the attribute handler Mbunge\PhpAttributes\AttributeResolver via factory PhpAttributes\PhpAttributesFactory::createResolver() or direct.

Attributes of traget class components get resolved by passed class name as string to Mbunge\PhpAttributes\Resolver\AttributeResolver::resolve(string $class).

All resolved attributes returned as an array of data-transfer object (dto) Mbunge\PhpAttributes\Resolver\ResolvedAttributesDto.

Run multiple resolver

\Mbunge\PhpAttributes\Resolver\ChainedAttributeResolver receives a list of resolvers, execute each resolver and merge reolved results.

This is usefull when resolvers with different contexts need to execute at once.

Restrict attributes to filter condition of class name, namespace or class reflection

Mbunge\PhpAttributes\Resolver\FilterClassAttributeResolverDecorator decorates an instance of attribute handler with any callable filter.

See FilterClassAttributeResolverDecoratorTest for filter examples

Present resolved attributes

Resolved attributes provide declared meta-data.

Pass resolved attributes to presenter and perform context specifc actions.

Examples

All examples use a small Application implementation.

Chain presenters

\Mbunge\PhpAttributes\Presenter\ChainedAttributePresenter receives a list of presenters, execute each presenter and merge results.

This is usefull when attributes needs to present to different contexts, like application routeing, event dispatcher, etc.

See ChainedAttributePresenterTest for detailed implementation.

Attribute handler

Avoid blueprint code and use handler to resolve attributes and present them afterwards.

Automatically apply attributes to autoloaded classes

The libray provides a composer classloader decorator which extends composer autoloader with the ability to execute attribute handler when class got autoloaded.

See also packaged autoload.

Use packaged autoload

Replace composer default autoload /vendor/autoload with packaged autoload /vendor/mbunge/php-attributes/autoload.php

The packed autoload applies all attributes to autoloaded classes.

Caveats

PHP 8 Attributes will not solve all problems.

Automatically apply logic through meta-data declarations sounds cool, but requires a lot of convention and my lead into complexity and may be hard to debug!

SOLID may get violated as well, since attributes are some sort of dependecy. Use attributes only for helpful tasks and without violating clean code priciples!

Furthermore, it is helpful to provide cli tools for attribute analytics and debugging.

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

Contributing

Please see CODE_OF_CONDUCT for details.

Deployment

Only maintainers are allowed to deploy new versions!

  1. Run composer run release which will run tests and on success update changelog, package version and creates a release tag
  2. switch to master branch and merge develop branch
  3. Run composer run deploy which will run tests and on success push tags, master branch and develop branch

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Further read


All versions of php-attributes with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0.0
ext-json Version *
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 mbunge/php-attributes contains the following files

Loading the files please wait ....