jackpopp/tura

Tura - use laravel named routes in your javascript.
31 7
Install
composer require jackpopp/tura
Latest Version:1.2
PHP:>=5.4.0
Laravel:4
License:MIT
Last Updated:May 1, 2015
Links: GitHub  ·  Packagist
Maintainer: jackpopp

Tura

Use laravel named routes in your javascript.

Register named routes in routes.php and add they key tura with the value true to the options array. Tura will only expose routes which have been set to be exposed.

Route::get('/', array(
    'uses' => 'HomeController@index',
    'as'   => 'home',
    'tura' => true
));

Route::get('user', array(
    'uses' => 'HomeController@index',
    'as'   => 'user.create'
));

Route::get('user/{id}', array(
    'uses' => 'HomeController@index',
    'as'   => 'user.show',
    'tura' => true
));

You can now access your exposed named routes as a JSON object by calling the fetch routes method (this could be called in your master blade layout for example).

Tura::fetchRoutes();

The named routes will now be available in the javascript global scope by calling the tura object

console.log(tura)
Object {home: "/", user.show: "user/{id}"}
console.log(tura['user.show'])
"user/{id}"

Install via composer add to require in composer.json

"jackpopp/tura": "dev-master"

Add the service provider and class alias to app.php config (found in app/config/app.php)

Add to the providers array

'Jackpopp\Tura\TuraServiceProvider',

Add to the aliases array

'Tura' => 'Jackpopp\Tura\TuraServiceProvider',

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

644,549,754 9,698
laravel/framework

The Laravel Framework.

598,760,099 34,966
laravel/tinker

Powerful REPL for the Laravel framework.

507,193,856 7,441
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

423,477,751 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

399,241,428 4,660

Version History

Version Released PHP Laravel License
1.2 >=5.4.0 4.2.* MIT
1.1 >=5.4.0 4.2.* MIT
1.0 >=5.4.0 4.2.*