Skip to content
Rumen Damyanov edited this page Sep 22, 2025 · 3 revisions

PHP-SEO Package Documentation

Welcome to the comprehensive documentation for the PHP-SEO package - a powerful, framework-agnostic SEO optimization library for modern PHP applications.

🎯 Overview

The PHP-SEO package provides automated SEO optimization capabilities with AI-powered content analysis and generation. It supports manual configuration, AI integration, and comes with native support for Laravel and Symfony frameworks.

Key Features

  • βœ… Framework Agnostic: Works with any PHP 8.2+ application
  • βœ… AI-Powered: Multiple AI provider support (OpenAI, Anthropic, Google, Ollama)
  • βœ… Manual Fallback: Pattern-based generation when AI is unavailable
  • βœ… Laravel Integration: Native service provider, facade, and middleware
  • βœ… Symfony Integration: Complete bundle with Twig extensions and event listeners
  • βœ… Content Analysis: Automatic extraction of headings, images, links, and keywords
  • βœ… Meta Tag Generation: Complete Open Graph, Twitter Cards, and standard meta tags
  • βœ… Structured Data: Schema.org markup support
  • βœ… Caching: Built-in caching for improved performance
  • βœ… Testing: Comprehensive test coverage with Pest framework

πŸ“¦ Installation

Install the package via Composer:

composer require rumenx/php-seo

Requirements

  • PHP 8.2 or higher
  • Composer for dependency management
  • Optional: Laravel 10+ or Symfony 6+ for framework integration

πŸš€ Quick Start

Here's a simple example to get you started:

use Rumenx\PhpSeo\SeoManager;
use Rumenx\PhpSeo\Config\SeoConfig;

// Create configuration
$config = new SeoConfig([
    'ai' => ['enabled' => false], // Start with manual mode
    'title' => ['max_length' => 60],
    'description' => ['max_length' => 160],
]);

// Initialize SEO manager
$seoManager = new SeoManager($config);

// Analyze your content
$htmlContent = '<h1>My Page</h1><p>Page content...</p>';
$analysis = $seoManager->analyze($htmlContent, [
    'title' => 'My Page Title',
    'url' => 'https://example.com/my-page',
]);

// Generate SEO elements
$title = $seoManager->generateTitle($analysis);
$description = $seoManager->generateDescription($analysis);
$metaTags = $seoManager->generateMetaTags($analysis);

// Render HTML meta tags
$htmlOutput = $seoManager->renderMetaTags($metaTags);
echo $htmlOutput;

πŸ“š Documentation Structure

This documentation is organized into the following sections:

Core Documentation

Framework Integration

Advanced Topics

Examples and Tutorials

🎨 Package Architecture

The PHP-SEO package follows a modular architecture:

php-seo/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ SeoManager.php           # Main orchestration class
β”‚   β”œβ”€β”€ Config/
β”‚   β”‚   └── SeoConfig.php        # Configuration management
β”‚   β”œβ”€β”€ Analyzers/
β”‚   β”‚   └── ContentAnalyzer.php  # Content analysis
β”‚   β”œβ”€β”€ Generators/
β”‚   β”‚   β”œβ”€β”€ TitleGenerator.php   # Title generation
β”‚   β”‚   β”œβ”€β”€ DescriptionGenerator.php # Description generation
β”‚   β”‚   └── MetaTagGenerator.php # Meta tag generation
β”‚   β”œβ”€β”€ Providers/
β”‚   β”‚   └── OpenAiProvider.php   # AI provider implementations
β”‚   β”œβ”€β”€ Contracts/               # Interfaces
β”‚   └── Integrations/            # Framework integrations
β”‚       β”œβ”€β”€ Laravel/
β”‚       └── Symfony/
β”œβ”€β”€ config/
β”‚   └── seo.php                  # Default configuration
β”œβ”€β”€ examples/                    # Code examples
└── tests/                       # Test suite

πŸ”§ Core Components

SeoManager

The main class that orchestrates all SEO operations. It coordinates content analysis, generation, and rendering.

SeoConfig

Comprehensive configuration system supporting environment variables, nested settings, and framework-specific options.

ContentAnalyzer

Analyzes HTML content to extract:

  • Headings (H1-H6)
  • Images with alt text and metadata
  • Internal and external links
  • Keywords and key phrases
  • Content metrics (word count, language, etc.)

Generators

Specialized classes for generating:

  • TitleGenerator: SEO-optimized page titles with templates
  • DescriptionGenerator: Meta descriptions from content analysis
  • MetaTagGenerator: Complete meta tag sets including Open Graph and Twitter Cards

AI Providers

Pluggable AI integrations:

  • OpenAI (GPT models)
  • Anthropic (Claude models)
  • Google (Gemini models)
  • Ollama (Local models)

🌟 Why Choose PHP-SEO?

Enterprise-Ready

  • Production-tested architecture
  • Comprehensive error handling
  • Built-in caching and performance optimization
  • Extensive test coverage (100% goal)

Developer-Friendly

  • Modern PHP 8.2+ with strict typing
  • PSR-4 autoloading and PSR-12 coding standards
  • Comprehensive documentation and examples
  • IDE-friendly with full type hints

Flexible Integration

  • Framework-agnostic core
  • Native Laravel and Symfony support
  • Pluggable AI providers
  • Configurable fallback strategies

AI-Powered with Fallbacks

  • Multiple AI provider support
  • Automatic fallback to manual generation
  • Cost-effective AI usage with caching
  • Rate limiting and error handling

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details on:

  • Code standards and guidelines
  • Testing requirements
  • Pull request process
  • Issue reporting

πŸ“„ License

This package is open-sourced software licensed under the MIT License.

πŸ†˜ Support

  • Documentation: Complete guides and examples in this wiki
  • Issues: Report bugs and feature requests on GitHub Issues
  • Discussions: Join community discussions on GitHub Discussions

πŸš€ Next Steps

Ready to get started? Here are some suggested next steps:

  1. Configuration - Set up your configuration
  2. Laravel Examples - Integrate with your framework
  3. AI Integration - Configure AI providers
  4. Basic Examples - Try some examples

Happy optimizing! 🎯

Clone this wiki locally