Skip to content

nowo-tech/RoutingKitBundle

Repository files navigation

Routing Kit Bundle

CI Packagist Version Packagist Downloads License PHP Symfony GitHub stars Coverage

Found this useful? Install from Packagist · Give it a star on GitHub so more developers can find it.

Routing Kit Bundle — DB-driven (pluggable storage) locale paths for Symfony: dual /foo + /{locale}/foo access, admin-defined canonical URLs, Twig CRUD panel, route-cache invalidation, and SeoKitBundle path bridge. Tested on Symfony 7.4, 8.0, and 8.1 · PHP 8.2+ (Symfony 8.x requires PHP 8.4+).

FrankenPHP Friendly Worker Mode

This bundle is FrankenPHP worker mode friendly.

Features

  • Storage — One row per (routeName, locale); filesystem JSON by default; swap via RoutePathStorageInterface.
  • Locales — YAML default_locale + locales, or a custom LocaleProviderInterface.
  • Canonical definition — Paths stored without {_locale}; the loader always builds /{_locale}/….
  • Stylescanonical_style, trailing slash, alias mode (redirect / alias).
  • Fallback — Missing locale row → default-locale path for that route name.
  • #[Routable] — Controllers offered in the CRUD; params + constraints validated on save.
  • Loadertype: nowo_routing_kit registers {name}.{locale} with _canonical_route (import last).
  • Panel — Twig CRUD under /_routing + clear routing cache (auto after save/delete).
  • SeoKit — Optional bridge decorates SeoPathBuilderInterface for canonical/hreflang paths.

Installation

composer require nowo-tech/routing-kit-bundle

With Symfony Flex, the recipe registers the bundle and adds config (see .symfony/recipe). Without Flex, see docs/INSTALLATION.md.

# config/routes.yaml — panel, then app routes, then DB loader LAST
nowo_routing_kit_panel:
    resource: '@NowoRoutingKitBundle/Resources/config/routes.yaml'

# … application routes …

nowo_routing_kit_db:
    resource: .
    type: nowo_routing_kit

The loader registers {name}.{locale} with _canonical_route. Protect /_routing with your firewall.

Configuration

nowo_routing_kit:
    default_locale: en
    locales: [en, es]
    panel:
        path_prefix: /_routing
    redirects:
        canonical_enabled: true
    seo_kit_bridge: true

Usage

use Nowo\RoutingKitBundle\Attribute\Routable;
use Nowo\RoutingKitBundle\Attribute\RouteParam;

#[Routable(name: 'app_about')]
public function about(): Response { … }

#[Routable(name: 'app_blog_show', params: [
    new RouteParam('slug', required: true, requirement: '[a-z0-9-]+'),
])]
public function show(string $slug): Response { … }

Open /_routing to manage paths. See docs/USAGE.md.

Documentation

Additional documentation

Requirements

  • PHP >=8.2 (<8.6); Symfony 8.0 and 8.1 require PHP 8.4+
  • Symfony 7.4, 8.0, or 8.1
  • Twig for the CRUD panel templates

Development

make up
make install
make test
make cs-check
make phpstan
make release-check

Install git hooks once per clone: make setup-hooks (REQ-GIT-001).

Demos

make -C demo up-symfony8

Open http://localhost:8058 — panel at /_routing. FrankenPHP mode is controlled by FRANKENPHP_MODE (classic | worker, default worker) in the demo .env.

Tests and coverage

PHPUnit with 100% line coverage of production PHP under src/ (optional SeoKit bridge files excluded when SeoKit is not a require-dev dependency):

make test-coverage
make coverage-check

License

MIT

About

DB-driven (pluggable storage) locale paths for Symfony: dual /foo + /{locale}/foo access, admin-defined canonical URLs, Twig CRUD panel, route-cache invalidation, and SeoKitBundle path bridge. Tested on Symfony 7.4, 8.0, and 8.1 · PHP 8.2+ (Symfony 8.x requires PHP 8.4+).

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages