PHP code example of ahmedanbar / devguard

1. Go to this page and download the library: Download ahmedanbar/devguard 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/ */

    

ahmedanbar / devguard example snippets


// @devguard-ignore: direct_db_in_controller
$rows = DB::table('users')->whereRaw($trustedExpr)->get();

$x = $request->raw(); // @devguard-ignore   (suppresses every rule at this line)



return [
    'tools' => [
        'deploy' => [
            'checks' => [
                'debug_mode' => ['impact' => 25],
            ],
        ],
        'architecture' => [
            'rules' => [
                'fat_controller' => ['max_lines' => 200],
            ],
        ],
    ],
];

   final class MyTool implements ToolInterface
   {
       public function name(): string { return 'mytool'; }
       public function title(): string { return 'My Tool'; }
       public function description(): string { return 'Does a thing.'; }

       public function run(ProjectContext $ctx): ToolReport
       {
           $report = new ToolReport(tool: $this->name(), title: $this->title());
           $report->add(CheckResult::pass('hello', 'It works'));
           return $report;
       }
   }
   

   $app->addTool(new MyTool());