lemonade/component_meta

A lightweight PHP library for generating SEO & social meta tags (HTML <meta>, OpenGraph, Twitter Cards, DC tags, …).

v2.1.1 2025-09-13 13:16 UTC

This package is auto-updated.

Last update: 2025-09-13 13:18:41 UTC


README

Packagist License PHP Version Tests

Lightweight OOP component for generating SEO & social meta tags (HTML <meta>, OpenGraph, Twitter Cards, DC tags, …) in Lemonade Framework projects.

✨ Features

  • Strongly typed MetaData object
  • Unified MetaEntityInterface for all meta entities
  • Minimalistic tag classes (MetaTag, OpenGraphTag, TwitterTag, DcTag, LinkTag, TitleTag)
  • Extensible: add your own meta entities or custom tags
  • Safe HTML escaping and readonly properties
  • Implements Stringable → render directly in templates

🚀 Installation

  composer require lemonade/component_meta

🔧 Usage

use Lemonade\Meta\MetaData;
use Lemonade\Meta\MetaFactory;

// 1. Prepare meta data
// Create a data object that contains all information for SEO and social networks.
$data = new MetaData(
    websiteName: "Lemonade Framework",
    title: "Knihovna pro meta tagy",
    description: "Elegantní a efektivní PHP knihovna pro generování HTML meta tagů. Ideální pro webové stránky a CMS.",
    keywords: "php, framework, seo, meta, tagy, web, vývoj, knihovna",
    author: "Honza Mudrák",
    robots: "index,follow",
    canonical: "https://lemonadeframework.cz/",
    image: "https://cdn.lemonadeframework.cz/framework/small/color.png",
    custom: [
        "google-site-verification" => "J-QyBfS-jXv18vF-k4B2SgM_mD3E0E2Y9VzV8F",
        "robots" => "index,follow",
        "seznam-wmt" => "1234567890abcdef",
        "og:type" => "website",
        "og:locale" => "cs_CZ",
        "fb:app_id" => "1234567890",
        "twitter:site" => "@lemonade_cz"
    ]
);

// 2. Create a factory instance for generating tags
// Pass in the prepared data.
$metaFactory = new MetaFactory($data);

// 3. Generate and output HTML code
// MetaFactory implements Stringable, so you can echo it directly
echo $metaFactory;

📖 Changelog

All notable changes are documented in the CHANGELOG.md.

🧪 Development & Testing

This package is fully covered by PHPUnit tests and verified with PHPStan Level 10.

Run PHPUnit tests:

composer install
vendor/bin/phpunit
vendor/bin/phpunit -c vendor/lemonade/component_meta/phpunit.xml --bootstrap vendor/autoload.php

Run static analysis:

  composer phpstan

📜 License

Released under the MIT License.
Copyright © 2025 Jan Mudrák