bepsvpt / secure-headers
Add security related headers to HTTP response. The package includes Service Providers for easy Laravel integration.
Fund package maintenance!
Open Collective
Installs: 3 224 176
Dependents: 10
Suggesters: 0
Security: 0
Stars: 510
Watchers: 19
Forks: 45
Open Issues: 1
Requires
- php: ^7.0 || ^8.0
- ext-json: *
Requires (Dev)
- ext-xdebug: *
- ergebnis/composer-normalize: ^2.42
- laravel/pint: ^1.14
- orchestra/testbench: ^3.1 || ^4.18 || ^5.20 || ^6.43 || ^7.41 || ^8.22 || ^9.0
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^5.7 || ^6.5 || ^7.5 || ^8.5 || ^9.6 || ^10.5
This package is auto-updated.
Last update: 2024-12-16 15:48:31 UTC
README
Add security related headers to HTTP response. The package includes Service Providers for easy Laravel integration.
Version
8.0.0
Supported Laravel Version
5.1 ~ 11.x
Installation
Non Laravel Project
Install using composer
composer require bepsvpt/secure-headers
Copy config file to your project directory
cp vendor/bepsvpt/secure-headers/config/secure-headers.php path/to/your/project/directory
Set up config file
Done!
Laravel Project
Install using composer
composer require bepsvpt/secure-headers
Add service provider in config/app.php
( laravel version < 5.5 )
Bepsvpt\SecureHeaders\SecureHeadersServiceProvider::class,
Publish config file
php artisan vendor:publish --provider="Bepsvpt\SecureHeaders\SecureHeadersServiceProvider"
Add global middleware in app/Http/Kernel.php
\Bepsvpt\SecureHeaders\SecureHeadersMiddleware::class,
Set up config file config/secure-headers.php
Done!
Lumen Project
Install using composer
composer require bepsvpt/secure-headers
Add service provider in bootstrap/app.php
$app->register(Bepsvpt\SecureHeaders\SecureHeadersServiceProvider::class);
Copy config file to project directory
mkdir config cp vendor/bepsvpt/secure-headers/config/secure-headers.php config/secure-headers.php
Add global middleware in bootstrap/app.php
$app->middleware([ \Bepsvpt\SecureHeaders\SecureHeadersMiddleware::class, ]);
Set up config file config/secure-headers.php
Done!
Usage(Non Laravel Project)
Do not forget to import namespace.
<?php use \Bepsvpt\SecureHeaders\SecureHeaders;
Instance
<?php // instantiate the class by fromFile static method $secureHeaders = SecureHeaders::fromFile('/path/to/secure-headers.php'); // or instantiate the class directly $config = require '/path/to/secure-headers.php'; $config['key'] = 'value'; // modify config value if needed $secureHeaders = new SecureHeaders($config);
Send
// Get headers $secureHeaders->headers(); // Send headers to HTTP response $secureHeaders->send();
Document and Notice
Please see DOCS for details.
Changelog
Please see CHANGELOG for details.
Upgrade
Please see UPGRADE for details.
License
Secure Headers is licensed under The MIT License (MIT).