PHP code example of pierre-arthur / sf-doctor

1. Go to this page and download the library: Download pierre-arthur/sf-doctor 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/ */

    

pierre-arthur / sf-doctor example snippets


return [
    // ...
    PierreArthur\SfDoctor\SfDoctorBundle::class => ['dev' => true, 'test' => true],
];

use PierreArthur\SfDoctor\Analyzer\AnalyzerInterface;
use PierreArthur\SfDoctor\Config\ConfigReaderInterface;
use PierreArthur\SfDoctor\Context\ProjectContext;
use PierreArthur\SfDoctor\Model\AuditReport;
use PierreArthur\SfDoctor\Model\Module;

class MonAnalyzer implements AnalyzerInterface
{
    public function __construct(
        private ConfigReaderInterface $configReader,
    ) {
    }

    public function getName(): string
    {
        return 'Mon Analyzer';
    }

    public function getModule(): Module
    {
        return Module::ARCHITECTURE;
    }

    public function supports(ProjectContext $context): bool
    {
        return true;
    }

    public function analyze(AuditReport $report): void
    {
        // Votre logique d'analyse ici
    }
}
bash
# Mode interactif : propose et applique les corrections une par une
bin/console sf-doctor:fix

# Voir les corrections sans les appliquer
bin/console sf-doctor:fix --dry-run

# Appliquer toutes les corrections automatiquement
bin/console sf-doctor:fix --auto

 SF-Doctor - Rapport d'audit
 ============================

 Projet : /var/www/mon-projet
 Issues trouvees : 3

 Module Security
 ----------------

 ---------- ------------------- --------------------------------------------- ---------------------------
  Severite   Analyzer            Message                                        Fichier
 ---------- ------------------- --------------------------------------------- ---------------------------
  CRITICAL   FirewallAnalyzer    No authenticator configured on firewall main   config/packages/security.yaml
  WARNING    CsrfAnalyzer        CSRF disabled on CheckoutType                  src/Form/CheckoutType.php
 ---------- ------------------- --------------------------------------------- ---------------------------

  > Impact metier : Un attaquant peut soumettre des formulaires au nom d'un utilisateur
  > Correction :    Retirer 'csrf_protection' => false du FormType
  > Documentation : https://symfony.com/doc/current/security/csrf.html
  > Temps estime :  15 min

 Module Configuration
 ---------------------

 ---------- -------------------- ----------------------- -----------
  Severite   Analyzer             Message                 Fichier
 ---------- -------------------- ----------------------- -----------
  CRITICAL   DebugModeAnalyzer    APP_DEBUG is true       .env.prod
 ---------- -------------------- ----------------------- -----------

 Score : 70/100
 Temps total de remediation estime : 2h30