1. Go to this page and download the library: Download otatechie/laravel-spotlight library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Spotlight\Rules\Performance; // Category auto-detected from namespace!
use Otatechie\Spotlight\Rules\AbstractRule;
class MyCustomRule extends AbstractRule
{
// Only define what's different - everything else is auto-detected!
protected ?string $severity = 'medium'; // Or leave null for category-based default
protected string $description = 'Checks for a specific issue';
protected ?string $documentationUrl = 'https://example.com/docs/my-rule';
// id: auto-generated as 'performance.my-custom'
// category: auto-detected as 'performance' from namespace
// name: auto-generated as 'My Custom' from class name
// severity: defaults to 'medium' (performance category default)
public function scan(): array
{
if ($issueFound) {
return $this->suggest(
'Issue description',
['recommendation' => 'How to fix it']
);
}
return $this->pass('Everything looks good!');
}
}