v3.0.1 2017-04-18 13:26 UTC


A small toolkit that I, Ollie, use for various projects.




This method is added to simplify the process of tidying up your routes file. Quite commonly, people complain at the size and I've seen all sorts of methods to split it up, this works like the Route::group() method but allows for extra files.

Route::file($prefix, $file[, $attributes]);

The method takes three arguments, $prefix being the value that will be passed to the prefix attribute of the group, $file being the name of the file, and $attributes being an entirely optional argument that works the same way as it would on Route::group().

NOTE Adding a prefix to $attributes will have no affect and will be overwritten with the value of $prefix.




Route::get('/', [
    'as'    => 'user.index',
    'uses'  => 'UserController@index'

Route::get('/{id}', [
    'as'    => 'user.show',
    'uses'  => 'UserController@show'



Route::file('/user', 'user.php', [
    'namespace' => 'MyApp\Controllers\User', 
    'before' => 'auth'

<a name="validators" />

<a name="validators-base" />

A simple abstract validator class to allow you to separate the validation out. First you define your validator.

<?php namespace MyApp\Validators;

use Ollieread\Toolkit\Validators\BaseValidator;

class UserValidator extends BaseValidator

    public static $rules = [
        'create'    => [
            // put rules here
        'update'    => [
            // put rules here


Now you can do something like App::make('MyApp\Validators\UserValidator') and call either of the following methods.


Run the passed data through the rules within the create part of the $rules array.

validForUpdate($data[, $rules])

Run the passed data through the rules within the update part of the $rules array.

You can also optionally pass in your own rules to override or append to those that have been predefined.


When validation isn't passed a ValidationException is thrown which can be caught, and by using the getErrors() method you can get a MessageBag of the errors that were generated.

If you do not catch it, there is a default handler which will redirect to the previous page, with the input and the errors (if there was a referer), to save messing around adding redirects and try/catch blocks.