Download the PHP package mfn/laravel-view-docblock without Composer
On this page you can find all versions of the php package mfn/laravel-view-docblock. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mfn/laravel-view-docblock
More information about mfn/laravel-view-docblock
Files in mfn/laravel-view-docblock
Package laravel-view-docblock
Short Description Laravel View docblock argument validation
License MIT
Homepage http://github.com/mfn/php-laravel-view-docblock
Informations about the package laravel-view-docblock
Laravel View Docblock
Homepage: https://github.com/mfn/php-laravel-view-docblock
Blurb
Add a docblock to your view, describing what parameters and types the template accepts and let the library automatically handle the argument type validation.
Never fear of a) now knowing what arguments a template accepts and b) what types they should be.
Requirements
PHP 5.6 / Laravel 5.0/5.1
Install / Setup
Using composer: composer.phar require mfn/laravel-view-docblock 0.1
Register the service provider in your config/app.php
by add this line to your
providers
entry: Mfn\Laravel\ViewDocblock\Provider::class
Note: it is advisable to register the provider after the laravel framework providers and before your custom ones.
Publish the configuration:
php artisan vendor:publish --provider="Mfn\Laravel\ViewDocblock\Provider"
Example
Instead of:
you add a docblock, specifying what parameters and types are accepted:
For a list of supported defaul types, please see https://github.com/mfn/php-parameter-validation
Configuration
-
enable_production
: Set to true to enable validation in production too. Defaults tofalse
. -
require_docblock_on_data
: Set to true to require a docblock on every template file. Defaults tofalse
. -
report_missing_arguments
: Set to true to report missing parameter types as errors. Defaults tofalse
. -
argument_blacklist
: A list of variables which should automatically be excluded from the validation. Useful for global or internal variables which are available in all templates. additional_types
: register additional validation types, specific for Laravel:CollectionType
: supportsCollection<SomeObject>
. Note: if an inner object type is provided (SomeObject
in this example), the collection is iterated to ensure the types match!TraversableType
: transparently supports any class implementing theTraversable
interface like an array. Note: inner types are ignored when encountering such a type.
The default settings are for easy getting started/integrating into existing projects. To take full effect of the library, the recommended settings are:
require_docblock_on_data
=>true
report_missing_arguments
=>true
However, undertand that Laravel is notorious in passing "global" variables to
all templates, e.g. $errors
is supposedly always available, which may render
the option report_missing_arguments
being set to true
quite annoying.
Contribute
Fork it, hack on a feature branch, create a pull request, be awesome!
No developer is an island so adhere to these standards:
© Markus Fischer [email protected]
All versions of laravel-view-docblock with dependencies
illuminate/support Version 5.0.x|5.1.x
illuminate/view Version 5.0.x|5.1.x
mfn/docblock-normalize Version 0.1
mfn/argument-validation Version 0.2