Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Php Api Client

Php Api Client Laravel Package

mosparo/php-api-client

PHP API client for mosparo spam protection. Connect to a mosparo instance, send verification requests for form submissions, handle validation results, and integrate bot protection into your PHP/Laravel apps with a simple, lightweight client.

View on GitHub
Deep Wiki
Context7

A PHP library to communicate with mosparo.

Frequently asked questions about Php Api Client
How do I install the mosparo/php-api-client in a Laravel project?
Run `composer require mosparo/php-api-client` in your project directory. The package has no Laravel-specific dependencies, so it works standalone or alongside Laravel’s HTTP client. For Laravel integration, bind the client to the service container via a service provider.
What Laravel versions does this package support?
The package is framework-agnostic but works seamlessly with Laravel 8.x, 9.x, and 10.x. It leverages Guzzle, which Laravel’s HTTP client also uses, ensuring compatibility. No version-specific Laravel features are required.
How do I integrate Mosparo’s frontend JavaScript with Laravel Blade forms?
Include the Mosparo frontend script in your Blade template, passing the Mosparo URL, project UUID, and public key. Example: `<script src='https://[URL]/build/mosparo-frontend.js'></script>`. The script auto-generates `_mosparo_submitToken` and `_mosparo_validationToken` for form submissions.
Can I use this client with Mosparo versions older than 1.5?
Yes, the `verifySubmission` method supports Mosparo 1.4 and earlier, but advanced features like `storeMetadata` or `getStatisticByDate` require Mosparo 1.5+. Check the Mosparo changelog for version-specific API changes that might affect your use case.
How do I handle failed verification results in Laravel?
Use `$result->isSubmittable()` to check if the submission is valid. For failed submissions, log errors with Laravel’s logging system (e.g., `Log::error($result->getIssues())`) or trigger a custom event (e.g., `event(new MosparoVerificationFailed($result))`) for downstream handling.
Where should I store Mosparo’s private key in Laravel?
Store the private key in Laravel’s `.env` file (e.g., `MOSPARO_PRIVATE_KEY=your_key`). Use Laravel’s `config()` helper or environment variables to inject it into the client during initialization. Avoid hardcoding keys in your application code.
How can I avoid CSRF conflicts with Mosparo’s tokens?
Laravel’s CSRF protection may block Mosparo’s auto-generated tokens (`_mosparo_submitToken`, `_mosparo_validationToken`). Exclude these tokens from CSRF verification in your `VerifyCsrfToken` middleware or whitelist them in the `except` array.
Is it safe to use Mosparo’s tokens directly from $_POST?
Yes, but sanitize the tokens to prevent tampering. Mosparo’s frontend script generates these tokens securely, but always validate them via the client’s `verifySubmission` method. Never rely solely on client-side checks.
Can I cache Mosparo API responses in Laravel?
Yes, cache statistical data (e.g., `getStatisticByDate`) using Laravel’s cache system. Wrap API calls in `Cache::remember` or use a queue job to fetch and cache data periodically. Avoid caching verification results, as they depend on real-time form submissions.
What are the alternatives to this package for Laravel spam protection?
Alternatives include hCaptcha’s PHP SDK, Google reCAPTCHA’s PHP client, or Akismet’s API wrapper. Mosparo offers advanced features like metadata storage and rule customization, making it ideal for complex form workflows. Compare Mosparo’s pricing and API limits with alternatives before choosing.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
symfony/ai-symfony-mate-extension
aashan/pimcore-mcp-bundle
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin