PHP code example of mazedlx / laravel-feature-policy
1. Go to this page and download the library: Download mazedlx/laravel-feature-policy 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/ */
mazedlx / laravel-feature-policy example snippets
return [
/*
* A policy will determine which "Permissions-Policy" headers will be set.
* A valid policy extends `Mazedlx\FeaturePolicy\Policies\Policy`
*/
'policy' => Mazedlx\FeaturePolicy\Policies\Basic::class,
/*
* "Feature-Policy" headers will only be added if this is set to true
*/
'enabled' => env('FPH_ENABLED', true),
];
// in a routes file
use App\Http\Controllers\HomeController;
use Mazedlx\FeaturePolicy\AddFeaturePolicyHeaders;
Route::get('/home', HomeController::class)
->middleware(AddFeaturePolicyHeaders::class);
// in a routes file
use App\Http\Controllers\HomeController;
use Mazedlx\FeaturePolicy\AddFeaturePolicyHeaders;
Route::get('/home', HomeController::class)
->middleware(AddFeaturePolicyHeaders::class . ':' . MyFeaturePolicy::class);
// in a policy
...
->addDirective(Directive::CAMERA, [
Value::SELF,
'spatie.be',
])
->addDirective(Directive::GYROSCOPE, 'self spatie.be')
...
namespace Mazedlx\FeaturePolicy\Policies;
use Mazedlx\FeaturePolicy\Value;
use Mazedlx\FeaturePolicy\Directive;
class Basic extends Policy
{
public function configure()
{
$this->addDirective(Directive::GEOLOCATION, Value::SELF)
->addDirective(Directive::FULLSCREEN, Value::SELF);
}
}
namespace App\Services\FeaturePolicy\Policies;
use Mazedlx\FeaturePolicy\Directive;
use Mazedlx\FeaturePolicy\Policies\Basic;
class MyFeaturePolicy extends Basic
{
public function configure()
{
parent::configure();
$this->addDirective(Directive::GEOLOCATION, 'www.awesomesite.com')
->addDirective(Directive::FULLSCREEN, 'www.awesomesite.com');
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.