Deprecated features and undefined variable
PHP Deprecated: Melbahja\Seo\Sitemap::__construct(): Implicitly marking parameter $options as nullable is deprecated, the explicit nullable type must be used instead in /home/gamerighq/htdocs/gamerighq.com/vendor/melbahja/seo/src/Sitemap.php on line 52 PHP Deprecated: Melbahja\Seo\Interfaces\SitemapIndexInterface::__construct(): Implicitly marking parameter $options as nullable is deprecated, the explicit nullable type must be used instead in vendor/melbahja/seo/src/Interfaces/SitemapIndexInterface.php on line 13
In Sitemap.php line 200:
Undefined variable $name
can you provide code to reproduce it ?
$sitemap = new Sitemap(config('app.url'), ['save_path' => public_path('sitemap')]);
$sitemap->links(['name' => 'categories.xml', 'images' => false], function ($map) {
Category::all()->each(function ($category) use ($map) {
$map->loc("/category/{$category->slug}")
->freq('weekly')->priority('0.9')
->lastMod($category->updated_at->toDateString());
});
});
$sitemap->save();
It's a laravel project The category class is a Model PHP Version Info:
PHP 8.4.5 (cli) (built: Mar 17 2025 20:35:32) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.5, Copyright (c) Zend Technologies
with Zend OPcache v8.4.5, Copyright (c), by Zend Technologies
This ticket reports 2 bugs, both affecting version 2.1.1. I recommend to focus this report on the deprecation and file a different ticket to track the undefined variable.
@melbahja: The deprecation only needs constructing a Sitemap object with a PHP version of at least 8.4, which deprecates such synopses.
v3 has been released with support for php >= 8.1, so this issue has been resolved, thank you all