kendocms / router
Router module for KendoCMS.
Fund package maintenance!
Open Collective
leafsphp
Requires
- leafs/anchor: *
- leafs/http: *
Requires (Dev)
- pestphp/pest: ^1.21
This package is auto-updated.
Last update: 2025-02-16 04:13:18 UTC
README
Fork of Leaf Router
Leaf router is the core routing engine which powers the Leaf PHP framework. Leaf router is now served as a serve-yourself module which can even be used outside the Leaf ecosystem.
Leaf Router is still built into Leaf Core and doesn't need to be installed separately.
Installation
You can easily install Leaf using Composer.
composer require leafs/router
Basic Usage
If you are using leaf router with Leaf, you can build your leaf apps just as you've always done:
<?php require __DIR__ . "vendor/autoload.php"; // GET example app()->get("/", function () { response()->json([ "message" => "Welcome!" ]); }); // MATCH example app()->match("GET", "/test", function () { response()->json([ "message" => "Test!" ]); }); app()->run();
If however, you are using leaf router outside of the leaf framework, you simply need to call these methods on the Leaf\Router
object:
<?php use Leaf\Router; require __DIR__ . "vendor/autoload.php"; // GET example Router::get("/", function () { echo json_encode([ "message" => "Welcome!" ]); }); // MATCH example Router::match("GET", "/test", function () { echo json_encode([ "message" => "Test!" ]); }); Router::run();