Introduction
A framework agnostic driver-based content rendering package, with support for HTML, Markdown & plain text.
You can register custom drivers for custom content types.
As you pass content to interpret, it will determine what it is and allow you to extract it's normal value and HTML equivalent.
The package requires PHP 5.3+ and comes bundled with a Laravel 4 and a Service Provider to simplify the optional framework integration and follows the FIG standard PSR-4 to ensure a high level of interoperability between shared PHP code and is fully unit-tested.
Have a read through the Installation Guide and on how to Integrate it with Laravel 4.
Installation
Cartalyst packages utilize Composer, for more information on how to install Composer please read the Composer Documentation.
Preparation
Open your composer.json
and add the following to the require
array:
"cartalyst/interpret": "1.1.*"
Note: Make sure that after the required changes your
composer.json
file is valid by runningcomposer validate
.
Install the dependencies
Run Composer to install or update the new requirement.
composer install
or
composer update
Note: We're assuming you have Composer installed Globally.
Now you are able to require the vendor/autoload.php
file to autoload the package.
Integration
Cartalyst packages are framework agnostic and as such can be integrated easily natively or with your favorite framework.
Laravel 4
The Interpret package has optional support for Laravel 4 and it comes bundled with a Service Provider and a Facade for easy integration.
After installing the package, open your Laravel config file located at app/config/app.php
and add the following lines.
In the $providers
array add the following service provider for this package.
'Cartalyst\Interpret\Laravel\InterpretServiceProvider',
In the $aliases
array add the following facade for this package.
'Interpreter' => 'Cartalyst\Interpret\Laravel\Facades\Interpreter',
Native
Integrating the package outside of a framework is incredible easy, just follow the example below.
// Include the composer autoload file
require_once 'vendor/autoload.php';
// Import the necessary classes
use Cartalyst\Interpret\Interpreter;
// Instantiate the interpreter
$interpreter = new Interpreter;
The integration is done and you can now use all the available methods, here's an example:
// Convert from markdown to html
echo $interpreter->make('## Hello', 'md')->toHtml();
Usage
In this section we'll show you how to use the interpret package.
Convert Markdown to HTML
$content = Interpreter::make('# Hello', 'md')->toHtml();