PHP Luminova: Audit Broken Webpage Links
Crawl your site from Novakit or PHP and write a JSON list of URLs that failed during the audit.
Use a link audit after moving pages, changing routes, or publishing new content. The crawler starts at your application’s configured URL and follows eligible links on the pages it can reach. It uses the same crawl settings as the Sitemap Generator, including URL exclusions and scan limits.
Configure the Crawl
Set app.start.url in your application environment and review the Sitemap configuration. A URL supplied with --url must still match the configured crawl base and any scanUrlPrefix. Pages outside that scope and links on pages the crawler never reaches are outside the audit.
Set numeric limits and delays directly in app/Config/Sitemap.php. The current Novakit command can pass command-line values such as --limit=25 to typed configuration properties as strings, which can stop the command before it starts.
Run a Link Audit with Novakit
From the project root, run the sitemap command with --broken. The default output is public/broken.sitemap.json.
php novakit sitemap --brokenPreview the crawl, or choose a starting page and a different output filename.
php novakit sitemap --broken --dry-run
php novakit sitemap --broken --url=https://example.com --basename=links-audit.json| Option | Purpose |
|---|---|
--broken, -b | Select the JSON link audit. |
--url, -u | Start at a URL within the configured crawl scope. |
--basename, -f | Set a filename in public/. A filename ending in .xml is replaced with broken.sitemap.json. |
--prefix, -p | Restrict the crawl to a URL prefix relative to the configured base. |
--dry-run, -n | Make the crawl requests and show terminal output without saving a report. |
The summary may say Link Tree Generation Completed. The current source gives both modes the value 2, so --link-tree also selects the JSON output. A separate link tree and its format options are unavailable in this implementation.
Read the Report
The report is a JSON array of URL strings. An entry means the crawler could not use that URL. Check the terminal output to distinguish HTTP failures, empty responses, and connection errors. When the scan succeeds and finds no failures, the report contains []. If the starting page fails and the crawl yields no usable pages, the command can fail without writing a report.
For example, a scan that cannot use two pages can produce this report.
[
"https://example.com/old-contact",
"https://example.com/retired-guide"
]The report is written to the public document root. Use a dry run if you want terminal output without leaving a publicly accessible file.
Run a Link Audit from PHP
Call Sitemap::generate() from a bootstrapped CLI script or worker and pass Sitemap::GENERATE_BROKEN_LINKS as the mode. The method is shared with sitemap generation.
use Luminova\Components\Seo\Sitemap;
$config = new \App\Config\Sitemap();
$config->maxScan = 25;
$generated = Sitemap::generate(
url: 'https://example.com',
basename: 'broken.sitemap.json',
config: $config,
options: ['mode' => Sitemap::GENERATE_BROKEN_LINKS]
);
if (!$generated) {
exit(STATUS_ERROR);
}The return value reports whether output generation succeeded. Read the JSON file to learn whether the audit found failures.
Exclude Asset Directories
Pass --ignore-assets or -a to skip links under /assets/ and /public/assets/. From PHP, set ignoreAssets to true in the crawl options. Use ignoreUrls in the crawl configuration to exclude specific URL patterns.