-
-
Notifications
You must be signed in to change notification settings - Fork 239
Open
Description
Add a new method like express.use() to pass down frequently used variables like database or other class instances, because when working with many routes, writing many variables with the use statement becomes a bit too much.
Example:
$database = new Database();
$router->use($database);
$router->get('/user/{id}', function ($id) {
$user = $database->query("SELECT * FROM users WHERE id = ?", [$id]);
if ($user) {
echo json_encode($user);
} else {
echo "User not found";
}
});
Metadata
Metadata
Assignees
Labels
No labels