PHP code example of oliweb / laravel-cap

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

    

oliweb / laravel-cap example snippets


// lang/vendor/cap/fr/messages.php
return [
    'validation_failed' => 'La vérification :attribute a échoué. Veuillez réessayer.',
    'middleware_failed'  => 'La vérification Cap a échoué.',
];

Route::post('/contact', [ContactController::class, 'store'])
    ->middleware('cap.verify');

use LaravelCap\Rules\CapRule;

public function rules(): array
{
    return [
        'cap-token' => ['

use LaravelCap\Facades\Cap;

if (Cap::verify($request->input('cap-token'))) {
    // token is valid
}

use LaravelCap\Cap;

class ContactController extends Controller
{
    public function __construct(private readonly Cap $cap) {}

    public function store(Request $request): RedirectResponse
    {
        $this->cap->verifyOrFail($request->input('cap-token'));
        // ...
    }
}
bash
php artisan vendor:publish --tag=cap-config
bash
php artisan vendor:publish --tag=cap-assets
bash
php artisan vendor:publish --tag=cap-lang
bash
php artisan vendor:publish --tag=cap-lang
bash
php artisan vendor:publish --tag=cap-assets