Skip to content

tristankenney/php-raml-parser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP RAML Parser

Parses a RAML file into a PHP object.

Build Status Coverage Status HHVM Status

See the RAML spec here: https://github.com/raml-org/raml-spec

Converts JSON schemas into a PHP objects using https://github.com/justinrainbow/json-schema

Get started

./composer.phar install --dev
./vendor/bin/phpunit test
$parser = new \Raml\Parser();
$apiDef = $parser->parse($filename, true);

$title = $apiDef->getTitle();

Exporting routes

It is possible to export the entire RAML file to an array of the full endpoints. For example, considering a basic RAML, this can be returned using:

$parser = new Raml\Parser();
$api = $parser->parse('test/fixture/simple.raml');

$routes = $api->getResourcesAsUri();

[
	GET /songs => ...
	POST /songs => ...
	GET /songs/{songId} => ...
	DELETE /songs/{songId} => ...
]

$routes = $api->getResourcesAsUri(new Raml\Formatters\NoRouteFormatter());

Route Formatters

There are two Route Formatters included in this package:

  • NoRouteFormatter which does nothing and simply echoes the result
  • SymfonyRouteFormatter which adds the routes to a Symfony RouteCollection

Contributing

./vendor/bin/phpunit
./vendor/bin/phpunit --coverage-text
./vendor/bin/phpcs --standard=PSR1,PSR2 src

TODO

  • Make the code prettier
  • Add support for the complete raml spec
    • SecuredBy
    • Markdown?
    • Date Representations?
  • Validation?
  • Parse RAML at URL instead of file?

Supported (I Believe)

  • Includes
    • .yml/.yaml
    • .raml/.rml
    • .json (parsed using json-schema)
  • Display Name
  • Traits
  • Resource Types

About

A RAML parser built in php

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%