Skip to content

Conversation

@KMKoushik
Copy link
Member

@KMKoushik KMKoushik commented Nov 29, 2025

Summary

  • add a PHP getting-started guide that uses the REST API for sending emails and managing contacts
  • document setup with Guzzle, email sending, contact operations, and basic error handling
  • surface the PHP guide in the Getting Started navigation

Issues

  • None

Screenshots

  • Not applicable

Migrations

  • None

Verification

  • Not run (docs-only change)

Codex Task


Summary by cubic

Adds a PHP getting started guide that uses the REST API via Guzzle to send emails and manage contacts, and surfaces it in the Getting Started navigation.

  • New Features
    • Setup with Composer/Guzzle and a reusable client.
    • Examples for sending emails and creating/updating contacts.
    • Basic error handling patterns.
    • Added “PHP (API)” to the Getting Started nav.

Written for commit 45c89cb. Summary will update automatically on new commits.

Summary by CodeRabbit

  • Documentation
    • Added PHP Getting Started guide covering REST API integration with code examples for email sending and contact management
    • Updated documentation navigation to include the new PHP guide

✏️ Tip: You can customize this high-level summary in your review settings.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 29, 2025

Deploying usesend with  Cloudflare Pages  Cloudflare Pages

Latest commit: 45c89cb
Status: ✅  Deploy successful!
Preview URL: https://dc0e6045.usesend.pages.dev
Branch Preview URL: https://codex-create-getting-started.usesend.pages.dev

View logs

@vercel
Copy link

vercel bot commented Nov 29, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
unsend-marketing Ready Ready Preview Comment Nov 29, 2025 4:42am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 29, 2025

Walkthrough

This pull request adds PHP documentation to the Getting Started section. It includes a new page in the documentation navigation (docs.json) and introduces a comprehensive PHP guide (get-started/php.mdx) for using the useSend REST API. The guide covers prerequisites, Guzzle HTTP client installation and configuration, practical examples for sending emails and managing contacts using POST and PATCH requests, error handling with try/catch blocks, and support notes for self-hosted deployments. Custom header forwarding is also documented.

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'docs: add PHP getting started guide' clearly and concisely describes the main change: adding a PHP getting-started guide to the documentation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
apps/docs/get-started/php.mdx (2)

29-37: Consider adding API key validation and timeout configuration.

The client setup is correct but lacks two best practices that should be documented for production safety:

  1. API key validation: getenv('USESEND_API_KEY') could fail silently if the environment variable is missing.
  2. Timeout settings: Guzzle client should have explicit timeout configuration to prevent indefinite hangs.

For a "getting started" guide, consider adding a note or optional example showing these patterns.

Example enhancement:

$apiKey = getenv('USESEND_API_KEY');
if (!$apiKey) {
    throw new Exception('USESEND_API_KEY environment variable not set');
}

$client = new Client([
    'base_uri' => 'https://app.usesend.com/api/',
    'timeout' => 5.0,
    'headers' => [
        'Authorization' => "Bearer {$apiKey}",
        'Content-Type' => 'application/json',
    ],
]);

91-105: Error handling section demonstrates practical patterns.

The try/catch pattern properly separates client and server errors. For additional robustness, consider catching the broader RequestException as a fallback:

} catch (\GuzzleHttp\Exception\RequestException $e) {
    error_log('Request failed: ' . $e->getMessage());
}

This would catch connection errors, timeouts, and other network-level issues, but this is optional for a getting-started guide.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e1b64d0 and 45c89cb.

📒 Files selected for processing (2)
  • apps/docs/docs.json (1 hunks)
  • apps/docs/get-started/php.mdx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (4)
apps/docs/docs.json (1)

31-31: Navigation entry correctly placed.

The PHP guide is well-positioned in the Getting Started navigation alongside other language guides.

apps/docs/get-started/php.mdx (3)

1-13: Prerequisites and metadata are clear and complete.

The frontmatter and prerequisites section properly orient users before they begin setup.


43-63: Email sending example is clear and functionally correct.

The POST example properly demonstrates the API payload structure. One minor clarification: the from address must match a verified domain configured in useSend.


65-89: Contact operations are well-documented with clear examples.

Both POST and PATCH examples properly demonstrate the contact management patterns. The upfront note about requiring a contact book ID prevents confusion.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 2 files

Prompt for AI agents (all 3 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/docs/get-started/php.mdx">

<violation number="1" location="apps/docs/get-started/php.mdx:27">
`use` statement shows a double backslash, so copying the snippet yields invalid PHP syntax. Use a single namespace separator when importing `GuzzleHttp\Client`.</violation>

<violation number="2" location="apps/docs/get-started/php.mdx:98">
ClientException catch statement escapes the namespace separator twice, making the provided PHP snippet uncompilable. Use single backslashes in the fully qualified class name.</violation>

<violation number="3" location="apps/docs/get-started/php.mdx:101">
ServerException catch block double-escapes the namespace separator, so the example cannot be pasted into PHP as-is. Replace it with a single backslash-qualified class name.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

} catch (\\GuzzleHttp\\Exception\\ClientException $e) {
// 4xx responses
error_log($e->getResponse()->getBody()->getContents());
} catch (\\GuzzleHttp\\Exception\\ServerException $e) {
Copy link

@cubic-dev-ai cubic-dev-ai bot Nov 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ServerException catch block double-escapes the namespace separator, so the example cannot be pasted into PHP as-is. Replace it with a single backslash-qualified class name.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/docs/get-started/php.mdx, line 101:

<comment>ServerException catch block double-escapes the namespace separator, so the example cannot be pasted into PHP as-is. Replace it with a single backslash-qualified class name.</comment>

<file context>
@@ -0,0 +1,105 @@
+} catch (\\GuzzleHttp\\Exception\\ClientException $e) {
+    // 4xx responses
+    error_log($e-&gt;getResponse()-&gt;getBody()-&gt;getContents());
+} catch (\\GuzzleHttp\\Exception\\ServerException $e) {
+    // 5xx responses
+    error_log(&#39;Server error: &#39; . $e-&gt;getMessage());
</file context>
Suggested change
} catch (\\GuzzleHttp\\Exception\\ServerException $e) {
+} catch (\GuzzleHttp\Exception\ServerException $e) {
Fix with Cubic

try {
$response = $client->get('v1/emails/email_123');
$email = json_decode($response->getBody()->getContents(), true);
} catch (\\GuzzleHttp\\Exception\\ClientException $e) {
Copy link

@cubic-dev-ai cubic-dev-ai bot Nov 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ClientException catch statement escapes the namespace separator twice, making the provided PHP snippet uncompilable. Use single backslashes in the fully qualified class name.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/docs/get-started/php.mdx, line 98:

<comment>ClientException catch statement escapes the namespace separator twice, making the provided PHP snippet uncompilable. Use single backslashes in the fully qualified class name.</comment>

<file context>
@@ -0,0 +1,105 @@
+try {
+    $response = $client-&gt;get(&#39;v1/emails/email_123&#39;);
+    $email = json_decode($response-&gt;getBody()-&gt;getContents(), true);
+} catch (\\GuzzleHttp\\Exception\\ClientException $e) {
+    // 4xx responses
+    error_log($e-&gt;getResponse()-&gt;getBody()-&gt;getContents());
</file context>
Suggested change
} catch (\\GuzzleHttp\\Exception\\ClientException $e) {
+} catch (\GuzzleHttp\Exception\ClientException $e) {
Fix with Cubic

<?php
require __DIR__ . '/vendor/autoload.php';

use GuzzleHttp\\Client;
Copy link

@cubic-dev-ai cubic-dev-ai bot Nov 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use statement shows a double backslash, so copying the snippet yields invalid PHP syntax. Use a single namespace separator when importing GuzzleHttp\Client.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/docs/get-started/php.mdx, line 27:

<comment>`use` statement shows a double backslash, so copying the snippet yields invalid PHP syntax. Use a single namespace separator when importing `GuzzleHttp\Client`.</comment>

<file context>
@@ -0,0 +1,105 @@
+&lt;?php
+require __DIR__ . &#39;/vendor/autoload.php&#39;;
+
+use GuzzleHttp\\Client;
+
+$apiKey = getenv(&#39;USESEND_API_KEY&#39;);
</file context>
Suggested change
use GuzzleHttp\\Client;
+use GuzzleHttp\Client;
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants