PHP code example of agungsugiarto / codeigniter4-cors

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

    

agungsugiarto / codeigniter4-cors example snippets


public $aliases = [
    'cors' => \Fluent\Cors\Filters\CorsFilter::class,
    // ...
];

public $filters = [
    // ...
    'cors' => [
        'before' => ['api/*'],
        'after' => ['api/*']
    ],
];

$routes->get('api/users', 'UserController::index', ['filter' => 'cors']);

$routes->group('api/v1', ['filter' => 'cors'], function ($routes) {
    // ...
});
sh
php spark cors:publish