pichicacax/laravel-js-route

Convert all your routes and enable named route usage in Javascript

Installs: 26

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/pichicacax/laravel-js-route

v1.0.0 2020-02-14 03:09 UTC

This package is auto-updated.

Last update: 2025-12-18 10:52:04 UTC


README

Convert all your routes and enable named route usage in the front-end.

Laravel Support

Compatible with Laravel 6.x, 5.8, and 5.7.

Installation

  1. Install via Composer
composer require pichicacax/laravel-js-route
  1. Add the following service provider to your config/app.php file
Pichicacax\LaravelJsRoute\LaravelJsRouteServiceProvider::class

Usage

Generating routes for JS

php artisan route:js

By default, the JS target is resources/assets/js/routes.js. You may change this by providing a custom target

php artisan route:js /path/custom-target.js

JS usage

import {route} from './routes';

Generate a URL using a named route

route("welcome")

Providing parameters

route("foo.edit", fooId)
route("bar.index", {
	param1: value1, 
	param2: value2
})