damack / ramltosilex
Silex Provider that generates REST API from a RAML description file
Installs: 60
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Language:JavaScript
Requires
- alecsammon/php-raml-parser: ^2.2
- doctrine/dbal: ^2.5
- league/oauth2-google: ^2.0
- pagerfanta/pagerfanta: ^1.0
- silex/silex: ^2.1
- symfony/form: ^3.3
Requires (Dev)
- phpunit/dbunit: ^2.0
- phpunit/phpunit: ^5.3
This package is not auto-updated.
Last update: 2025-01-08 21:03:27 UTC
README
RamlToSilex is a Silex provider to setting up a REST API on top of a relational database, based on a YAML (RAML) configuration file.
What is RAML ?
RESTful API Modeling Language (RAML) is a simple and sufficient way of describing practically-RESTful APIs. It encourages reuse, enables discovery and pattern-sharing, and aims for merit-based emergence of best practices.
Installation
To install RamlToSilex library, run the command below and you will get the latest version:
composer require damack/ramltosilex
Enable ServiceController
, Doctrine
and RamlToSilex
service providers in your application:
$app = new Application(); $app->register(new \Silex\Provider\ServiceControllerServiceProvider()); $app->register(new \Silex\Provider\DoctrineServiceProvider(), array( 'dbs.options' => array( 'test' => array( 'driver' => 'pdo_sqlite', 'path' => __DIR__ . '/db.sqlite' ) ), )); $app->register(new Damack\RamlToSilex\RamlToSilexServiceProvider(), array( 'ramlToSilex.raml_file' => __DIR__ . '/raml/api.raml', 'ramlToSilex.config_file' => __DIR__ . '/config.json', 'ramlToSilex.google-app-id' => 'id', 'ramlToSilex.google-app-secret' => 'secret', 'ramlToSilex.google-redirect-uri' => 'http://localhost/', 'ramlToSilex.redirectUri' => 'http://localhost/login.html', 'ramlToSilex.customController' => function() use ($app) { return new CustomController($app); } )); - You need to give the path to the `RAML` file describing your API. You can find an example into the `tests/raml` directory - You need to give the path to the config file describing your access to the routs and custom controller - You need to give the app-id, app-secret and redirect-uri so google auth can work ## Function - Create table from schema definition - Goolge OAuth authentication - API authentication with token - Role based access to routes - Hidden fields for get - Custom controller - API console ### Missing function - Input validation ## Tests Run the tests suite with the following commands: ```bash composer install composer test
License
is licensed under the MIT License