1. Go to this page and download the library: Download heano/basin-php 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/ */
heano / basin-php example snippets
use GuzzleHttp\Client as Guzzle;
use GuzzleHttp\Psr7\HttpFactory;
use Heano\Basin\Client;
$factory = new HttpFactory();
$basin = new Client(
apiKey: getenv('BASIN_API_KEY'),
http: new Guzzle(['timeout' => 10, 'connect_timeout' => 5]),
requestFactory: $factory,
streamFactory: $factory,
);
$projects = $basin->listProjects();
foreach ($projects->items as $project) {
echo $project['id'], ': ', $project['name'], PHP_EOL;
}
$project = $basin->getProject(1004);
// Forms in one project. Leave the project ID out to list every form.
$forms = $basin->listForms(projectId: 1004);
// One form, with its inbox_count, spam_count and trash_count.
$form = $basin->getForm(1001);
echo $form['uuid']; // e.g. "demo0contact", the ID in https://usebasin.com/f/demo0contact
// Change a form's settings, using Basin's field names.
$basin->updateForm(1001, ['use_ajax' => false]);
// Name and project are orm('Quotes', projectId: 1004, fields: [
'timezone' => 'Europe/London',
'notification_emails' => '[email protected]',
]);
// Permanently deletes the form and all its submissions.
$basin->deleteForm($form['id']);
$settings = $basin->getFormSettings(1001);
$settings['notification_emails']; // Confirmed recipients
$settings['notification_emails_pending']; // Waiting for confirmation
$settings['turnstile_secret_set']; // true or false; the secret itself is never returned
$page = $basin->listSubmissions([
'formId' => 1001, // or 'projectId' => 1004
'filter' => null, // null (inbox), 'spam' or 'trash'
'query' => 'jane', // Basin's text search
'order' => 'date_desc', // date_desc, date_asc, email_asc, email_desc
'dateFrom' => '2026-01-01',
'dateTo' => '2026-01-31', // either end can be left out
]);
$page->items; // the submissions
$page->total; // matching submissions, if Basin said
$page->meta['inbox_count']; // Basin's counts for the same scope
$page->meta['spam_count'];
$submission = $basin->getSubmission(5678);
$submission['payload_params']; // the submitted fields
// Mark as read, spam or trash (any combination).
$basin->updateSubmission(5678, ['read' => true]);
$basin->updateSubmission(5678, ['spam' => false, 'trash' => true]);
// Send it to the form's webhooks again.
$basin->refireWebhooks(5678);
// Delete it permanently. This can't be undone.
$basin->deleteSubmission(5678);
$page = 1;
do {
$result = $basin->listSubmissions(['formId' => 1001], $page++);
foreach ($result->items as $submission) {
// ...
}
} while ($result->hasMore());