PHP code example of bigpoint / slim-bootstrap3

1. Go to this page and download the library: Download bigpoint/slim-bootstrap3 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/ */

    

bigpoint / slim-bootstrap3 example snippets




$endpoints = [
    [
        'type'           => SlimBootstrap\Bootstrap::HTTP_METHOD_GET,
        'route'          => '/dummy/test/{id:[0-9]+}',
        'name'           => 'dummy',
        'instance'       => new DummyApi\Endpoint\V1\Dummy(),
        'authentication' => false,
    ],
];

$slimBootstrap = new \SlimBootstrap\Bootstrap();
$slimBootstrap->run($endpoints);
~~~


## Logging

If you want to enable logging for the API, you can inject an instance of
[`\Monolog\Logger`](https://github.com/Seldaek/monolog/) into the framework by calling the `setLogger()` on the
instance of the `\SlimBootstrap\Bootstrap` object (this method is chainable):

~~~diff
-$slimBootstrap->run($endpoints);
+$slimBootstrap->setLogger(new \Monolog\Logger('dummyApi'))->run($endpoints);
~~~


## Create Endpoints

An endpoint is a PHP class that has to implement at least one of the
[`\SlimBootstrap\Endpoint\*`](https://github.com/Bigpoint/slim-bootstrap3/tree/master/src/SlimBootstrap/Endpoint)
interfaces depending on what HTTP method it should support (see below for more details).
All endpoints have to return a PHP array with the data they want to output in the end. The framework will then take
care of rendering this in the correct output format.

### Supported HTTP methods
At the moment the framework supports the following HTTP methods:

 - DELETE
 - GET
 - POST
 - PUT

For each of these methods the framework supplies an interface for the endpoints under
[`\SlimBootstrap\Endpoint\`](https://github.com/Bigpoint/slim-bootstrap3/tree/master/src/SlimBootstrap/Endpoint).

### Registering endpoints to the framework
The written endpoints have to be registered to the framework and the underlying Slim instance in order to be
accessible. This is done by passing an array to the `run()` on the `\SlimBootstrap\Bootstrap` instance. The framework
is using the basic form of slim to [register a route](https://www.slimframework.com/docs/objects/router.html) and bind
an endpoint to the route. However at the moment slim-bootstrap3 doesn't allow grouping of endpoints.
The array has to have the following structure:

~~~php
$endpoints = [
    [
        'type'     => SlimBootstrap\Bootstrap::HTTP_METHOD_GET,
        'route'    => '/dummy/test/{id:[0-9]+}',
        'name'     => 'dummy',
        'instance' => new DummyApi\Endpoint\Dummy(),
    ],
    [
        'type'           => SlimBootstrap\Bootstrap::HTTP_METHOD_GET,
        'route'          => '/dummy/test/{id:[0-9]+}',
        'name'           => 'dummy-other',
        'instance'       => new DummyApi\Endpoint\DummyOther(),
        'authentication' => false
    ],
];
~~~

| parameter       | type                   |