PHP code example of mixerapi / rest

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

    

mixerapi / rest example snippets


# src/Application.php
public function bootstrap(): void
{
    // other logic...
    $this->addPlugin('MixerApi/Rest');
}

# config/routes.php
$routes->scope('/', function (RouteBuilder $builder) {
    // ... other routes
    (new AutoRouter($builder))->buildResources();
    // ... other routes
});

# in your plugins/{PluginName}/routes.php file
(new AutoRouter($builder, new ResourceScanner('MyPlugin\Controller')))->buildResources();

return [
    'MixerApi' => [
        'Rest' => [
            'crud' => [
                'statusCodes' => [
                    'index' => 200,
                    'view' => 200,
                    'add' => 201,
                    'edit' => 200,
                    'delete' => 204
                ]
            ]
        ]
    ]
];