PHP code example of rafaelogic / codesnoutr
1. Go to this page and download the library: Download rafaelogic/codesnoutr 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/ */
rafaelogic / codesnoutr example snippets
Route::group(['prefix' => 'code-scanner', 'middleware' => ['web', 'auth']], function () {
// In config/logging.php
'channels' => [
'codesnoutr' => [
'driver' => 'daily',
'path' => storage_path('logs/codesnoutr.log'),
'level' => 'info',
'days' => 7,
],
],
// In app/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
// Schedule periodic scans
$schedule->command('codesnoutr:scan codebase --save')
->daily()
->withoutOverlapping();
}
return [
'enabled' => env('CODESNOUTR_ENABLED', true),
// Scanning configuration
'scan' => [
'paths' => ['app', 'config', 'routes', 'database/migrations', 'resources/views'],
'exclude_paths' => ['vendor', 'node_modules', 'storage', 'bootstrap/cache'],
'file_extensions' => ['php', 'blade.php'],
'max_file_size' => 1024 * 1024, // 1MB
'timeout' => 300, // 5 minutes
],
// Queue management configuration
'queue' => [
'enabled' => env('CODESNOUTR_QUEUE_ENABLED', true),
'name' => env('CODESNOUTR_QUEUE_NAME', 'default'),
'connection' => env('CODESNOUTR_QUEUE_CONNECTION', config('queue.default')),
'auto_start' => env('CODESNOUTR_QUEUE_AUTO_START', true),
'timeout' => env('CODESNOUTR_QUEUE_TIMEOUT', 300),
'memory' => env('CODESNOUTR_QUEUE_MEMORY', 512),
],
// Scanner rules configuration
'scanners' => [
'security' => ['enabled' => true, 'rules' => [...]],
'performance' => ['enabled' => true, 'rules' => [...]],
'quality' => ['enabled' => true, 'rules' => [...]],
'laravel' => ['enabled' => true, 'rules' => [...]],
],
// AI integration (ready for implementation)
'ai' => [
'enabled' => env('CODESNOUTR_AI_ENABLED', false),
'provider' => env('CODESNOUTR_AI_PROVIDER', 'openai'),
'openai' => [
'api_key' => env('OPENAI_API_KEY'),
'model' => env('CODESNOUTR_AI_MODEL', 'gpt-4'),
],
],
// UI preferences
'ui' => [
'theme' => ['default' => 'system', 'persist' => true],
'pagination' => ['per_page' => 25, 'max_per_page' => 100],
],
];
bash
php artisan codesnoutr:install
bash
# Check if queue worker is running
ps aux | grep "queue:work"
# Check failed jobs
php artisan queue:failed
# Clear failed jobs
php artisan queue:flush
# Restart queue worker
php artisan queue:restart
bash
# Re-run migrations if needed
php artisan migrate:refresh
# Check database connection
php artisan tinker
>>> \DB::connection()->getPdo()
bash
# Force republish assets
php artisan vendor:publish --tag=codesnoutr-assets --force
# Clear and rebuild cache
php artisan config:clear
php artisan route:clear
php artisan view:clear
php artisan cache:clear
bash
# Check queue status
php artisan queue:status
# Restart queue workers
php artisan queue:restart
# Test queue functionality
php artisan queue:work --once
# Start queue worker for Fix All jobs
php artisan queue:work --verbose
bash
php artisan migrate
bash
# Remove the package
composer remove rafaelogic/codesnoutr
# Remove database tables (optional)
php artisan migrate:rollback --path=database/migrations/codesnoutr
# Remove published files (optional)
rm -rf config/codesnoutr.php
rm -rf public/vendor/codesnoutr/
# Clear caches
php artisan config:clear
php artisan route:clear
php artisan view:clear
bash
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan optimize
bash
# Scan a single file for quick testing
php artisan codesnoutr:scan file app/Models/User.php
# Or scan your entire application
php artisan codesnoutr:scan codebase --save
bash
php artisan codesnoutr:scan codebase
bash
php artisan codesnoutr:scan file app/Models/User.php
bash
php artisan codesnoutr:scan directory app/Models
bash
php artisan codesnoutr:scan codebase --categories=security,performance
bash
# Export as JSON
php artisan codesnoutr:scan codebase --format=json --export-path=results.json
# Export as CSV
php artisan codesnoutr:scan codebase --format=csv --export-path=results.csv
# Save to database (default)
php artisan codesnoutr:scan codebase --save
bash
# Terminal 1: Queue worker (keep this running)
php artisan queue:work --verbose --timeout=300
# Terminal 2: Your Laravel app
php artisan serve
bash
composer analyse
bash
php artisan codesnoutr:install --force
# or
php artisan vendor:publish --provider="Rafaelogic\CodeSnoutr\CodeSnoutrServiceProvider" --tag="codesnoutr-assets" --force