2017 © Pedro Peláez
 

cakephp-plugin markdown-plugin

A CakePHP plugin that facilitates the use of PHP Markdown with CakePHP

image

maurymmarques/markdown-plugin

A CakePHP plugin that facilitates the use of PHP Markdown with CakePHP

  • Tuesday, February 10, 2015
  • by maurymmarques
  • Repository
  • 4 Watchers
  • 24 Stars
  • 955 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 9 Forks
  • 0 Open issues
  • 1 Versions
  • 6 % Grown

The README.md

Markdown plugin for CakePHP

This plugin facilitates the use of PHP Markdown with CakePHP, (*1)

PHP Markdown is a port to PHP of the Markdown program written by John Gruber., (*2)

“Markdown” is two things: a plain text markup syntax, and a software tool that converts the plain text markup to HTML for publishing on the web., (*3)

More info: http://michelf.com/projects/php-markdown, (*4)

For this plugin, the application Markdown is inside Vendor, (*5)

Version

Written for CakePHP 2.x, (*6)

Copyright (c) 2011 Maury M. Marques, (*7)

Installation

You can install this plugin using Composer, GIT Submodule, GIT Clone or Manually, (*8)

[Using Composer], (*9)

Add the plugin to your project's composer.json - something like this:, (*10)

{
  "require": {
    "maurymmarques/markdown-plugin": "dev-master"
  },
  "extra": {
    "installer-paths": {
      "app/Plugin/Markdown": ["maurymmarques/markdown-plugin"]
    }
  }
}

Then just run composer install, (*11)

Because this plugin has the type cakephp-plugin set in it's own composer.json, composer knows to install it inside your /Plugin directory, rather than in the usual vendors file., (*12)

[GIT Submodule], (*13)

In your app directory (app/Plugin) type:, (*14)

git submodule add git://github.com/maurymmarques/markdown-cakephp.git Plugin/Markdown
git submodule init
git submodule update

[GIT Clone], (*15)

In your plugin directory (app/Plugin or plugins) type:, (*16)

git clone https://github.com/maurymmarques/markdown-cakephp.git Markdown

[Manual], (*17)

  • Download the Markdown archive.
  • Unzip that download.
  • Rename the resulting folder to Markdown
  • Then copy this folder into app/Plugin/ or plugins

Configuration

Bootstrap the plugin in app/Config/bootstrap.php:, (*18)

CakePlugin::load(array('Markdown' => array('bootstrap' => true)));

Usage

Enable the helper using the plugin syntax, (*19)

If desired, set the component to assist with the return of data from the markdown., (*20)

// in app/Controller/BakeriesController.php
class BakeriesController extends AppController {

        public $helpers = array('Markdown.Markdown');

        public function index() {
            $this->set('textInMarkdownFormat', $yourTextInMarkdownFormat);
        }
}

Or, if the markdown content is in a file..., (*21)

// in app/Controller/BakeriesController.php
class BakeriesController extends AppController {

        public $helpers = array('Markdown.Markdown');
        public $components = array('Markdown.Markdown');

        public function index() {
            $this->set('textInMarkdownFormat', $this->Markdown->getFile($pathToMarkdownFile));
        }
}

In the view you can use something like:, (*22)

// in app/View/Bakeries/index.ctp
echo $this->Markdown->transform($textInMarkdownFormat);

In the model you can use something like:, (*23)

```php // in app/Model/Bakery.php class BakeryModel extends AppModel {, (*24)

public $actsAs = array('Markdown.Markdown');

public function beforeSave($options = array()) {
    $this->data[$this->alias]['text_html'] = $this->transform( $this->data[$this->alias]['text_md'] );
    return true;
}

}, (*25)

The Versions

10/02 2015

dev-master

9999999-dev https://github.com/maurymmarques/markdown-cakephp

A CakePHP plugin that facilitates the use of PHP Markdown with CakePHP

  Sources   Download

MIT

The Requires

 

by Maury M. Marques

plugin cakephp markdown