Download the PHP package olvlvl/composer-attribute-collector without Composer

On this page you can find all versions of the php package olvlvl/composer-attribute-collector. 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 composer-attribute-collector

composer-attribute-collector

Release Code Coverage Downloads

composer-attribute-collector is a plugin for Composer. Its ambition is to provide a convenient way—and near zero cost—to retrieve targets of PHP 8 attributes. After the autoloader has been dumped, the plugin collects attribute targets and generates a static file. These targets can be retrieved through a convenient interface, without reflection. The plugin is useful when you need to discover attribute targets in a codebase—for known targets you can use reflection.

Features

[!NOTE] Currently, the plugin supports class, method, and property targets. You're welcome to contribute if you're interested in expending its support.

Usage

The following example demonstrates how targets and their attributes can be retrieved:

Getting started

Here are a few steps to get you started.

1. Configure the plugin

The plugin only inspects paths and files specified in the configuration with the include property. That is usually your "src" directory. Add this section to your composer.json file to enable the generation of the "attributes" file when the autoloader is dumped.

Check the Configuration options for more details.

2. Install the plugin

Use Composer to install the plugin. You will be asked if you trust the plugin and wish to activate it, select y to proceed.

You should see log messages similar to this:

[!TIP] See the Frequently Asked Questions section to automatically refresh the "attributes" file during development.

3. Autoload the "attributes" file

You can require the "attributes" file using require_once 'vendor/attributes.php'; but you might prefer to use Composer's autoloading feature:

Configuration

Here are a few ways you can configure the plugin.

Including paths or files (root-only)

Use the include property to define the paths or files to inspect for attributes. Without this property, the "attributes" file will be empty.

The specified paths are relative to the composer.json file, and the {vendor} placeholder is replaced with the path to the vendor folder.

Excluding paths or files (root-only)

Use the exclude property to exclude paths or files from inspection. This is handy when files cause issues or have side effects.

The specified paths are relative to the composer.json file, and the {vendor} placeholder is replaced with the path to the vendor folder.

Cache discoveries between runs

The plugin is able to maintain a cache to reuse discoveries between runs. To enable the cache, set the environment variable COMPOSER_ATTRIBUTE_COLLECTOR_USE_CACHE to 1, yes, or true. Cache items are persisted in the .composer-attribute-collector directory, you might want to add it to your .gitignore file.

Test drive with the Symfony Demo

You can try the plugin with a fresh installation of the Symfony Demo Application.

[!TIP] The demo application configured with the plugin is available on GitHub.

See the Getting started section to set up the plugin. If all went well, the file vendor/attributes.php should be available.

Now, you can try to get the controller methods tagged as routes. Create a PHP file with the following content and run it:

You should see an output similar to the following excerpt:

Frequently Asked Questions

Do I need to generate an optimized autoloader?

You don't need to generate an optimized autoloader for this to work. The plugin uses code similar to Composer to find classes. Anything that works with Composer should work with the plugin.

Can I use the plugin during development?

Yes, you can use the plugin during development, but keep in mind the "attributes" file is only generated after the autoloader is dumped. If you modify attributes you will have to run composer dump-autoload to refresh the "attributes" file.

As a workaround you could have watchers on the directories that contain classes with attributes to run XDEBUG_MODE=off composer dump-autoload when you make changes. PhpStorm offers file watchers. You could also use spatie/file-system-watcher, it only requires PHP. If the plugin is too slow for your liking, try running the command with COMPOSER_ATTRIBUTE_COLLECTOR_USE_CACHE=yes, it will enable caching and speed up consecutive runs.


Continuous Integration

The project is continuously tested by GitHub actions.

Tests Static Analysis Code Style

Code of Conduct

This project adheres to a Contributor Code of Conduct. By participating in this project and its community, you're expected to uphold this code.

Contributing

See CONTRIBUTING for details.


All versions of composer-attribute-collector with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
composer-plugin-api Version ^2.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 olvlvl/composer-attribute-collector contains the following files

Loading the files please wait ....