{"id":36969697,"url":"https://github.com/mputkowski/laroute","last_synced_at":"2026-01-13T21:36:46.901Z","repository":{"id":57045411,"uuid":"146770881","full_name":"mputkowski/laroute","owner":"mputkowski","description":"Generate Laravel route URLs from JavaScript.","archived":false,"fork":true,"pushed_at":"2019-03-25T15:08:30.000Z","size":325,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-10T16:35:09.970Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"aaronlord/laroute","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mputkowski.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-30T15:36:19.000Z","updated_at":"2024-04-10T16:35:09.971Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/mputkowski/laroute","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mputkowski/laroute","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mputkowski%2Flaroute","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mputkowski%2Flaroute/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mputkowski%2Flaroute/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mputkowski%2Flaroute/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mputkowski","download_url":"https://codeload.github.com/mputkowski/laroute/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mputkowski%2Flaroute/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28400957,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-13T21:36:45.950Z","updated_at":"2026-01-13T21:36:46.894Z","avatar_url":"https://github.com/mputkowski.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laroute\n\n[Laravel](http://laravel.com/) has some pretty sweet [helper functions](http://laravel.com/docs/helpers#urls) for generating urls/links and its auto-json-magic makes it building APIs super easy. It's my go-to choice for building single-page js apps, but routing can quickly become a bit of a pain.\n\nWouldn't it be amazing if we could access our Laravel routes from JavaScript?\n\nThis package allows us to port our routes over to JavaScript, and gives us a bunch of _very familiar_ helper functions to use.\n\n![Laroute in action](laroute.png)\n\n## Installation\n\nInstall the usual [composer](https://getcomposer.org/) way.\n\n###### composer.json\n```json\n{\n\t\"require\" : {\n\t\t\"lord/laroute\" : \"2.*\"\n\t}\n}\n```\n\nn.b Laravel 4.x users, check out [version 1.3.2](https://github.com/aaronlord/laroute/tree/v1.3.2)\n\n###### app/config/app.php\n```php\n\t...\n\t\n\t'providers' =\u003e array(\n\t\t...\n\t\tLord\\Laroute\\LarouteServiceProvider::class,\n\t],\n\t\n\t...\n```\n\n### Configure (optional)\n\nCopy the packages config files.\n\n```\nphp artisan vendor:publish --provider='Lord\\Laroute\\LarouteServiceProvider'\n```\n\n###### app/config/packages/lord/laroute/config.php\n\n```php\n\nreturn [\n\n    /*\n     * The destination path for the javascript file.\n     */\n    'path' =\u003e 'public/js',\n\n    /*\n     * The destination filename for the javascript file.\n     */\n    'filename' =\u003e 'laroute',\n\n    /*\n     * The namespace for the helper functions. By default this will bind them to\n     * `window.laroute`.\n     */\n    'namespace' =\u003e 'laroute',\n\n    /*\n     * Generate absolute URLs\n     *\n     * Set the Application URL in config/app.php\n     */\n    'absolute' =\u003e false,\n\n    /*\n     * The Filter Methode\n     *\n     * 'all' =\u003e All routes except \"'laroute' =\u003e false\"\n     * 'only' =\u003e Only \"'laroute' =\u003e true\" routes\n     * 'force' =\u003e All routes, ignored \"laroute\" route parameter\n     */\n    'filter' =\u003e 'all',\n\n    /*\n     * Action Namespace\n     *\n     * Set here your controller namespace (see RouteServiceProvider -\u003e $namespace) for cleaner action calls\n     * e.g. 'App\\Http\\Controllers'\n     */\n    'action_namespace' =\u003e '',\n\n    /*\n     * The path to the template `laroute.js` file. This is the file that contains\n     * the ported helper Laravel url/route functions and the route data to go\n     * with them.\n     */\n    'template' =\u003e 'vendor/lord/laroute/src/templates/laroute.js',\n    \n    /*\n     * Appends a prefix to URLs. By default the prefix is an empty string.\n    *\n    */\n    'prefix' =\u003e '',\n\n];\n\n    \n```\n\n### Generate the `laroute.js`\n\nTo access the routes, we need to \"port\" them over to a JavaScript file:\n\n```\nphp artisan laroute:generate\n```\n\nWith the default configuration, this will create a `public/js/laroute.js` file to include in your page, or build.\n\n```html\n\u003cscript src=\"/js/laroute.js\"\u003e\u003c/script\u003e\n```\n\n**Note: You'll have to `laroute:generate` if you change your routes.**\n\n## JavaScript Documentation\n\nBy default, all of the functions are under the `laroute` namespace. This documentation will stick with this convention.\n\n\n### action\n\nGenerate a URL for a given controller action. \n\n```js\n/** \n * laroute.action(action, [parameters = {}])\n *\n * action     : The action to route to.\n * parameters : Optional. key:value object literal of route parameters.\n */\n\nlaroute.action('HomeController@getIndex');\n```\n\n### route\n\nGenerate a URL for a given named route.\n\n```js\n/**\n * laroute.route(name, [parameters = {}])\n *\n * name       : The name of the route to route to.\n * parameters : Optional. key:value object literal of route parameters.\n */\n \n laroute.route('Hello.{planet}', { planet : 'world' });\n```\n\n### url\n\nGenerate a fully qualified URL to the given path.\n\n```js\n/**\n * laroute.url(name, [parameters = []])\n *\n * name       : The name of the route to route to.\n * parameters : Optional. value array of route parameters.\n */\n \n laroute.url('foo/bar', ['aaa', 'bbb']); // -\u003e /foo/bar/aaa/bbb\n```\n\n### link_to\n\nGenerate a html link to the given url.\n\n```js\n/**\n * laroute.link_to(url, [title = url, attributes = {}]])\n *\n * url        : A relative url.\n * title      : Optional. The anchor text to display\n * attributes : Optional. key:value object literal of additional html attributes.\n */\n \n laroute.link_to('foo/bar', 'Foo Bar', { style : \"color:#bada55;\" });\n```\n\n### link_to_route\n\nGenerate a html link to the given route.\n\n```js\n/**\n * laroute.link_to_route(name, [title = url, parameters = {}], attributes = {}]]])\n *\n * name       : The name of the route to route to.\n * title      : Optional. The anchor text to display\n * parameters : Optional. key:value object literal of route parameters.\n * attributes : Optional. key:value object literal of additional html attributes.\n */\n \n laroute.link_to_route('home', 'Home');\n```\n\n### link_to_action\n\nGenerate a html link to the given action.\n\n```js\n/**\n * laroute.link_to_action(action, [title = url, parameters = {}], attributes = {}]]])\n *\n * action     : The action to route to.\n * title      : Optional. The anchor text to display\n * parameters : Optional. key:value object literal of route parameters.\n * attributes : Optional. key:value object literal of additional html attributes.\n */\n \n laroute.link_to_action('HelloController@planet', undefined, { planet : 'world' });\n```\n\n## PHP Documentation\n\n### Ignore/Filter Routes\n\nBy default, all routes are available to laroute after a `php artisan laroute:generate`. However, it is sometimes desirable to have laroute ignore certain routes. You can do this by passing a `laroute` route option.\n\n```php\nRoute::get('/ignore-me', [\n    'laroute' =\u003e false,\n    'as'      =\u003e 'ignoreme',\n    'uses'    =\u003e 'IgnoreController@me'\n]);\n\nRoute::group(['laroute' =\u003e false], function () {\n    Route::get('/groups-are-super-useful', 'GroupsController@index');\n});\n\n```\n\n\n## Licence\n\n[View the licence in this repo.](https://github.com/aaronlord/laroute/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmputkowski%2Flaroute","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmputkowski%2Flaroute","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmputkowski%2Flaroute/lists"}