Skip to content

Commit d8e274a

Browse files
committed
chore: cleanup + add changelog
1 parent b3aa6f0 commit d8e274a

3 files changed

Lines changed: 39 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Changelog
2+
3+
All notable changes to the Leaf core are documented here.
4+
5+
## v5.0 (unreleased)
6+
7+
### Added
8+
9+
- Compiled routing engine: routes are compiled to indexed patterns at registration; exact matches resolve from a dictionary without touching regex
10+
- Optional route parameters — `/posts/{id?}` matches both `/posts` and `/posts/5`
11+
- Inline route constraints — `/users/{id:[0-9]+}`, including quantifiers like `{year:[0-9]{4}}`
12+
- `Leaf\Router::reset()` for tests, workers, and long-running processes
13+
- Per-request memoization of the request method and URI
14+
15+
### Changed
16+
17+
- **Route matching is specificity-first**: exact routes always win over dynamic routes regardless of registration order; dynamic routes win over catch-alls. Registration order only breaks ties within a tier
18+
- Debug behavior derives from the app environment: `APP_ENV=production` disables detailed error pages by default
19+
- Sessions are off by default; `session.cookie.secure` is auto-detected from HTTPS
20+
- `_env()` parses the environment once per request and caches it (use `getenv()` for values set at runtime)
21+
- The error handler registers once per process and is shared across `App` instances — `config()` no longer re-registers it, and custom handlers set with `setErrorHandler()` survive later `config()` calls
22+
23+
### Fixed
24+
25+
- Router hooks that replace routes at runtime (the lingo/sitemap contract) are re-indexed so their changes actually apply
26+
- Calling an undefined method on `Leaf\App` throws `BadMethodCallException` instead of silently returning `null`
27+
- `Router::run()` no longer pops error handlers it didn't register
28+
29+
### Removed
30+
31+
- **Raw regex route patterns**`/posts(/edit)?` style routes no longer match; use named parameters, optional parameters, and constraints instead
32+
- Built-in Eien/Swoole integration (`$app->ws()`) — long-running server setups now live outside the core
33+
34+
See the [upgrade guide](https://leafphp.dev/docs/upgrade-guide) for migration steps.

alchemy.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ app:
33

44
tests:
55
engine: pest
6-
parallel: true
6+
# parallel workers crash on this suite: the middleware tests echo directly to stdout
7+
parallel: false
78
paths:
89
- tests
910
files:

src/Router.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
* @author Michael Darko
1313
* @since 1.2.0
14-
* @version 3.0
14+
* @version 5.0
1515
*/
1616
class Router
1717
{
@@ -158,7 +158,7 @@ public static function mount(string $path, $handler)
158158

159159
$initialNamespace = static::$namespace;
160160
$initialGroupRoute = static::$groupRoute;
161-
$initialLingoOptioins = static::$lingoOptions;
161+
$initialLingoOptions = static::$lingoOptions;
162162
$initialSitemapOptions = static::$sitemapOptions;
163163
$initialGroupMiddleware = static::$routeGroupMiddleware;
164164

@@ -184,7 +184,7 @@ public static function mount(string $path, $handler)
184184

185185
static::$namespace = $initialNamespace;
186186
static::$groupRoute = $initialGroupRoute;
187-
static::$lingoOptions = $initialLingoOptioins;
187+
static::$lingoOptions = $initialLingoOptions;
188188
static::$sitemapOptions = $initialSitemapOptions;
189189
static::$routeGroupMiddleware = $initialGroupMiddleware;
190190
}
@@ -665,8 +665,6 @@ protected static function mapHandler(
665665
}
666666
}
667667
}
668-
669-
// $parsedOptions = array_merge($handler, $parsedOptions);
670668
}
671669

672670
return [$parsedHandler, $parsedOptions];
@@ -746,10 +744,6 @@ private static function reindexRoutes(): void
746744
*/
747745
public static function use($middleware)
748746
{
749-
// if (in_array($middleware, static::$middleware)) {
750-
// throw new \RuntimeException('Circular Middleware setup detected. Tried to queue the same Middleware twice.');
751-
// }
752-
753747
if (is_string($middleware)) {
754748
$middleware = class_exists($middleware) ? function () use ($middleware) {
755749
(new $middleware())->call();

0 commit comments

Comments
 (0)