PHPackages                             fbf/laravel-agegate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. fbf/laravel-agegate

ActiveLibrary

fbf/laravel-agegate
===================

A Laravel 4 package for adding an agegate to a site

v0.4.0(12y ago)56291[1 issues](https://github.com/FbF/Laravel-Agegate/issues)MITPHPPHP &gt;=5.3.0

Since Oct 25Pushed 12y ago3 watchersCompare

[ Source](https://github.com/FbF/Laravel-Agegate)[ Packagist](https://packagist.org/packages/fbf/laravel-agegate)[ RSS](/packages/fbf-laravel-agegate/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

Laravel-Agegate
===============

[](#laravel-agegate)

A Laravel 4 package for adding an age gate to a site

Features
--------

[](#features)

- Redirects requests for guarded routes to agegate URL
- Agegate form with input type=date or select tags for year, month and day
- Configurable url for agegate, minimum age, cookie name, cookie value
- Sets 'forever', or 'session' or X minute (configurable) cookie if user is old enough
- Redirects user back to the URL they were trying to access
- Optionally allows bots/crawlers/spiders through age gate using one of 3 approaches

Installation
------------

[](#installation)

Add the following to you composer.json file

```
"fbf/laravel-agegate": "dev-master"

```

Run

```
composer update

```

Add the following to app/config/app.php

```
'Fbf\LaravelAgegate\LaravelAgegateServiceProvider'

```

Publish the config

```
php artisan config:publish fbf/laravel-agegate

```

Configuration
-------------

[](#configuration)

URI of the agegate page

```
'agegate_uri' => 'agegate',

```

The minimum age to access the site

```
'minimum_age' => 18,

```

The input type to use. Choices are: "date" for html5 input type="date" "select" for 3 select tags for day, month and year

```
'input_type' => 'select',

```

The name of the cookie to set. Change this to whatever you want

```
'cookie_name' => 'age_ok',

```

The value of the cookie to set. Change this to something unique

```
'cookie_val' => 'hell yeah!',

```

The age of the cookie to set. Options are 'forever', an integer (minutes) or the default is for the session

```
'cookie_age' => 'forever',

```

Determines whether the user can try again, if they entered a dob that makes them too young, or not. This lasts the session

```
'can_try_again' => false,

```

The view that should be rendered for the agegate. You can use the bundled view, or specify your own and use @include('laravel-agegate::agegate') to get the agegate form and validation errors

```
'view' => 'laravel-agegate::agegate',

```

The mode for allowed user agents (see section on Allowing bots etc below)

```
'allowed_user_agents.mode' => 'phpbrowscap_crawler'

```

The strings for allowed user agents, for the mode = exact or mode = contains setting (see section on Allowing bots etc below)

```
'allowed_user_agents.strings' => array(...)

```

Usage
-----

[](#usage)

Register the filter by adding the following to app/filters.php

```
Route::filter('agegate', 'Fbf\LaravelAgegate\LaravelAgegateFilter');

```

and apply it to the routes you want to protect by adding the following to app/routes.php

```
Route::when('my/routes/*', 'agegate');

```

or

```
Route::group(array('before' => 'agegate'), function()
{
	// My routes
});

```

You also need to add the agegate routes to your app/routes.php, for example:

```
Route::get(
	Config::get('laravel-agegate::agegate_uri'),
	'Fbf\LaravelAgegate\AgegateController@agegate'
);

Route::post(
	Config::get('laravel-agegate::agegate_uri'),
	array(
		'before' => 'csrf',
		'uses' => 'Fbf\LaravelAgegate\AgegateController@doAgegate'
	)
);

```

If you are using route prefixes in combination with the agegate filter, you can do the following:

```
Route::get(
    Request::segment(1).'/'.Config::get('laravel-agegate::agegate_uri'),
    'Fbf\LaravelAgegate\AgegateController@agegate'
);

Route::post(
    Request::segment(1).'/'.Config::get('laravel-agegate::agegate_uri'),
    array(
        'before' => 'csrf',
        'uses' => 'Fbf\LaravelAgegate\AgegateController@doAgegate'
    )
);

```

Allowing bots/crawlers/spiders through
--------------------------------------

[](#allowing-botscrawlersspiders-through)

You can prevent them by setting the config setting `allowed_user_agents.mode` to `none`

If you do want to allow certain user agents through the package provides 3 approaches:

- Using `phpbrowscap_crawler`

    This is a composer package that is installed as a dependency of the agegate package.

    Simply it is a version of the browscap project that doesn't require you to have specified the path to the browscap.ini file in your php.ini.

    The project maintains an up-to-date list of platforms, browsers, versions and capabilities and also details of crawlers. It's the crawlers data that this package uses.

    The way it works is to fetch and cache a copy of the latest browscap.ini file and create a php array cache version too, then it looks us the user agent string in this file to determine if it's a crawler.

    As you may guess, this takes a while the first time it fetches and caches the file, but subsequent checks, once it has the cached copy, are really fast.

    phpbrowscap also self-updates the cache too, so it will always be up-to-date.

    The disadvantage of the overhead on a very occasional request (which may be a bot you don't care about anyway) is outweighed by the advantage of having a more robust test to ensure the filter is not applied to any bots, since the alternative methods (see below) have room for error in that you may not come up with a list of strings to correctly match all the user agents you intended to target.
- Using `contains`

    Add a list of strings to the `allowed_user_agents.strings` config setting and if the user agent contains one of these strings, the age gate will not be applied.
- Using `exact`

    Add a list of strings to the `allowed_user_agents.strings` config setting and if the user agent exactly matches one of these strings, the age gate will not be applied.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~60 days

Total

4

Last Release

4399d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c1890fa7f83fd77b7c73d984199cb9a45ba9871acb4133490f43115c19fe845f?d=identicon)[neilcrookes](/maintainers/neilcrookes)

---

Top Contributors

[![neilcrookes](https://avatars.githubusercontent.com/u/24232?v=4)](https://github.com/neilcrookes "neilcrookes (18 commits)")

### Embed Badge

![Health badge](/badges/fbf-laravel-agegate/health.svg)

```
[![Health](https://phpackages.com/badges/fbf-laravel-agegate/health.svg)](https://phpackages.com/packages/fbf-laravel-agegate)
```

###  Alternatives

[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[slowlyo/owl-admin

基于 laravel、amis 开发的后台框架~

61214.2k26](/packages/slowlyo-owl-admin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
