-
-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Welcome to the comprehensive documentation for the PHP-SEO package - a powerful, framework-agnostic SEO optimization library for modern PHP applications.
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.
- β 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
Install the package via Composer:
composer require rumenx/php-seo- PHP 8.2 or higher
- Composer for dependency management
- Optional: Laravel 10+ or Symfony 6+ for framework integration
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;This documentation is organized into the following sections:
- Configuration - Complete configuration reference and options
- AI Integration - Setting up and using AI providers
- Content Analysis - Understanding content analysis features
- Laravel Examples - Complete Laravel setup and usage
- Symfony Examples - Complete Symfony bundle integration
- Plain PHP Examples - Using the package without frameworks
- Meta Tags Reference - Complete meta tags documentation
- Structured Data - Schema.org integration and examples
- Performance Optimization - Caching and performance tips
- Testing - Testing your SEO implementation
- Troubleshooting - Common issues and solutions
- Basic Examples - Simple usage examples
- Advanced Examples - Complex implementation scenarios
- Best Practices - SEO and implementation best practices
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
The main class that orchestrates all SEO operations. It coordinates content analysis, generation, and rendering.
Comprehensive configuration system supporting environment variables, nested settings, and framework-specific options.
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.)
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
Pluggable AI integrations:
- OpenAI (GPT models)
- Anthropic (Claude models)
- Google (Gemini models)
- Ollama (Local models)
- Production-tested architecture
- Comprehensive error handling
- Built-in caching and performance optimization
- Extensive test coverage (100% goal)
- 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
- Framework-agnostic core
- Native Laravel and Symfony support
- Pluggable AI providers
- Configurable fallback strategies
- Multiple AI provider support
- Automatic fallback to manual generation
- Cost-effective AI usage with caching
- Rate limiting and error handling
We welcome contributions! Please see our Contributing Guide for details on:
- Code standards and guidelines
- Testing requirements
- Pull request process
- Issue reporting
This package is open-sourced software licensed under the MIT License.
- Documentation: Complete guides and examples in this wiki
- Issues: Report bugs and feature requests on GitHub Issues
- Discussions: Join community discussions on GitHub Discussions
Ready to get started? Here are some suggested next steps:
- Configuration - Set up your configuration
- Laravel Examples - Integrate with your framework
- AI Integration - Configure AI providers
- Basic Examples - Try some examples
Happy optimizing! π―