Installation Add the package via Composer:
composer require chill-project/icpc2
Publish the config file (if available):
php artisan vendor:publish --provider="ChillProject\ICPC2\ICPC2ServiceProvider"
First Use Case The package appears to be a mirror of ICPC2 (likely a privacy-focused alternative to Google's Invisible reCAPTCHA). Start by:
config/icpc2.php (if published) for basic configuration.{!! ICPC2::render() !!}
use ChillProject\ICPC2\Facades\ICPC2;
if (!ICPC2::verify($request->input('icpc2-token'))) {
return back()->withErrors(['icpc2' => 'Verification failed']);
}
Where to Look First
ICPC2ServiceProvider for registration logic.ICPC2 facade methods (render(), verify()) in src/Facades/ICPC2.php.VerifyICPC2 middleware if included.Frontend Integration
@icpc2 or {{ icpc2() }} if the package provides them.ICPC2::render(['theme' => 'dark', 'size' => 'compact']);
@icpc2(['async' => true])
Backend Validation
FormRequest to include ICPC2 validation:
public function rules()
{
return [
'icpc2-token' => 'required|icpc2',
];
}
VerifyICPC2:
Route::middleware(['icpc2'])->group(function () {
// Protected routes
});
if (ICPC2::verify($token)) {
// Proceed
}
Configuration
config/icpc2.php:
'site_key' => env('ICPC2_SITE_KEY'),
'endpoint' => env('ICPC2_ENDPOINT', 'https://icpc2.example.com/api/verify'),
Event Handling
Event::listen('icpc2.failed', function ($request) {
Log::warning('ICPC2 verification failed', ['ip' => $request->ip()]);
});
Cache::remember('icpc2-script', now()->addDays(1), function () {
return ICPC2::render();
});
ICPC2 facade in unit tests:
ICPC2::shouldReceive('verify')->once()->andReturn(true);
Archived Status
Missing Documentation
src/ directory.ICPC2 facade.Configuration Quirks
ICPC2_SITE_KEY is set in .env:
ICPC2_SITE_KEY=your_site_key_here
config/icpc2.php defaults).JavaScript Dependencies
<body>.Rate Limiting
try {
if (!ICPC2::verify($token)) {
throw new \RuntimeException('ICPC2 verification failed');
}
} catch (\Exception $e) {
// Retry or show a fallback CAPTCHA
}
Log Verification Responses
Add debug logging to the verify() method (temporarily):
\Log::debug('ICPC2 Response', [
'token' => $token,
'response' => $response,
]);
Check Network Requests
Fallback Mechanism Implement a fallback (e.g., hCaptcha) if ICPC2 fails:
if (!ICPC2::verify($token)) {
if ($request->has('hcaptcha-response')) {
// Validate hCaptcha instead
}
}
Clear Cache If changes to config aren’t reflected:
php artisan config:clear
php artisan view:clear
Custom Verification Logic Override the verification logic by binding a custom verifier:
$app->bind('icpc2.verifier', function () {
return new CustomICPC2Verifier();
});
Add Custom Data Extend the verification payload:
ICPC2::verify($token, ['custom_field' => 'value']);
Create a Package Wrapper If the package lacks features, wrap it in a custom package to add:
Contribute Upstream Since the package is archived, consider:
How can I help you explore Laravel packages today?