PHP Classes

PHP RAML to HTML: Parse RAML of an API to generate documentation

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 151 All time: 9,071 This week: 524Up
Version License PHP version Categories
raml2html 1.1GNU General Publi...5.3PHP 5, Web services, Parsers
Description 

Author

This class is a parser for RAML (RESTful API Markup Language) for a given API.

It can parse a given file with the definitions of a REST API in the YAML RAML format.

The class can returns arrays with the details of the API definitions that can be passed to a template processing script that outputs the documentation.

Innovation Award
PHP Programming Innovation award nominee
September 2014
Number 6


Prize: One copy of DWebPro Standard License
RAML (REST API Markup Language) is a specification for defining the function calls made available by a given REST API.

This class can parse the definitions of a REST API in RAML format and generates API documentation automatically.

Manuel Lemos
Picture of Mike Stowe
Name: Mike Stowe is available for providing paid consulting. Contact Mike Stowe .
Classes: 6 packages by
Country: United States United States
Age: 39
All time rank: 1375198 in United States United States
Week rank: 227 Up23 in United States United States Up
Innovation award
Innovation award
Nominee: 2x

Example

<?php
/**
  * RAML2HTML for PHP -- A Simple API Docs Script for RAML & PHP
  * @version 1.1beta
  * @author Mike Stowe <me@mikestowe.com>
  * @link https://github.com/mikestowe/php-raml2html
  * @link http://www.mikestowe.com/2014/05/raml-2-html.php
  * @license http://www.gnu.org/licenses/gpl-2.0.html GPL v2
  */

require_once('inc/spyc.php');
require_once(
'inc/ramlDataObject.php');
require_once(
'inc/raml.php');
require_once(
'inc/ramlPathObject.php');
require_once(
'config.php');


// Dangling Function
function formatResponse($text) {
    return
str_replace(array(" ", "\n"), array("&nbsp;", "<br />"), htmlentities($text));
}


// Handle Caching and Build
$RAML = false;
if (
$cacheTimeLimit && function_exists('apc_fetch')) {
   
$RAML = apc_fetch('RAML' . md5($RAMLsource));
} elseif (!
$cacheTimeLimit && function_exists('apc_fetch')) {
   
// Remove existing cache files
   
apc_delete('RAML' . md5($RAMLsource));
}

if (!
$RAML) {
   
$RAMLarray = spyc_load(file_get_contents($RAMLsource));
   
$RAML = new RAML2HTML\RAML($RAMLactionVerbs);

   
$RAML->setIncludePath(dirname($RAMLsource) . '/');
   
$RAML->buildFromArray($RAMLarray);
   
    if (
$cacheTimeLimit && function_exists('apc_store')) {
       
apc_store('RAML' . md5($RAMLsource), $RAML, $cacheTimeLimit);
    }
}


// Set Current Path
if (isset($_GET['path'])) {
   
$RAML->setCurrentPath($_GET['path']);
    unset(
$_GET['path']);
}


// Set Current Action
if (isset($_GET['action']) && $RAML->isActionValid($_GET['action'])) {
   
$RAML->setCurrentAction($_GET['action']);
    unset(
$_GET['action']);
}

// Render Template
require_once($docsTheme);

?>


Details

RAML 2 HTML for PHP

RAML 2 HTML for PHP is a simple application that makes use of multiple templates to allow you to build and customize your API Docs using RAML.

Screenshot

What version of PHP does RAML 2 HTML require?

RAML 2 HTML for PHP versions 1.0 or greater require PHP 5.3+

If you are running an older version of PHP, it is highly recommend you upgrade, but if you are unable to do so, you can use RAML version 0.2 which supports PHP 5+. However, this version is extremely limited and is not being maintained or supported.

How do I set it up?

Important setup information is stored in config.php. You can read setup instructions here.

Is there a Demo?

Yes! You can find the latest stable demo and the latest development version demos here.

Does it support all RAML features?

Not yet, although version 1.0 was a complete rewrite supports base, path variables, multi-level includes, traits, and more. Other features will be added down the road!

How Can I Help?

Easy! Download and use RAML 2 HTML for PHP, tell your friends, if you find issues report them, or even better - feel free to contribute by forking and making pull requests!

License

RAML is covered under the GPL2 license. However, the included class Spyc falls under the MIT license.


  Files folder image Files (16)  
File Role Description
Files folder imageinc (4 files)
Files folder imageraml (3 files)
Files folder imagetemplates (1 directory)
Accessible without login Plain text file config.php Conf. Configuration script
Accessible without login Plain text file index.php Example Application script
Accessible without login Plain text file README.md Data Auxiliary data

  Files folder image Files (16)  /  inc  
File Role Description
  Plain text file raml.php Class Class source
  Plain text file ramlDataObject.php Class Class source
  Plain text file ramlPathObject.php Class Class source
  Plain text file spyc.php Class Class source

  Files folder image Files (16)  /  raml  
File Role Description
  Accessible without login Plain text file github.raml Data GitHub RAML File
  Accessible without login Plain text file githubrepo.raml Data Auxiliary data
  Accessible without login Plain text file songs.raml Data Auxiliary data

  Files folder image Files (16)  /  templates  
File Role Description
Files folder imagegrey (6 files)

  Files folder image Files (16)  /  templates  /  grey  
File Role Description
  Accessible without login Plain text file index.phtml Aux. Sample output
  Accessible without login Plain text file _404.phtml Data Sample output
  Accessible without login Plain text file _action.phtml Appl. Sample output
  Accessible without login Plain text file _menu.phtml Aux. Sample output
  Accessible without login Plain text file _resources.phtml Aux. Sample output
  Accessible without login Plain text file _verbs.phtml Aux. Sample output

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:151
This week:0
All time:9,071
This week:524Up
User Comments (1)
very good class
10 years ago (pooya sabramooz)
67%StarStarStarStar