behnam / secure-headers
Add security related headers to HTTP response. The package includes Service Providers for easy Laravel integration.
Requires
- php: ^7.0 || ^8.0
- illuminate/support: ~5.1 || ~6.0 || ~7.0 || ~8.0 || ~9.0
Requires (Dev)
- ext-json: *
- ext-xdebug: *
- orchestra/testbench: ~3.1 || ~4.0 || ~5.0 || ~6.0 || ~7.0
Suggests
- friendsofphp/php-cs-fixer: Coding style fixer
- phpstan/phpstan: Static analysis tool
- phpunit/phpunit: PHP unit testing framework
This package is not auto-updated.
Last update: 2024-11-17 18:34:43 UTC
README
Add security related headers to HTTP response. The package includes Service Providers for easy Laravel integration.
Version
7.2.0
Supported Laravel Version
5.1 ~ 9.x
Installation
Non Laravel Project
Install using composer
composer require Behnam/secure-headers
Copy config file to your project directory
cp vendor/behnam/secure-headers/config/secure-headers.php path/to/your/project/directory
Set up config file
Done!
Laravel Project
Install using composer
composer require behnam/secure-headers
Add service provider in config/app.php
( laravel version < 5.5 )
Behnam\SecureHeaders\SecureHeadersServiceProvider::class,
Publish config file
php artisan vendor:publish --provider="Behnam\SecureHeaders\SecureHeadersServiceProvider"
Add global middleware in app/Http/Kernel.php
\Behnam\SecureHeaders\SecureHeadersMiddleware::class,
Set up config file config/secure-headers.php
Done!
Lumen Project
Install using composer
composer require behnam/secure-headers
Add service provider in bootstrap/app.php
$app->register(Behnam\SecureHeaders\SecureHeadersServiceProvider::class);
Copy config file to project directory
mkdir config cp vendor/behnam/secure-headers/config/secure-headers.php config/secure-headers.php
Add global middleware in bootstrap/app.php
$app->middleware([ \Behnam\SecureHeaders\SecureHeadersMiddleware::class, ]);
Set up config file config/secure-headers.php
Done!
Usage(Non Laravel Project)
Do not forget to import namespace.
<?php use \Behnam\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.
Contributors
Financial Contributors
Become a financial contributor and help us sustain our community. [Contribute]
Individuals
Organizations
Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]
License
Secure Headers is licensed under The MIT License (MIT).