What Laravel Robots Middleware does
Laravel Robots Middleware is a small PHP package from Spatie that controls whether pages of a Laravel application are indexed by search engines. It ships as a middleware class, and by default it enables indexing on every page. Developers extend the class and override the shouldIndex method, which receives the current request and returns a value that decides the outcome for that request.
Installation is one Composer command, composer require spatie/laravel-robots-middleware, after which the class is registered in the application middleware stack, shown in the README in app/Http/Kernel.php. The documented example checks the first URL segment against admin, so administrative pages are excluded from indexing while the rest of the site is not. The README points to Google's robots meta tag documentation and the code is released under the MIT licence.
Key features
- Per-request indexing rule
- Override shouldIndex to return a string or boolean that decides indexing for the current request.
- Indexing enabled by default
- Out of the box the middleware enables indexing on all pages without any configuration.
- Composer installation
- Installed with composer require spatie/laravel-robots-middleware as printed in the README.
- Middleware stack registration
- The custom class is added to the middleware array in app/Http/Kernel.php.
- URL segment conditions
- Sample rule compares the first request segment against admin before deciding the outcome.
- Laravel HTTP middleware
- Built as a standard Laravel middleware class that wraps requests in the framework pipeline.
- MIT licence
- Released under the MIT licence with a LICENSE.md file in the repository.
- Changelog file
- Repository keeps a separate CHANGELOG.md recording what changed between releases.
- Composer test command
- Tests run with the composer test command described in the README.
How it works
- Install the package with Composer using the require command printed in the README.
- Create your own middleware class in app/Http/Middleware that extends the package RobotsMiddleware class.
- Override the protected shouldIndex method and return a string or boolean for the request.
- Register the new class in the middleware array inside app/Http/Kernel.php.
- Each request then passes through the rule and indexing is enabled or disabled for it.
Plans and pricing
The package is free and open source under the MIT licence; no paid tiers are listed.
Integrations and platforms
Works with
- Laravel
- Composer
Available as
- Web
- CLI
Repository facts
- Repositoryspatie/laravel-robots-middleware
- LanguagePHP
- Stars334
- Forks29
- LicenceMIT
- Created2016-01-04
- Last commit2026-11-05
- Open issues0
- laravel
- php
- robots
- seo
Services and details
Does SEO work itself
YesFree plan or free tools
Yes
No information yet on keyword research, content optimization, writes content with AI, technical audits, rank tracking, backlinks and link building, local SEO, AI search visibility, free trial, API or MCP server, WordPress plugin, browser extension, built for agencies. The website did not say; check with the vendor.
About the company
- Company Spatie
- Head office Antwerp, Belgium
- Website: github.com/spatie/laravel-robots-middleware
Listing compiled from public sources and the product's own website. Last updated 2026-11-12. Report a correction or request removal. Back to GitHub repos.