PHP code example of therealmkadmi / laravel-citadel

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

    

therealmkadmi / laravel-citadel example snippets


Route::middleware(['citadel-passive'])->group(function () {
    // These routes will be monitored but never blocked
    Route::get('/public-content', 'ContentController@index');
});

Route::middleware(['citadel-active'])->group(function () {
    // These routes get full protection with external API calls
    Route::post('/login', 'AuthController@login');
    Route::post('/register', 'AuthController@register');
});

Route::middleware(['citadel-protect'])->group(function () {
    // These routes get complete protection with all analyzers
    Route::post('/checkout', 'PaymentController@processPayment');
});

// In config/citadel.php
'middleware' => [
    'enabled' => env('CITADEL_ENABLED', true),             // Global on/off switch
    'passive_enabled' => env('CITADEL_PASSIVE_ENABLED', true), // Enable passive monitoring
    'active_enabled' => env('CITADEL_ACTIVE_ENABLED', true),   // Enable active protection
],

Route::middleware(['citadel-protect'])->group(function () {
    Route::get('/protected', function () {
        return 'This route is protected by Citadel.';
    });
});

'api' => [
    'enabled' => true,
    'token' => env('CITADEL_API_TOKEN', 'your-secret-token'),
    'prefix' => 'api/citadel',
],
bash
php artisan vendor:publish --provider="TheRealMkadmi\\Citadel\\CitadelServiceProvider"
bash
php artisan citadel:ban {identifier} --type={ip|fingerprint|auto} --duration={minutes}
bash
php artisan citadel:unban {identifier} --type={ip|fingerprint|auto}
bash
php artisan laravel-citadel