PHPackages                             uzbek/urlex - 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. uzbek/urlex

ActiveLibrary

uzbek/urlex
===========

Generates a Blade directive exporting all of your named Laravel routes.

v0.0.1(6y ago)073MITPHP

Since Jun 2Pushed 6y ago1 watchersCompare

[ Source](https://github.com/avuz/urlex)[ Packagist](https://packagist.org/packages/uzbek/urlex)[ RSS](/packages/uzbek-urlex/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (3)Versions (1)Used By (0)

Urlex - Use your Laravel Named Routes inside JavaScript
=======================================================

[](#urlex---use-your-laravel-named-routes-inside-javascript)

Urlex creates a Blade directive which you can include in your views. This will export a JavaScript object of your application's named routes, keyed by their names (aliases), which you can use to access your routes in your JavaScript.

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

[](#installation)

1. Add Urlex to your Composer file: `composer require uzbek/urlex`
2. (if Laravel 5.4) Add `Uzbek\Urlex\UrlexServiceProvider::class` to the `providers` array in your `config/app.php`.
3. Include our Blade Directive (`@routes`) somewhere in your template before your main application JavaScript is loaded—likely in the header somewhere.

Usage
-----

[](#usage)

This package replaces the `@routes` directive with a collection of all of your application's routes, keyed by their names. This collection is available at `Urlex.namedRoutes`.

### Examples:

[](#examples)

Coming soon

### Default Values

[](#default-values)

See Laravel [documentation](https://laravel.com/docs/5.5/urls#default-values)

Default values work out of the box for Laravel versions &gt;= 5.5.29, for the previous versions you will need to set the default parameters by including this code somewhere in the same page as our Blade Directive (@routes)

```
Urlex.defaultParameters = {
    //example
    locale: "en"
}
```

Filtering Routes
----------------

[](#filtering-routes)

Filtering routes is *completely* optional. If you want to pass all of your routes to JavaScript by default, you can carry on using Urlex as described above.

### Basic Whitelisting &amp; Blacklisting

[](#basic-whitelisting--blacklisting)

To take advantage of basic whitelisting or blacklisting of routes, you will first need to create a standard config file called `Urlex.php` in the `config/` directory of your Laravel app and set **either** the `whitelist` or `blacklist` setting to an array of route names.

**Note: You've got to choose one or the other. Setting `whitelist` and `blacklist` will disable filtering altogether and simply return the default list of routes.**

#### Example `config/Urlex.php`:

[](#example-configurlexphp)

```
