PHP code example of damack / ramltosilex

1. Go to this page and download the library: Download damack/ramltosilex library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

damack / ramltosilex example snippets


$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: