Download the PHP package shammaa/laravel-seo without Composer

On this page you can find all versions of the php package shammaa/laravel-seo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-seo

Laravel SEO Package

Professional SEO package for Laravel with comprehensive support for OpenGraph, Twitter Cards, LinkedIn, Schema.org structured data, multilingual SEO, performance optimization, analytics integration, and much more.

Table of Contents

Features

Core SEO Features

Schema.org Structured Data (JSON-LD) - 22+ Types

Core Schemas:

New Advanced Schemas:

Advanced Features

Developer Experience

Installation

Install via Composer

That's it! The package will be installed automatically.

Publish Configuration

This creates config/seo.php where you can configure all SEO settings.

Step 4: Configure Basic Settings

Edit config/seo.php and set your site information:

Dynamic Site Data from Database (Recommended)

Instead of hardcoding site information in the config file, you can load it dynamically from your database. This is useful when:

Step 1: Register the resolver in your Service Provider:

Step 2: The resolver data automatically:

Clearing cache after settings update:

Quick Start

Basic Usage

In your controller:

In your Blade layout (resources/views/layouts/app.blade.php):

That's it! The package automatically generates all SEO tags.

Usage Guide

Page Types

Home Page

Post/Article Page

Category Page

Product Page (E-commerce)

Product Schema automatically includes:

Search Page

Tag Page

Author Page

Archive Page

Static Page

Custom Page Type

Author Handling

The package automatically detects the author from your model relationships. It checks for relationships named: writer, author, user, or creator.

If the relationship is found, it will generate a rich Person schema with the author's name, image, and URL, instead of the generic Organization schema.

Manually Setting Author (withAuthor)

If you need to manually specify the author, or override the author's URL/Image without verifying model methods, you can use withAuthor() with extra arguments:

Advanced Schema Usage

Video Schema

For pages containing a main video:

Automatic Detection: If your model has a video_url attribute or accessor, the package automatically adds the Video Schema.

FAQ Schema

For articles with frequently asked questions:

From Database (with HasSEO trait):

HowTo Schema

For tutorial and instructional articles:

Simple Steps:

Detailed Steps:

From Database (with HasSEO trait):

Review Schema

For product and service reviews:

From Database (with HasSEO trait):

Event Schema

For event announcements and coverage:

From Database (with HasSEO trait):

Breadcrumb Usage

The breadcrumb is automatically generated for post and category page types.

Method 1: Using the shared variable (Automatic)

After calling SEO::set(), breadcrumb items are automatically shared with the view:

Method 2: Using the Facade method

Method 3: Using the included view component

The breadcrumb view includes Schema.org microdata for SEO.

Chaining Multiple Schemas

You can chain multiple schema types for a single page:

New Advanced Schemas - Complete Guide

Course Schema

Perfect for educational websites, online courses, and training platforms:

Recipe Schema

Ideal for food blogs, recipe websites, and cooking platforms:

JobPosting Schema

Perfect for job boards and recruitment websites:

LocalBusiness Schema

Great for local businesses, restaurants, shops, and service providers:

SoftwareApplication Schema

Perfect for app stores, software marketplaces, and SaaS platforms:

Book Schema

Ideal for bookstores, libraries, and publishing websites:

Movie Schema

Perfect for movie databases, streaming platforms, and entertainment sites:

Podcast Schema

Great for podcast platforms and audio content websites:

Enhanced Video Schema

Improved VideoObject with additional features:

Geo-targeting

Add geographic targeting meta tags for location-based SEO:

This automatically generates:

Social Media Optimization

Pinterest Rich Pins

WhatsApp & Telegram

Both WhatsApp and Telegram use OpenGraph tags, so they work automatically. The package optimizes images for better previews.

Performance Optimization (Enhanced)

Prefetch, Prerender, and Modulepreload

Commands

Test Schema

Test your JSON-LD schemas:

This command:

Health Check

Check your SEO configuration:

This command checks:

Complete Guide

For complete examples of Controller and Model integration for all page types, see:

These guides include:

Model Integration

The package provides a professional HasSEO trait that automatically detects and extracts SEO data from your models.

Quick Setup

Step 1: Add Trait to Model

Step 2: Use in Controller

The library automatically:

Customizing Field Mappings

Each model can define its own field names:

Example: Different Model Structure

Customizing Relationship Loading

You can customize which relationships are loaded:

Overriding Methods

You can override methods for custom logic:

Model Requirements

The package automatically detects model attributes. Here's what it looks for:

Post Model

Category Model

Product Model (E-commerce)

Tag Model

Author Model

Archive (String or Object)

Page Model (Static Pages)

Advanced Features

Multilingual & Hreflang Support

Enable multilingual SEO with hreflang tags:

Custom URL Generator (via Static Method - Recommended):

⚠️ Important: Do NOT set url_generator to a closure in your config file if you plan to use php artisan config:cache. Closures cannot be serialized and will cause the cache command to fail.

Instead, register a global custom URL generator in your Service Provider:

Why use the static method?

Legacy Config Method (Not Recommended):

If you're not using config:cache, you can still use the config method (for backward compatibility):

Reading Time

Reading time is automatically calculated and displayed:

Translation Format:

Customization:

Reading time is automatically:

Using ReadingTimeCalculator directly:

AMP (Accelerated Mobile Pages) Support

⚠️ Important: Do NOT set url_generator to a closure in your config file if you plan to use php artisan config:cache. Closures cannot be serialized and will cause the cache command to fail.

Recommended approach: Register the URL generator in your Service Provider:

Config file (optional, for simple cases):

When enabled, automatically adds <link rel="amphtml"> tag for post pages.

RSS/Atom Feeds

Adds <link rel="alternate" type="application/rss+xml"> tag.

Pagination Support

To ensure perfect SEO for paginated pages (Canonical, Prev/Next, Robots), simply pass your Paginator instance to the library using withPagination():

The package provides comprehensive pagination SEO support:

Canonical URL Behavior

Page URL Canonical
First page /articles /articles
Page 2 /articles?page=2 /articles?page=2 (Self-referencing)
Page 2 (config to first) /articles?page=2 /articles

Robots Directive

Setting Page 1 Page 2+
noindex_pagination: false index, follow index, follow
noindex_pagination: true index, follow noindex, follow

Recommendation: Use canonical_to_first: false (default) to ensure paginated content is indexed. Only enable canonical_to_first: true if you have identical content across pages (which is rare for archives).

Prev/Next Links

Automatically adds <link rel="prev"> and <link rel="next"> tags if your model has previous and next relationships:

Model Example:

Performance Optimization

Improve page load speed with resource hints:

Mobile Optimization

Security Headers

Analytics Integration

Support for multiple analytics platforms:

All analytics scripts are automatically injected when configured.

Image Rendering Configuration

Configure image loading behavior:

Dynamic Site Configuration (Database)

For projects that store site settings in a database, use the Dynamic Site Resolver to fetch settings automatically.

Step 1: Add the Interface to Your Model (Optional but Recommended)

Step 2: Register in AppServiceProvider

That's it! Now your SEO settings come from the database.

Benefits:

Configuration Reference

Site Information

Image Route

If you're using an image processing package (like laravel-smart-glide):

Social Media

Organization Schema

Fallback Texts

Customize default texts:

Environment Variables

You can configure SEO via environment variables:

Basic Settings

Social Media

Multilingual

Reading Time

AMP

RSS

Performance

Mobile

Security

Analytics

Organization

API Reference

Facade Methods

SEO::for(string $pageType, $model = null)

Set page type and model.

SEO::home()

Set page type to home.

SEO::post($model)

Set page type to post with model.

SEO::category($model)

Set page type to category with model.

SEO::search(array $params)

Set page type to search with query parameters.

SEO::set()

Generate and set all SEO tags. Must be called after setting page type.

SEO::render()

Render all SEO tags as HTML string. Automatically calls set() if not called.

SEO::breadcrumb()

Get breadcrumb items as array.

SEO::addFAQ(array $faqs)

Add FAQ schema. Returns self for chaining.

Parameters:

SEO::addHowTo(string $name, array $steps, ?string $description = null, ?string $image = null)

Add HowTo schema. Returns self for chaining.

Parameters:

SEO::addReview(string $itemName, float $ratingValue, float $bestRating = 5.0, ?string $reviewBody = null, ?string $authorName = null, ?string $datePublished = null)

Add Review schema. Returns self for chaining.

Parameters:

SEO::addEvent(string $name, string $startDate, ?string $endDate = null, ?string $description = null, ?string $locationName = null, ?string $locationAddress = null, ?string $image = null, ?string $organizerName = null, ?string $organizerUrl = null)

Add Event schema. Returns self for chaining.

Parameters:

SEO::product($model)

Set page type to product with model.

SEO::addProduct($model)

Add Product schema. Returns self for chaining. Automatically called when using SEO::product()->set().

Parameters:

SEO::addAggregateRating(float $ratingValue, int $ratingCount, float $bestRating = 5.0, float $worstRating = 1.0)

Add AggregateRating schema. Returns self for chaining.

Parameters:

SEO::addBrand(string $name, ?string $logo = null, ?string $url = null)

Add Brand schema. Returns self for chaining.

Parameters:

HasSEO Trait Methods

getSEOFieldMap(): array

Define field mappings for your model. Override in your model.

getSEORelationships(): array

