Download the PHP package ryudith/mezzio-block-ip without Composer

On this page you can find all versions of the php package ryudith/mezzio-block-ip. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package mezzio-block-ip

mezzio-block-ip

Ryudith\MezzioBlockIp is middleware to block IP based on request.

Version 1.1.0 remove code auto register route when helper configuration is enable (enable_helper) also remove enable_helper from configuration and add CLI helper version.
To enable helper please read enable helper below.

Installation

To install run command :

Usage

Add Ryudith\MezzioBlockIp\ConfigProvider to config/config.php

Add Ryudith\MezzioBlockIp\BlockIPMiddleware to config/pipeline.php

You can place $app->pipe(BlockIPMiddleware::class) before $app->pipe(ErrorHandler::class) if you want.

Custom Configuration

Configuration is locate in vendor/ryudith/mezzio-block-ip/ConfigProvider.php :

Detail :

  1. limit_hit
    is how many request hit per limit_duration before blocked.

  2. limit_duration
    is duration for limit_hit in second.

  3. request_real_ip_key
    is assoc key for get IP from $_SERVER or $_ENV variable.

  4. ip_data_dir
    is directory location to save record request IP, since the storage implementation is file system based.

  5. blacklist_data_dir
    is directory location to save blacklist file.

  6. whitelist_data_dir
    is directory location to save whitelist file.

  7. file_data_delimiter
    is data delimiter inside file.

  8. ip_storage_class
    is implementation class of Ryudith\MezzioBlockIp\Storage\StorageInterface that will do work to check, create, delete blacklist or whitelist data.

  9. ip_response_class
    is implementation class of Ryudith\MezzioBlockIp\SimpleResponse\SimpleResponseInterface that will give response from blacklist IP.

  10. admin_whitelist_ip
    is string array whitelist permanent IP for admin.

Enable Helper

To enable helper add the following items to factories configuration (usually in config/dependencies.global.php) :

Then for web helper register helper to routes.php

Make sure your blacklist_uri_path and whitelist_uri_path value is match to your route path.

For web helper you can change default configuration values as listed below by add array key to mezzio_block_ip configuration, also don't forget to add your IP to whitelist to be able access helper.

  1. helper_url_param_op
    is URL query parameter key for helper operation. Default 'op' and the option value is 'add' or 'delete'.

  2. helper_url_param_ip
    is URL query parameter key for helper data IP, default value 'ip'.

  3. blacklist_uri_path
    is URI path for blacklist helper operation.

  4. whitelist_uri_path
    is URI path for whitelist helper operation.

Change default configuration web helper value

Create new file config/autoload/blockip.local.php and add :

Then you can access helper with URL http://localhost:8080/blockip/blacklist?operation=add&ip=userip.168.0.12 with your whitelist IP.

For CLI helper you need to register helper command to laminas-cli commands configuration usually locate in file config/autoload/mezzio.global.php :

Change your:command to your own choice command.

Documentation

API Documentation

Issues or Questions


All versions of mezzio-block-ip with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0.0
psr/http-server-middleware Version ^1.0
psr/container Version ^1.0
laminas/laminas-diactoros Version ^2.11
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ryudith/mezzio-block-ip contains the following files

Loading the files please wait ...