panlatent/craft-codepower-pack
最新稳定版本:0.1.0
Composer 安装命令:
composer require panlatent/craft-codepower-pack
包简介
Improve encoding experience
README 文档
README
Codepower Pack is a plugin to improve the Craft encoding experience. It emphasizes the use of PHP attribute annotations instead of encoding, including event register, enum assistants, and other useful tools.
Note
Before the official release of version 1.0, 0.x was unstable and always relied on the latest development version of subpackages.
What's this?
Essentially, Codepower Pack simply packages some libraries into a plugin for use directly in the Craft Store. You can directly Using these libraries, there is no need to install this plugin.
Event Register is an event register that can directly register application events in the configuration file.
Example
<?php // config/events.php use craft\services\ProjectConfig; use craft\web\View; use panlatent\craft\event\register\Bootstrap; use panlatent\craft\event\register\RegisterEvent; return [ #[Bootstrap] function($app) { if ($app->request->getIsCpRequest()) { // ... } }, #[RegisterEvent(View::class, View::EVENT_REGISTER_CP_TEMPLATE_ROOTS)] function(\craft\events\RegisterTemplateRootsEvent $event) { // ... }, ]
Enum Helper is an enumeration assistant that automatically generates PHP enumeration classes such as Section, Field, etc., so that you can use enumeration items instead of handle strings.
Example
<?php // Query a section Section::post->find()
Form Schema declare form fields via PHP Attribute without writing Twig templates
Example
<?php use Panlatent\FormSchema\Forms; class Volume extends \craft\base\Field { // ... #[Forms\TextInput] public ?string $property1 = null; #[Forms\KeyValue] public array $property2 = []; // ... }
Attribute It is a richer collection of PHP Attributes for Craft
Example
<?php use panlatent\craft\attribute\web\AllowAnonymous; use panlatent\craft\attribute\web\RequiredLogin; use panlatent\craft\attribute\web\HasAttributes; class UserController extends \craft\web\Controller { use HasAttributes; #[AllowAnonymous] #[RequiredLogin] public function actionIndex() { } }
Requirements
This plugin requires Craft CMS 5.0 or later, and PHP 8.2 or later.
Installation
You can install this plugin from the Plugin Store or with Composer.
From the Plugin Store
Go to the Plugin Store in your project’s Control Panel and search for “Codepower Pack”. Then press “Install”.
With Composer
Open your terminal and run the following commands:
# go to the project directory cd /path/to/my-project.test # tell Composer to load the plugin composer require panlatent/craft-codepower-pack # tell Craft to install the plugin ./craft plugin/install codepower-pack
Configuration
Copy config/codepower-pack.php goes to your application config/ directory and modify it according to your actual situation.
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: mit
- 更新时间: 2025-03-15