-
Notifications
You must be signed in to change notification settings - Fork 100
Zend Framework Expressive
Zend framework officially provides two types of skeleton - Zend MVC and Zend Expressive.
No matter which skeleton you are using, this guide might give you some ideas on how to implement Shieldon Firewall, not sure which way is considered the best practice to Zend, you can pick one you prefer.
Use PHP Composer:
composer require shieldon/shieldon ^2
This will also install dependencies built for Shieldon:
- shieldon/psr-http The PSR-7, 15, 17 Implementation with full documented and well tested.
- shieldon/event-dispatcher The simplest event dispatcher.
- shieldon/web-security The collection of functions about web security.
- shieldon/messenger The collection of modules of sending message to third-party API or service, such as Telegram, Line, RocketChat, Slack, SendGrid, MailGun and more...
This is an example that shows you using a PSR-15 Middleware in Zend Expressive skeleton.
There is a integration class ready for Zend Expressive.
In your pipeline.php
, add this line:
Example:
$app->pipe(\Shieldon\Firewall\Integration\ZendPsr15:class);
Let's go to App/src/Handler
directory and create a PHP file named FirewallPanelHandler
.
Copy the text blew, paste them into that file.
Example:
<?php
declare(strict_types=1);
namespace App\Handler;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Zend\Diactoros\Response;
/**
* Firewall Panel Handler
* If you have CSRF enabled, make sure to pass the csrf token to the control panel.
*/
class FirewallPanelHandler implements RequestHandlerInterface
{
public function handle(ServerRequestInterface $request): ResponseInterface
{
$panel = new \Shieldon\Firewall\Panel();
$panel->entry();
return new Response();
}
}
In your route.php
, add this line:
Example:
// Begin - Shieldon Firewall
$app->route('/firewall/panel/', App\Handler\FirewallPanelHandler::class, ['GET', 'POST']);
foreach(\Shieldon\Firewall\Panel::getRoutes() as $route) {
$app->route("/firewall/panel/$route/", App\Handler\FirewallPanelHandler::class, ['GET', 'POST']);
}
// End - Shieldon Firewall
That's it.
You can access the Firewall Panel by /firewall/panel/
, to see the page, go to this URL in your browser.
https://yourwebsite.com/firewall/panel
The default login is shieldon_user
and password
is shieldon_pass
. After logging in the Firewall Panel, the first thing you need to do is to change the login and password.
Shieldon Firewall will start watching your website if it get enabled in Deamon
setting section, make sure you have set up the settings correctly.
- Author: Terry L. from Taiwan.
- Website: shieldon.io
- GitHub repository: github.com/terrylinooo/shieldon
- WordPress plugin: wordpress.org/plugins/wp-shieldon/
Docs: Laravel, Symfony, CodeIgniter, CakePHP, Yii, Zend, Slim, Fat-Free, Fuel, PHPixie