Installation
Add the bundle to your composer.json:
composer require beloop/typeform-bundle
Register it in config/bundles.php:
return [
// ...
Beloop\TypeformBundle\BeloopTypeformBundle::class => ['all' => true],
];
Configuration Publish the default config:
php bin/console beloop:typeform:install
Update config/packages/beloop_typeform.yaml with your Typeform API credentials:
beloop_typeform:
api_key: 'your_typeform_api_key'
webhook_secret: 'your_webhook_secret'
First Use Case Trigger a Typeform submission via a Symfony command:
php bin/console beloop:typeform:submit --form-id=12345 --data='{"name":"John","email":"john@example.com"}'
Submission Handling
Use the TypeformClient service to submit forms programmatically:
$client = $container->get('beloop.typeform.client');
$response = $client->submitForm(12345, ['name' => 'Alice', 'email' => 'alice@example.com']);
Webhook Integration
Extend the TypeformWebhookController to handle incoming submissions:
use Beloop\TypeformBundle\Controller\TypeformWebhookController;
class CustomWebhookController extends TypeformWebhookController
{
public function onSubmitAction(Request $request)
{
$data = $this->getSubmissionData($request);
// Process data (e.g., save to DB, trigger email)
}
}
Form Management
Fetch forms via the TypeformManager:
$forms = $this->get('beloop.typeform.manager')->getForms();
$form = $this->createFormBuilder($data)
->add('name', TextType::class)
->getForm();
$form->submit($submissionData);
if ($form->isValid()) { /* ... */ }
$dispatcher->dispatch(new TypeformSubmissionEvent($submissionData));
Deprecated API
The bundle uses Typeform’s v1 API (deprecated in 2021). Migrate to the v2 API for long-term use.
Workaround: Use a wrapper like typeform/php-sdk alongside this bundle.
Webhook Validation Always validate webhook signatures:
$this->validateWebhook($request, $this->getParameter('beloop_typeform.webhook_secret'));
Rate Limits Typeform’s free tier has strict rate limits. Cache form responses aggressively:
# config/packages/cache.yaml
beloop_typeform:
cache_enabled: true
cache_lifetime: 3600
config/packages/beloop_typeform.yaml:
debug: true
var/log/dev.log for raw Typeform API responses.Custom Responses
Override Beloop\TypeformBundle\Service\TypeformClient to modify API calls:
services:
beloop.typeform.client:
class: App\Service\CustomTypeformClient
parent: beloop.typeform.client
Data Transformers
Use the TypeformDataTransformer interface to sanitize/transform submissions:
$transformer = new CustomTransformer();
$cleanData = $transformer->transform($rawSubmission);
Event Listeners
Subscribe to typeform.submission events in config/services.yaml:
services:
App\EventListener\TypeformListener:
tags:
- { name: kernel.event_listener, event: typeform.submission, method: onSubmission }
How can I help you explore Laravel packages today?