giantbits / yii2-crelish
Content management for the Yii2 framework
Installs: 917
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Type:yii2-extension
pkg:composer/giantbits/yii2-crelish
Requires
- php: >=7.4.0
- brussens/yii2-trumbowyg: *
- cocur/slugify: ^4.6
- deeplcom/deepl-php: ^1.11
- erusev/parsedown: ^1.7
- firebase/php-jwt: ^6.11
- guzzlehttp/guzzle: ^7.9
- jaybizzle/crawler-detect: ^1.3
- kartik-v/yii2-checkbox-x: dev-master
- kartik-v/yii2-dialog: dev-master
- kartik-v/yii2-dynagrid: dev-master
- kartik-v/yii2-grid: v3.5.3
- kartik-v/yii2-tabs-x: v1.2.9
- kartik-v/yii2-widget-select2: v2.2.5
- kartik-v/yii2-widgets: v3.4.1
- ksubileau/color-thief-php: ^1.3
- league/flysystem: *
- league/glide: 2.2.2
- league/uri: *
- lodash-php/lodash-php: 0.0.9
- luyadev/yii2-recaptcha-widget: ^1.0
- matthiasmullie/minify: ^1.3
- mpdf/mpdf: ^8.1
- npm-asset/bootstrap: v5.3.3
- phpoffice/phpspreadsheet: ^1.29
- sentry/sentry: ^4.0
- spatie/pdf-to-image: ^1.2
- symfony/http-client: ^6.2
- symfony/http-foundation: ^3.0
- symfony/mailgun-mailer: ^6.2
- symfony/yaml: v6.3.12
- umneeq/yii2-color-extractor: *
- vlucas/phpdotenv: ^3.6
- yiisoft/yii2: ~2.0.14
- yiisoft/yii2-bootstrap5: ~2.0.2
- yiisoft/yii2-debug: 2.1.26
- yiisoft/yii2-gii: 2.2.6
- yiisoft/yii2-httpclient: ^2.0
- yiisoft/yii2-imagine: ^2.3.1
- yiisoft/yii2-queue: *
- yiisoft/yii2-symfonymailer: ^4.0
- yiisoft/yii2-twig: 2.5.1
Requires (Dev)
- phpstan/extension-installer: ^1.4
- yii2-extensions/phpstan: ^0.2.3
- dev-master
- 0.16.7
- 0.16.6
- 0.16.5
- 0.16.4
- 0.16.3
- 0.16.2
- 0.16.1
- 0.16.0
- 0.15.2
- 0.15.1
- 0.15.0
- 0.14.25
- 0.14.24
- 0.14.23
- 0.14.22
- 0.14.21
- 0.14.20
- 0.14.19
- 0.14.18
- 0.14.17
- 0.14.16
- 0.14.15
- 0.14.14
- 0.14.13
- 0.14.12
- 0.14.11
- 0.14.10
- 0.14.9
- 0.14.8
- 0.14.7
- 0.14.6
- 0.14.5
- 0.14.4
- 0.14.3
- 0.14.2
- 0.14.1
- 0.14.0
- 0.13.15
- 0.13.14
- 0.13.13
- 0.13.12
- 0.13.11
- 0.13.10
- 0.13.9
- 0.13.8
- 0.13.7
- 0.13.6
- 0.13.5
- 0.13.4
- 0.13.3
- 0.13.2
- 0.13.1
- 0.13.0
- 0.12.0
- 0.11.14
- 0.11.13
- 0.11.12
- 0.11.10
- 0.11.9
- 0.11.8
- 0.11.7
- 0.11.6
- 0.11.5
- 0.11.4
- 0.11.3
- 0.11.2
- 0.11.1
- 0.11.0
- 0.10.7
- 0.10.6
- 0.10.5
- 0.10.4
- 0.10.3
- 0.10.2
- 0.10.1
- 0.10.0
- 0.9.8
- 0.9.7
- 0.9.6
- 0.9.5
- 0.9.3
- V0.7.8
- 0.7.7
- 0.7.6
- 0.7.5
- 0.7.4
- 0.7.3
- 0.7.2
- 0.7.1
- 0.7.0
- 0.6.13
- 0.6.12
- 0.6.11
- 0.6.10
- 0.6.9
- 0.6.8
- 0.6.7
- 0.6.6
- 0.6.5
- 0.6.4
- 0.6.3
- 0.6.2
- 0.6.1
- 0.6.0
- 0.5.4
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.67
- 0.4.66
- 0.4.65
- 0.4.64
- 0.4.63
- 0.4.62
- 0.4.61
- 0.4.60
- 0.4.59
- 0.4.58
- 0.4.57
- 0.4.55
- 0.4.54
- 0.4.53
- 0.4.52
- 0.4.51
- 0.4.50
- 0.4.49
- 0.4.48
- 0.4.47
- 0.4.46
- 0.4.45
- 0.4.44
- 0.4.43
- 0.4.42
- 0.4.41
- 0.4.40
- 0.4.39
- 0.4.38
- 0.4.37
- 0.4.36
- 0.4.35
- 0.4.34
- 0.4.33
- 0.4.32
- 0.4.31
- 0.4.30
- 0.4.29
- 0.4.28
- 0.4.27
- 0.4.26
- 0.4.25
- 0.4.24
- 0.4.23
- 0.4.22
- 0.4.21
- 0.4.20
- 0.4.19
- 0.4.18
- 0.4.17
- 0.4.16
- 0.4.15
- 0.4.14
- 0.4.13
- 0.4.12
- 0.4.11
- 0.4.10
- 0.4.9
- 0.4.8
- 0.4.7
- 0.4.6
- dev-develop
- dev-feature/json-structure-editor
- dev-feature/database-fork
This package is auto-updated.
Last update: 2025-10-23 19:27:14 UTC
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.