panlatent / craft-attribute
Attribute for CraftCMS
dev-main
2025-03-15 06:47 UTC
Requires
- php: >=8.2
- craftcms/cms: ^5.0
This package is auto-updated.
Last update: 2026-02-15 08:58:59 UTC
README
Using PHP Attribute in CraftCMS.
Installation
Then tell Composer to load the library:
composer require panlatent/craft-attribute
Usages
Controllers
For Web Controllers, you can inherit panlatent\craft\attribute\web\Controller or use Trait panlatent\craft\attribute\web\HasAttributes to use these attributes:
| Attribute | Targets | Scopes |
|---|---|---|
| #[AllowAnonymous] | Controller | Class |
| #[RequireLogin] | ControllerAction | Method |
| #[RequirePostRequest] | ControllerAction | Method |
| #[RequireAcceptsJson] | ControllerAction | Method |
Elements
Documentation
License
The Element Messages is open-sourced software licensed under the MIT license.