Download the PHP package mchev/banhammer without Composer

On this page you can find all versions of the php package mchev/banhammer. 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 banhammer

Banhammer 🔨

A simple and powerful ban package for Laravel - ban models, IPs, and countries with ease.

Latest Version on Packagist GitHub Tests Action Status Total Downloads Package for laravel

Banhammer allows you to ban any Eloquent model, IP addresses, and even entire countries. Bans can be permanent or temporary with automatic expiration.


📋 Table of Contents


🚀 Quick Start

Add the trait to your model:

Ban a user:


✨ Features


📦 Installation

Requirements

Laravel compatibility

Laravel Supported since Banhammer
9.x v1.0.0
10.x v1.0.0
11.x v2.2.0
12.x v2.4.0
13.x v2.5.0

Setup

  1. Install the package:

  2. Publish and run migrations:

  3. Publish config (optional):

    💡 The config file allows you to customize table name, model, fallback URLs, and more.


📖 Usage Guide

Banning Models

Make a Model Bannable

Add the Bannable trait to any model:

💡 You can add the trait to multiple models (User, Team, Group, etc.)

Basic Operations

Action Code
Ban a user $user->ban()
Ban with expiration $user->banUntil('2 days')
Check if banned $user->isBanned()
Check if not banned $user->isNotBanned()
Unban $user->unban()

Advanced Ban Options

⚠️ Without expired_at, the ban is permanent.

Query Scopes

List Bans


Banning IPs

Basic Operations

Unban IPs

Check & List Banned IPs


Country Blocking

Block access from specific countries automatically.

Configuration

  1. Enable country blocking in config/ban.php:

  2. Specify blocked countries:

That's it! The middleware will automatically block requests from these countries.

⚠️ Rate Limit Notice: The free version of ip-api.com has a limit of 45 requests/minute. Exceeding this will result in 429 errors until the limit resets.

💡 Want to improve this? If you have suggestions for better geolocation services or want to contribute improvements, please open an issue or submit a pull request.


Middleware

Protect your routes with ban middleware:

Available Middleware

Middleware Description
auth.banned Blocks banned users
ip.banned Blocks banned IPs
logout.banned Logs out and blocks banned users/IPs

Usage

💡 Tip: logout.banned includes the functionality of both auth.banned and ip.banned, so you don't need to use them together.


Scheduler

Banhammer automatically deletes expired bans using Laravel's scheduler.

Setup

⚠️ Important: You must have a cron job running Laravel's scheduler:

See: Laravel Scheduler Docs

Configuration

By default, the banhammer:unban command runs every minute. You can customize this:

Disable automatic scheduler:

Or via environment:

Change frequency:

Or via environment:

Available frequencies: everyMinute, everyFiveMinutes, everyTenMinutes, everyFifteenMinutes, everyThirtyMinutes, hourly, daily, twiceDaily, etc.


Events

Listen to ban/unban events:


🔧 Advanced Topics

Metas

Store additional data with bans:

Filter by Meta

Ban with Metas


UUIDs

To use UUIDs instead of auto-incrementing IDs:

  1. Publish migrations:

  2. Edit the migration:

  3. Create a custom Ban model:

  4. Update config:

Upgrading To 2.0 from 1.x

  1. Update composer.json:

  2. Update the package:

  3. Update configuration:

🛠️ Development

Commands

Programmatic Usage

Testing


🤝 Contributing

We welcome contributions! Please:

💡 Pull requests in "draft" state will be closed after a few days of inactivity.


🙏 Credits

Inspired by laravel-ban from cybercog.


📄 License

The MIT License (MIT). Please see License File for more information.


All versions of banhammer with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
illuminate/cache Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/console Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/contracts Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/http Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/routing Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^9.0|^10.0|^11.0|^12.0|^13.0
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 mchev/banhammer contains the following files

Loading the files please wait ...