markup-carve / cakephp-carve
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
Requires
- php: ^8.2
- cakephp/cakephp: ^5.2
- markup-carve/carve-php: ^0.1.14
Requires (Dev)
- php-collective/code-sniffer: ^0.6.0
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^11.5 || ^12.0 || ^13.0
- symfony/yaml: ^7.0 || ^8.0
Suggests
- ext-yaml: Alternative YAML frontmatter parser
- symfony/yaml: Parses YAML frontmatter for RenderedCarve::meta() and CarveView
Provides
None
Conflicts
None
Replaces
None
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.