Download the PHP package pollora/attributes without Composer
On this page you can find all versions of the php package pollora/attributes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pollora/attributes
More information about pollora/attributes
Files in pollora/attributes
Package attributes
Short Description PHP attributes to declare WordPress post types, taxonomies, hooks, REST routes, meta, roles, schedules and more. Declarations only: they run without the framework.
License MIT
Homepage https://pollora.dev/core-concepts/auto-discovery/
Informations about the package attributes
The PHP attributes that declare WordPress components as code: #[PostType], #[Taxonomy], #[Action], #[Filter], #[WpRestRoute], #[Meta], #[Role], #[Schedule], #[Ajax], #[Ability], #[BlockBinding], #[WpCli] and the attributes that refine them.
They are declarations only. Each attribute holds its values and, for post types and taxonomies, says which registration arguments it sets; registering is left to the code that reads them. A plugin can declare its components without installing a framework, and an IDE or a static analyser can read them alone.
Part of Pollora, the Laravel framework for WordPress, which discovers these attributes and registers what they declare. See Auto-discovery and the post type attributes reference.
Installation
Requires PHP 8.3+ and mbstring. It brings pollora/ajax and pollora/abilities, whose AjaxAccess and Behaviour enumerations #[Ajax] and #[Ability] take; both depend on PHP alone.
Declaring
Reading
Post type and taxonomy attributes implement ConfiguresArguments: given the registration arguments gathered so far, they return them with their own contribution. Method attributes such as #[AdminCol] or #[RegisterMetaBoxCb] implement ConfiguresArgumentsWithMethod and are handed the decorated method as a callback.
resolveSlug() derives the slug from the class name when none is given (Book → book, kebab case, 20 characters at most), as Pollora does. The other attributes are plain values: #[Action('init', priority: 20)] exposes $hook and $priority.
Public API
The attribute classes, their constructor parameters and public properties, and the Pollora\Attributes\Contracts\* interfaces follow semantic versioning. Pollora\Attributes\Support\* is internal.
The package also carries the value types the attributes take, under the class names Pollora has always used: Pollora\Schedule\Every and Interval, Pollora\Role\Domain\Enums\Access, Pollora\Meta\Domain\Enums\Control and Pollora\BlockBinding\Domain\Enums\BindingFieldType.
Testing
License
MIT. See LICENSE.
All versions of attributes with dependencies
ext-mbstring Version *
pollora/abilities Version ^1.0
pollora/ajax Version ^1.1 || ^2.0