neophp/seo-package

Automatic sitemap.xml and robots.txt generation from scanned routes for NeoPHP

Maintainers

Package info

github.com/NeoPHP-Dev/neo-seo-package

pkg:composer/neophp/seo-package

Transparency log

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.1 2026-08-08 03:07 UTC

This package is auto-updated.

Last update: 2026-08-08 03:07:39 UTC


README

Automatic sitemap.xml and robots.txt generation for NeoPHP projects — no content to write by hand. Both are built directly from the routes already scanned by RouterManager, including routes from any other installed package.

Structure

seo-package/
├── composer.json
├── README.md
├── src/
│   ├── NeoSeoPackage.php
│   └── Controllers/
│       └── SeoController.php
└── config/
    └── seo.config.php

What it provides

Route Content-Type Behavior
GET /sitemap.xml application/xml Lists every static GET route in the project (and installed packages), excluding configured prefixes
GET /robots.txt text/plain Standard robots directives + a Sitemap: line pointing at the sitemap

Only static routes are included — any route containing a URL parameter ({id}, {slug}, etc.) is skipped automatically, since the package has no way to know which values are valid. If you need dynamic URLs (e.g. product pages) in your sitemap, this package does not cover that case — you'd need your own controller for it.

Installation

php bin/neo package:require neophp/seo-package --project=MyProject

Register it in the project's Config/app.config.php:

return [
    // ...
    'packages' => [
        \Vendor\NeoPHP\SeoPackage\NeoSeoPackage::class,
    ],
];

Configuration

config/seo.config.php is copied once to Config/Packages/Seo/seo.config.php in the target project:

<?php

declare(strict_types=1);

return [
    'sitemap' => [
        'enabled' => true,
        'exclude_prefixes' => ['/admin', '/api'],
        'default_changefreq' => 'weekly',
        'default_priority' => 0.5,
    ],

    'robots' => [
        'enabled' => true,
        'disallow' => ['/admin', '/api'],
        'sitemap_url' => '/sitemap.xml',
    ],
];
  • sitemap.exclude_prefixes — any route whose path starts with one of these prefixes is left out of sitemap.xml. Useful for admin panels (e.g. neo-admin-package's /admin/* routes) or API endpoints.
  • robots.disallow — paths listed under Disallow: in robots.txt. Independent from sitemap.exclude_prefixes — set both if you want a route both hidden from the sitemap and disallowed for crawlers.
  • Set enabled: false on either section to return a 404 for that route instead of generating content — useful if you only want one of the two.

Notes

  • changefreq and priority are the same for every URL — there is no per-route override. If you need fine-grained control, this package is intentionally simple; write your own sitemap controller instead.
  • The base URL (scheme + host) is read from the current request ($_SERVER['HTTPS'] / $_SERVER['HTTP_HOST']), so the sitemap always reflects the domain it's served from — no config needed for that part.

License

MIT