krystal-sf/ux-metadata

Page Metadata Management for Krystal Symfony Projects

Maintainers

Package info

gitlab.com/krystal-sf/ux-metadata

Homepage

Issues

Type:symfony-bundle

pkg:composer/krystal-sf/ux-metadata

Transparency log

Statistics

Installs: 1 857

Dependents: 2

Suggesters: 0

Stars: 0

1.0.x-dev 2026-08-05 09:30 UTC

This package is auto-updated.

Last update: 2026-08-05 09:30:11 UTC


README

Page metadata management for Krystal Symfony Projects: page title, meta tags, canonical & lang alternates — SEO ready.

PHP Version Symfony

Installation

composer require krystal-sf/ux-metadata

This bundle is a Krystal Plugin (krystal-sf/plugin-manager) — the recommended way to enable it is through the Plugin Manager:

bin/console plugin:discover
bin/console plugin:enable ksf_metadata

Alternatively, register it as a regular bundle in config/bundles.php:

return [
    // ...
    Ksf\Plugins\PageMetadata\KsfMetadataBundle::class => ['all' => true],
];

Usage

Import the trait in your controller, then autoload metadata from translations:

class Index extends AbstractController
{
    use PageMetadataAwareTrait;

    public function __invoke(): Response
    {
        $this->autoloadPageMeta("page-metadata.index", "MyDomain");
        // or configure manually:
        $this->getPageMetadataOrDie()
            ->setTitle("My Page")
            ->addTitleSuffix("| My App")
            ->addMeta("name", "description", "My page description")
            ->setLinkCanonical("https://my.app/page")
            ->addLangAlternate("https://my.app/fr/page", "fr")
        ;
    }
}

Rendering

Two Twig Components are registered as Tagged Blocks on the HEADER location (krystal-sf/ux-blocks) — rendered automatically when your layout includes the header block:

  • Ksf:Metadata:Title — the <title> tag
  • Ksf:Metadata:Page<meta> tags, canonical link & lang alternates

Head & html attributes (getHeadAttributes(), getHtmlAttributes()) are exposed by the PageMetadata service for manual use in custom layouts.

Testing

make up          # boot the docker stack
make phpunit     # run the test suite
make quality     # lint + style + phpstan

License

MIT — see LICENSE.