1. Go to this page and download the library: Download leafs/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/ */
leafs / cors example snippets
$app = new Leaf\App;
$app->cors();
$app->get('/products/{id}', function () use($app) {
$app->response()->json(['message' => 'This is CORS-enabled for all origins!']);
});
$app->run();
$app = new Leaf\App;
$app->cors([
'origin' => 'http://example.com',
'optionsSuccessStatus' => 200 // some legacy browsers (IE11, various SmartTVs) choke on 204
]);
$app->get('/products/{id}', function () use($app) {
$app->response()->json(['message' => 'This is CORS-enabled for all origins!']);
});
$app->run();