PHP code example of codebar-ag / laravel-feature-policy
1. Go to this page and download the library: Download codebar-ag/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/ */
codebar-ag / laravel-feature-policy example snippets
return [
/*
* A policy will determine which Permissions-Policy headers will be set.
* A valid policy extends `CodebarAg\FeaturePolicy\Policies\Policy`
*/
'policy' => CodebarAg\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
Route::get('/home', 'HomeController')->middleware(CodebarAg\FeaturePolicy\AddFeaturePolicyHeaders::class);
// in a routes file
Route::get('/home', 'HomeController')->middleware(CodebarAg\FeaturePolicy\AddFeaturePolicyHeaders::class . ':' . MyFeaturePolicy::class);
// in a policy
...
->addDirective(Directive::CAMERA, [
Value::SELF,
'spatie.be',
])
->addDirective(Directive::GYROSCOPE, 'self spatie.be')
...
namespace CodebarAg\FeaturePolicy\Policies;
use CodebarAg\FeaturePolicy\Value;
use CodebarAg\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 CodebarAg\FeaturePolicy\Directive;
use CodebarAg\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.