← ClaudeAtlas

nette-routinglisted

Invoke before writing or modifying a router, a RouterFactory or any URL mask in Nette. Use for RouteList, addRoute(), route masks (optional `[...]` parts, `<param regex>` constraints, defaults in the mask), withModule()/withDomain()/withPath(), pretty URLs and slugs, one-way routes for retired URLs, Route::FilterIn/FilterOut/FilterTable/FilterStrict, general filters under the `''` key, fixed parameters, SimpleRouter, the `routing:` NEON section, and canonical-URL redirects (canonicalize(), $autoCanonicalize). Also trigger for "wrong URL is generated", "link points to the wrong route", dots in URLs of a modular app, unexpected 301 redirect loops, or the Tracy routing panel. Not for `n:href`/`{link}` syntax (latte-templates) nor signal links (nette-components).
nette/agent-plugins · ★ 44 · AI & Automation · score 81
Install: claude install-skill nette/agent-plugins
## Nette Routing A route is **bidirectional**: the same object matches an incoming URL and generates links, and almost every routing bug comes from forgetting the second direction. Related skills: **nette-architecture** (`RouterFactory`, lifecycle), **nette-configuration** (registering it), **nette-components** (signal links), **latte-templates** (`n:href`/`{link}`). Verified against nette/application 3.3.0 and nette/routing 3.1.3. ### Order governs link GENERATION, not just matching `RouteList::constructUrl()` walks the routes in declaration order and returns the URL from **the first route that can build one** – so a catch-all placed first silently hijacks every link, with no error: ```php $router->addRoute('admin/<presenter>/<action>', 'Admin:Default:default'); // WRONG order: $router->addRoute('rss.xml', 'Feed:rss'); // link to Feed:rss generates '/admin/feed/rss' ``` Specific first, catch-all last. The **canonical URL of a page is whatever the first non-one-way matching route generates**, so the order also decides where canonicalization redirects. ### Mask grammar ```php $router->addRoute('chronicle/<year=2020>', 'History:show'); // default inside the mask $router->addRoute('<presenter>/<action>[/<id \d+>]', 'Home:default'); // optional part + regex $router->addRoute('<path .+>', 'File:serve'); // default pattern is [^/]+; only .+ eats slashes $router->addRoute('//<lang>.example.com/<presenter>', /* ... */); // host part needs the // prefix ``