Define relationship names for your model. Override in your model.

getSEORelationshipsToLoad(): array

Define which relationships to eager load. Override in your model.

getSEOTitle(): ?string

Get SEO title from model.

getSEODescription(): ?string

Get SEO description from model.

getSEOImage(): ?string

Get SEO image from model.

getSEOKeywords(): array

Get SEO keywords from model (from tags and categories).

getSEOAuthor(): ?string

Get SEO author name from model.

getSEOPublishedAt(): ?string

Get published date in ISO 8601 format.

getSEOModifiedAt(): ?string

Get modified date in ISO 8601 format.

getSEOFAQs(): array

Get FAQs for FAQ schema. Override for custom logic.

getSEOHowToSteps(): array

Get HowTo steps. Override for custom logic.

getSEOReview(): ?array

Get Review data. Override for custom logic.

getSEOEvent(): ?array

Get Event data. Override for custom logic.

hasSEOFAQs(): bool

Check if model has FAQs.

hasSEOHowToSteps(): bool

Check if model has HowTo steps.

hasSEOReview(): bool

Check if model has Review data.

hasSEOEvent(): bool

Check if model has Event data.

Examples

Complete Example: Post with All Features

Example: Using HasSEO Trait

Example: Extracting Data from Database

Differences: Blog vs E-commerce

Blog/Article Website

Focus: Content, articles, news Schemas: NewsArticle, WebPage, BreadcrumbList Key Features:

Example:

E-commerce Website

Focus: Products, sales, shopping Schemas: Product, Offer, AggregateRating, Brand Key Features:

Example:

Hybrid Website (Both)

You can use both on the same website:

Troubleshooting

Tags Not Appearing

  1. Check if set() is called:

  2. Check if render() is called in view:

  3. Check config file:

Model Data Not Detected

  1. Check field mappings:

  2. Check relationships:

Breadcrumb Not Showing

  1. Check if breadcrumb is shared:

  2. Check model relationships:
    • Post should have categories relationship
    • Category should have parent relationship and route() method

Reading Time Not Showing

  1. Check if enabled:

  2. Check if model has content:

Schemas Not Auto-Detected

  1. Check if HasSEO trait is used:

  2. Check relationships:

  3. Check if relationships are loaded:

Config Cache Error (LogicException)

Error:

Cause: This error occurs when you try to run php artisan config:cache after setting url_generator to a closure/function in your config file. Closures cannot be serialized.

Solution: Use the static method MultilingualBuilder::urlGeneratorUsing() instead of setting a closure in the config file:

If you already cached config:

Best Practices

1. Use HasSEO Trait

Always use the HasSEO trait for automatic data extraction:

2. Define Field Mappings

Always define field mappings in your models:

3. Use Eager Loading

The library automatically eager loads relationships, but you can optimize:

4. Cache Site Data

Site data is cached by default (24 hours). Adjust if needed:

5. Use Environment Variables

Store sensitive data in .env:

6. Test Your Schemas

Use Google's Rich Results Test:

7. Validate JSON-LD

Use JSON-LD Playground:

8. Monitor Performance

Use performance optimization features:

How It Works

Automatic Detection

The package automatically detects model attributes:

  1. Title: Checks title, name attributes
  2. Description: Checks content, text, description attributes
  3. Image: Checks photo, image, thumbnail attributes
  4. Dates: Checks created_at, published_at, updated_at, modified_at
  5. Author: Checks writer relationship or uses site name
  6. Categories: Checks categories relationship for breadcrumbs
  7. Tags: Checks tags relationship for article:tag meta tags
  8. Video: Checks video_url for VideoObject schema

Schema Generation Flow

  1. Page Type Detection: Determines page type (home, post, category, search)
  2. Data Extraction: Extracts data from model or config
  3. Meta Tags: Generates standard meta tags
  4. OpenGraph: Generates Facebook OpenGraph tags
  5. Twitter Cards: Generates Twitter Card tags with reading time
  6. Schemas: Generates appropriate JSON-LD schemas
  7. Additional Features: Adds multilingual, performance, analytics tags

Caching

Site data is cached for 24 hours by default (configurable via SEO_CACHE_TTL). This improves performance by avoiding repeated database queries.

View Sharing

The package automatically shares data with views:

Requirements

License

MIT

Author

Shadi Shammaa


Support

For issues, questions, or contributions, please visit the GitHub repository.


All versions of laravel-seo with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/support Version ^9.0|^10.0|^11.0|^12.0
illuminate/http Version ^9.0|^10.0|^11.0|^12.0
illuminate/view Version ^9.0|^10.0|^11.0|^12.0
illuminate/cache Version ^9.0|^10.0|^11.0|^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package shammaa/laravel-seo contains the following files

Loading the files please wait ...