Search by

markup-carve / cakephp-carve

dereuromark

CakePHP plugin for Carve: rendering, views, validation, ORM behavior, commands and caching

Package info

github.com/markup-carve/cakephp-carve

Type:cakephp-plugin

pkg:composer/markup-carve/cakephp-carve

Statistics

Installs: 131

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 1

0.1.2 2026-10-23 16:32 UTC

This package is auto-updated.

Last update: 2026-10-24 01:53:03 UTC


README

CakePHP wrapper for Carve rendering, templates, validation, persistence, and commands.

View the live demo →: presets and safe mode, validation, the ORM behavior and .crv views in a running CakePHP app.

See composer.json for supported versions and the version map for which plugin line matches which CakePHP and carve-php release.

Install

composer require markup-carve/cakephp-carve

Load the plugin in your application:

$this->addPlugin('MarkupCarve/CakeCarve');

Load the helper in AppView::initialize():

$this->addHelper('MarkupCarve/CakeCarve.Carve');

Use

$carve = new \MarkupCarve\CakeCarve\Carve\CarveRenderer();
$html = $carve->toHtml('# Hello');
$result = $carve->render('# Hello', ['preset' => 'comment']);
$toc = $result->toc();
$text = $carve->toText('Hello');
$markdown = $carve->toMarkdown('Hello');
$ansi = $carve->toAnsi('Hello');
$file = $carve->renderFile('/path/to/article.crv');
$formatted = $carve->format('Hello');
$findings = $carve->lint('Hello');
$imported = $carve->import('**Hello**', 'markdown');

In a template, call the helper's convert, render, text, markdown, toc, file, lint, or format methods. For .crv templates, use CarveView::class as the controller view class. The view supplies $carve['meta'] and $carve['toc'] to layouts.

Add CarveValidation::class as a validator provider:

$validator->setProvider('carve', \MarkupCarve\CakeCarve\Validation\CarveValidation::class)
    ->add('body', 'carve', ['rule' => ['valid', ['preset' => 'comment']], 'provider' => 'carve']);

Attach CarveBehavior to render source fields when an entity is saved:

$this->addBehavior('MarkupCarve/CakeCarve.Carve', [
    'fields' => ['body' => ['target' => 'body_html', 'text' => 'body_text']],
]);

Run bin/cake carve render, carve convert, carve format, or carve lint for file operations.

See the documentation and configuration example.