Download the PHP package uiibevy/flutzig without Composer
On this page you can find all versions of the php package uiibevy/flutzig. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package flutzig
Flutzig – Use your Laravel routes in Flutter
flutzig provides a JavaScript route()
function that works like Laravel's, making it a breeze to use your named Laravel routes in JavaScript.
- Installation
- Usage
route()
functionRouter
class- Route-model binding
- Filtering Routes
- Including/excluding routes
- Filtering with groups
- Contributing
Installation
Install Flutzig in your Laravel app with Composer:
Install Flutzig in your flutter app with pub:
Add the Flutzig initialisation in your Flutter app
Usage
route()
function
flutzig's route()
function works like Laravel's route()
helper—you can pass it the name of a route, and the parameters you want to pass to the route, and it will generate a URL.
Basic usage
Parameters
Multiple parameters
Query parameters
flutzig adds arguments that don't match any named route parameters as query parameters:
If you need to pass a query parameter with the same name as a route parameter, nest it under the special query_
key:
Like Laravel, Flutzig automatically encodes boolean query parameters as integers in the query string:
Default parameter values
flutzig supports default route parameter values (Laravel docs).
Examples
HTTP request with dio
:
Router
class
Calling flutzig's route()
function with no arguments will return an instance of its JavaScript Router
class, which has some other useful properties and methods.
Check the current route: route().current()
COMING SOON !
Check if a route exists: route().has()
COMING SOON !
Route-model binding
Flutzig supports Laravel's route-model binding, and can even recognize custom route key names. If you pass route()
a Dart object as a route parameter, Flutzig will use the registered route-model binding keys for that route to find the correct parameter value inside the object. If no route-model binding keys are explicitly registered for a parameter, Flutzig will use the object's id
key.
flutzig also supports custom keys for scoped bindings declared directly in a route definition:
Generating and importing flutzig's configuration
Flutzig provides an Artisan command to output its config and routes to a file:
This command places your configuration in storage/public/flutzig/routes.json
by default, but you can customize this path by passing an argument to the Artisan command or setting the flutzig.output.path
config value.
The file flutzig:generate
creates looks something like this:
Filtering Routes
Flutzig supports filtering the list of routes it outputs, which is useful if you have certain routes that you don't want to be included and visible in your json export.
[!IMPORTANT] Hiding routes from flutzig's output is not a replacement for thorough authentication and authorization. Routes that should not be accessibly publicly should be protected by authentication whether they're filtered out of flutzig's output or not.
Including/excluding routes
To set up route filtering, create a config file in your Laravel app at config/flutzig.php
and add either an only
or except
key containing an array of route name patterns.
Note: You have to choose one or the other. Setting both
only
andexcept
will disable filtering altogether and return all named routes.
You can use asterisks as wildcards in route filters. In the example below, admin.*
will exclude routes named admin.login
, admin.register
, etc.:
Filtering with groups
You can also define groups of routes that you want make available in different places in your app, using a groups
key in your config file:
Contributing
To get started contributing to Flutzig, check out the contribution guide.
Credits
License
Flutzig is open-source software released under the MIT license. See LICENSE for more information.