PHPackages                             raiolanetworks/plugin-seo-test - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. raiolanetworks/plugin-seo-test

ActiveLibrary[Testing &amp; Quality](/categories/testing)

raiolanetworks/plugin-seo-test
==============================

This Composer package provides a seamless integration for testing SEO aspects of your Laravel applications. Compatible with both Pest and PHPUnit, it offers a collection of tools and assertions specifically designed to evaluate on-page SEO elements like meta tags, title tags, canonical URLs, and structured data. By automating SEO testing, this plugin ensures that your application consistently adheres to best SEO practices, helping you catch potential SEO issues early in the development cycle.

2.1.0(1mo ago)21.6k↓62.9%MITPHPPHP ^8.2CI passing

Since Sep 18Pushed 1mo agoCompare

[ Source](https://github.com/RaiolaNetworks/plugin-seo-test)[ Packagist](https://packagist.org/packages/raiolanetworks/plugin-seo-test)[ Docs](https://github.com/RaiolaNetworks/plugin-seo-test)[ RSS](/packages/raiolanetworks-plugin-seo-test/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (4)Dependencies (12)Versions (9)Used By (0)

Plugin SEO Test
===============

[](#plugin-seo-test)

[![Latest Version on Packagist](https://camo.githubusercontent.com/edd28d20d6f514d5594994a2327291a3bd11a6f0feab64f1a32074a720dfa3ff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7261696f6c616e6574776f726b732f706c7567696e2d73656f2d746573742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/raiolanetworks/plugin-seo-test)[![GitHub Tests Action Status](https://camo.githubusercontent.com/4466a759cea162ba57e68bae2ae04eba8aefaffe66c012e0dc280a125a652cb4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7261696f6c616e6574776f726b732f706c7567696e2d73656f2d746573742f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/raiolanetworks/plugin-seo-test/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/49f03e85b81b86b06126c3ba8e035149f35cf072aae3ae510589bf74279090bb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7261696f6c616e6574776f726b732f706c7567696e2d73656f2d746573742f70696e742e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652d7374796c65267374796c653d666c61742d737175617265)](https://github.com/raiolanetworks/plugin-seo-test/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/c9d8b6d84730d3f8729de1cdc0cbce4cc7251dcd611bae1dc804aa17de552d9d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7261696f6c616e6574776f726b732f706c7567696e2d73656f2d746573742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/raiolanetworks/plugin-seo-test)

SEO testing assertions for Laravel applications. Compatible with PHPUnit and Pest.

Test meta tags, titles, canonical URLs, Open Graph, Twitter Cards, robots directives, and more with a fluent API.

Requirements
------------

[](#requirements)

- PHP 8.2+ (8.3+ required when used with Laravel 13)
- Laravel 11, 12, or 13
- PHPUnit 10, 11, or 12

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
    - [PHPUnit](#phpunit)
    - [Laravel](#laravel)
    - [Pest](#pest)
- [API](#seo-data)
    - [SEO Data](#seo-data)
    - [Assertions](#assertions)
- [Snapshot testing](#snapshots)

---

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require raiolanetworks/plugin-seo-test --dev
```

Usage
-----

[](#usage)

```
// Create TestSEO instance using the response:
$seo = new TestSEO($htmlResponse);

// Perform assertions:
$seo->assertTitleEndsWith(' - My Website');

// Assert the data yourself:
$this->assertEquals(
    'My title - My Website',
    $seo->data->title()
);
```

Look at the following examples using **PHPUnit**, **Laravel**, and **Pest**.

### PHPUnit

[](#phpunit)

```
public function testLandingPageSEO()
{
    // Arrange
    // ...

    // Act
    $response = $client->get('/')->send();

    // Assert
    $this->assertEquals(200, $response->getStatusCode());
    $html = json_decode($response->getBody(true), true);

    $seo = new TestSEO($html);

    // Assert
    $seo
        ->assertTitleEndsWith(' - My Website')
        ->assertCanonicalIs('https://www.mywebsite.com/');
}
```

### Laravel

[](#laravel)

```
public function test_landing_page_SEO()
{
    // Arrange
    // ...

    // Act
    $response = $this->get('/');

    // Assert
    $response->assertStatus(200);

    $seo = new TestSEO($response->getContent());

    $seo
        ->assertTitleEndsWith(' - My Website')
        ->assertCanonicalIs('https://www.mywebsite.com/');
}
```

### Pest

[](#pest)

```
test('landing page SEO tags', function () {
    // Arrange
    // ...

    // Act
    $response = get('/')->assertStatus(200);

    $seo = new TestSEO($response->getContent());

    // Assert
    expect($seo->data)
        ->title()->toEndWith(' - My Website')
        ->description()->toBe('This is my description')
        ->canonical()->not()->toBeNull()
        ->robots()->index()->toBeTrue()
        ->robots()->nofollow()->toBeTrue();
});
```

SEO Data
--------

[](#seo-data)

You can access the SEO Data yourself by accessing the public property `TestSEO->data`. Here are the available methods:

MethodReturnsDescription`title()``?string``{this}``description()``?string````image()``?Url` [🔍](https://github.com/spatie/url)```robots()``Robots` [🔍](https://github.com/raiolanetworks/plugin-seo-test/blob/main/src/Tags/Robots.php)```canonical()``?Url` [🔍](https://github.com/spatie/url)```prev()``?Url` [🔍](https://github.com/spatie/url)```next()``?Url` [🔍](https://github.com/spatie/url)```openGraph()``TagCollection` [🔍](https://github.com/raiolanetworks/plugin-seo-test/blob/main/src/Tags/TagCollection.php)```twitter()``TagCollection` [🔍](https://github.com/raiolanetworks/plugin-seo-test/blob/main/src/Tags/TagCollection.php)```alternateHrefLang()``AlternateHrefLangCollection` [🔍](https://github.com/raiolanetworks/plugin-seo-test/blob/main/src/Tags/AlternateHrefLangCollection.php)```images()``array`All images in the page. ```h1s()``array`All H1 in the page. `{this}``h2s()``array`All H2 in the page. `{this}``charset()``?string```The SEOData class is **Macroable**, so feel free to extend it yourself.

Assertions
----------

[](#assertions)

MethodNotes`assertCanonicalIs(string $expected)``assertCanonicalIsEmpty()``assertRobotsIsEmpty()``assertRobotsIsNoIndexNoFollow()`Checks that the robots are `noindex, nofollow` or `none``assertPaginationIsEmpty()``prev` and `next` are both missing.`assertAlternateHrefLangIsEmpty()``assertTitleIs(string $expected)``assertTitleContains(string $expected)``assertTitleEndsWith(string $expected)``assertDescriptionIs(string $expected)``assertThereIsOnlyOneH1()`Make sure there is only one H1 in the entire website.`assertAllImagesHaveAltText()`Make sure all images have an `alt="..."`Suggest your own!These assertions can help devs to follow the best SEO practices. Make a PR if you think some are missing!Snapshots
---------

[](#snapshots)

When it comes to SEO, a snapshot test is a great way to ensure nothing has been changed by accident.

Here is an example:

```
$seo = new TestSEO($response->getContent());

$json = json_encode($seo);
```

By default, the SEO tags are serialized using the `SimpleSerializer`. You can provide your own serializer by implementing the `SnapshotSerializer` interface:

```
$seo = new TestSEO($response->getContent(), new MyCustomSerializer());

$json = json_encode($seo);
```

### Pest Example

[](#pest-example)

```
use function Spatie\Snapshots\{assertMatchesSnapshot, assertMatchesJsonSnapshot};
use Raiolanetworks\PluginSEOTest\TestSEO;

test('landing page SEO', function () {
    $response = $this->get('/');

    $response->assertStatus(200);

    $seo = new TestSEO($response->getContent());

    assertMatchesJsonSnapshot(json_encode($seo));
});
```

**Note:** this example requires `spatie/pest-plugin-snapshots`.

Changelog
---------

[](#changelog)

See [Releases](https://github.com/RaiolaNetworks/plugin-seo-test/releases) for a list of changes.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Martin Gomez](https://github.com/soymgomez)
- [David Eguiluz](https://github.com/eguiluz)
- Based on [juampi92/test-seo](https://github.com/juampi92/test-seo)

[![](https://camo.githubusercontent.com/a2a13aedf73f874d9f95dd4a2e9c0505a43a8e0934ef8dd225b8935fe0ad1192/68747470733a2f2f63646e2d6173736574732e7261696f6c616e6574776f726b732e636f6d2f646973742f696d616765732f6c6f676f732f6c6f676f2d626c75652e737667)](https://raiolanetworks.com)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance92

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~205 days

Total

4

Last Release

38d ago

Major Versions

1.0.0 → 2.0.02026-02-20

PHP version history (2 changes)1.0.0PHP ^8.0.2

2.0.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/162998172?v=4)[Raiola Networks](/maintainers/RaiolaNetworks)[@RaiolaNetworks](https://github.com/RaiolaNetworks)

---

Top Contributors

[![juampi92](https://avatars.githubusercontent.com/u/2080215?v=4)](https://github.com/juampi92 "juampi92 (40 commits)")[![soymgomez](https://avatars.githubusercontent.com/u/6207345?v=4)](https://github.com/soymgomez "soymgomez (7 commits)")

---

Tags

laravellaravel-packagepestpestphpphpunitphptestingphpunitlaravelseo

###  Code Quality

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/raiolanetworks-plugin-seo-test/health.svg)

```
[![Health](https://phpackages.com/badges/raiolanetworks-plugin-seo-test/health.svg)](https://phpackages.com/packages/raiolanetworks-plugin-seo-test)
```

###  Alternatives

[juampi92/test-seo

Easy way to test your SEO

26346.2k](/packages/juampi92-test-seo)[brianium/paratest

Parallel testing for PHP

2.5k136.1M986](/packages/brianium-paratest)[drupal/core-dev

require-dev dependencies from drupal/drupal; use in addition to drupal/core-recommended to run tests from drupal/core.

2022.6M343](/packages/drupal-core-dev)[nunomaduro/laravel-mojito

A lightweight package for testing Laravel views.

369461.8k12](/packages/nunomaduro-laravel-mojito)[robiningelbrecht/phpunit-pretty-print

Prettify PHPUnit output

77559.8k16](/packages/robiningelbrecht-phpunit-pretty-print)[robiningelbrecht/phpunit-coverage-tools

PHPUnit coverage tools

17143.1k51](/packages/robiningelbrecht-phpunit-coverage-tools)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
