giantbits/yii2-crelish
最新稳定版本:0.21.6
Composer 安装命令:
composer require giantbits/yii2-crelish
包简介
Content management for the Yii2 framework
README 文档
README
Content management for the Yii2 framework.
Installation
- Create Yii2 Basic project
composer global require "fxp/composer-asset-plugin:^1.2.0"
composer create-project --prefer-dist yiisoft/yii2-app-basic {projectname}
- Install yii2-crelish
composer require giantbits/yii2-crelish
Setup
configuration
Edit your web.php config file
// Add crelish to the bootstrap phase.
'bootstrap' => ['crelish', '...'],
// Configure components.
// Set default route.
'defaultRoute' => 'frontend/index',
// Configure view component to use twig.
'view' => [
'class' => 'yii\web\View',
'renderers' => [
'twig' => [
'class' => 'yii\twig\ViewRenderer',
'cachePath' => '@runtime/Twig/cache',
// Array of twig options:
'options' => [
'auto_reload' => true,
],
'globals' => ['html' => '\yii\helpers\Html'],
'uses' => ['yii\bootstrap']
],
]
]
// Enable file cache.
'cache' => [
'class' => 'yii\caching\FileCache'
]
// Enable swift mailer.
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'useFileTransport' => TRUE
]
// Use crelish user class
'user' => [
'class'=>'giantbits\crelish\components\CrelishUser',
'identityClass' => 'giantbits\crelish\components\CrelishUser',
'enableAutoLogin' => true,
],
// Enable basic URL Manager.
'urlManager' => [
'enablePrettyUrl' => TRUE,
'showScriptName' => FALSE,
'enableStrictParsing' => TRUE,
'suffix' => '.html',
'rules' => [
// ...
]
]
// Finaly add Crelish to the config. (After component configuration)
$config['modules']['crelish'] = [
'class' => 'giantbits\crelish\Module',
'theme' => 'klangfarbe'
];
Setting up folders
Create the following structure in you project root folder.
workspace/
data/
*Create folders for evey content type you use.*
asset/
*Content items of this type are stored here.*
2131123123123123.json
...
page/
*Content items of this type are stored here.*
2131123123123123.json
...
elements/
*Definitions for each content type are stored here.*
asset.json
page.json
widgets/
Important additions
Currently the system relies on two cintent types to b epresent. Paste the following code into the folder workspace/elements/.
// File name: asset.json
{
"key": "asset",
"label": "Asset",
"selectable": false,
"tabs": [
],
"groups": [
],
"fields": [
{ "label": "Title internal", "key": "systitle", "type": "textInput", "visibleInGrid": true, "rules": [["required"], ["string", {"max": 128}]]},
{ "label": "Title", "key": "title", "type": "textInput", "visibleInGrid": false, "rules": [["required"], ["string", {"max": 128}]]},
{ "label": "Description", "key": "description", "type": "textInput", "visibleInGrid": false, "rules": [["required"],["string", {"max": 320}]]},
{ "label": "MIME-Type", "key": "mime", "type": "textInput", "visibleInGrid": false, "rules": [["required"],["string", {"max": 128}]]},
{ "label": "Source", "key": "src", "type": "textInput", "visibleInGrid": false, "rules": [["required"],["string", {"max": 256}]]},
{ "label": "Size", "key": "size", "type": "textInput", "visibleInGrid": false, "rules": [["required"],["integer"]]},
{ "label": "Dominant color HEX", "key": "colormain_hex", "type": "textInput", "visibleInGrid": false, "rules": [["safe"]]},
{ "label": "Dominant color RGB", "key": "colormain_rgb", "type": "textInput", "visibleInGrid": false, "rules": [["safe"]]},
{ "label": "Color palette", "key": "colorpalette", "type": "textInput", "visibleInGrid": false, "rules": [["safe"]]}
]
}
// File name: page.json
{
"key": "page",
"label": "Page",
"tabs": [
{
"label": "Content",
"key": "content",
"groups": [
{
"label": "Content",
"key": "content",
"settings": {
"width": "60"
},
"fields": [
"displaytitle",
"body",
"matrix"
]
},
{
"label": "Settings",
"key": "settings",
"settings": {
"width": "40"
},
"fields": [
"systitle",
"navtitle",
"metadescription",
"metakeywords"
]
}
]
}
],
"fields": [
{
"label": "Title internal",
"key": "systitle",
"type": "textInput",
"visibleInGrid": true,
"rules": [
[
"required"
],
[
"string",
{
"max": 128
}
]
]
},
{
"label": "Title display",
"key": "displaytitle",
"type": "textInput",
"visibleInGrid": false,
"rules": [
[
"required"
],
[
"string",
{
"max": 128
}
]
]
},
{
"label": "Title navigation",
"key": "navtitle",
"type": "textInput",
"visibleInGrid": false,
"rules": [
[
"required"
],
[
"string",
{
"max": 128
}
]
]
},
{
"label": "Meta-Description",
"key": "metadescription",
"type": "textInput",
"visibleInGrid": false,
"rules": [
[
"required"
],
[
"string",
{
"max": 128
}
]
]
},
{
"label": "Meta-Keywords",
"key": "metakeywords",
"type": "textInput",
"visibleInGrid": false,
"rules": [
[
"required"
],
[
"string",
{
"max": 128
}
]
]
},
{
"label": "Content",
"key": "body",
"type": "widget_\\yii\\redactor\\widgets\\Redactor",
"visibleInGrid": false,
"rules": [
[
"required"
],
[
"string",
{
"max": 2300
}
]
]
},
{
"label": "References",
"key": "matrix",
"type": "matrixConnector",
"rules": [
[
"safe"
]
]
}
]
}
Content Type Generator
Crelish now provides a command-line tool to streamline the process of creating new content types. This tool automatically generates both the database table and the model class based on a JSON element definition.
Usage
- Create a JSON element definition file in
@app/workspace/elements/(e.g.,boardgame.json) - Run the generator command:
./yii content-type/generate boardgame
This will:
- Create a database table for the content type
- Generate a model class with appropriate getters/setters for JSON fields
- Set up relations based on the element definition
Listing Available Element Definitions
To see all available element definitions:
./yii content-type/list
Element Definition Format
The element definition should follow the standard Crelish format, with the addition of a storage property to specify whether to use database or JSON storage:
{
"key": "boardgame",
"storage": "db",
"label": "Board Games",
"category": "Content",
"fields": [
{
"label": "Title",
"key": "systitle",
"type": "textInput",
"visibleInGrid": true,
"rules": [
["required"],
["string", {"max": 128}]
],
"sortable": true
},
{
"label": "Mechanics",
"key": "mechanics",
"type": "checkboxList",
"transform": "json",
"visibleInGrid": false,
"rules": [
["safe"]
]
},
{
"label": "Cover Image",
"key": "coverImage",
"type": "assetConnector",
"visibleInGrid": false,
"rules": [
["safe"]
]
}
]
}
The generator will automatically:
- Map field types to appropriate database column types
- Create getters and setters for JSON fields
- Set up relations for fields of type
relationSelectandassetConnector
Special Field Types
- relationSelect: Creates a relation to another content type. Requires a
config.ctypeproperty to specify the target content type. - assetConnector: Creates a relation to the asset content type. This is automatically handled without additional configuration.
- matrixConnector: Stored as JSON data for complex structured content.
- widgetConnector: Stored as JSON data for connecting widgets to content items.
- Fields with
"transform": "json": Automatically handled with getters and setters for working with JSON data.
giantbits/yii2-crelish 适用场景与选型建议
giantbits/yii2-crelish 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.32k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2016 年 06 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「yii2」 「crelish」 「cmp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 giantbits/yii2-crelish 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 giantbits/yii2-crelish 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 giantbits/yii2-crelish 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A custom URL rule class for Yii 2 which allows to create translated URL rules
SCEditor, a lightweight WYSIWYG BBCode & HTML editor extension for Yii 2.0 Framework
Symfony 8 bundle for GDPR/DSGVO cookie consent with Google Consent Mode v2, Twig components, Stimulus.js, and AssetMapper. Supports cookie, Doctrine, or combined storage. Includes YouTube, Vimeo, Google Maps embed components.
Consent management platform for Laravel with WireBoard Analytics, GA4, and Google Funding Choices support
Redirect all not authenticated web user to login page.
Google reCAPTCHA v3 integration for Yii2 with automatic token refresh. Works seamlessly with AJAX/PJAX forms.
统计信息
- 总下载量: 1.32k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2016-06-02