-
-
Notifications
You must be signed in to change notification settings - Fork 253
docs: add PHP getting started guide #295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Deploying usesend with
|
| Latest commit: |
45c89cb
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://dc0e6045.usesend.pages.dev |
| Branch Preview URL: | https://codex-create-getting-started.usesend.pages.dev |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThis pull request adds PHP documentation to the Getting Started section. It includes a new page in the documentation navigation ( Pre-merge checks✅ Passed checks (3 passed)
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. Comment |
There was a problem hiding this 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:
- API key validation:
getenv('USESEND_API_KEY')could fail silently if the environment variable is missing.- 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
RequestExceptionas 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
📒 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
fromaddress 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.
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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->getResponse()->getBody()->getContents());
+} catch (\\GuzzleHttp\\Exception\\ServerException $e) {
+ // 5xx responses
+ error_log('Server error: ' . $e->getMessage());
</file context>
| } catch (\\GuzzleHttp\\Exception\\ServerException $e) { | |
| +} catch (\GuzzleHttp\Exception\ServerException $e) { |
| try { | ||
| $response = $client->get('v1/emails/email_123'); | ||
| $email = json_decode($response->getBody()->getContents(), true); | ||
| } catch (\\GuzzleHttp\\Exception\\ClientException $e) { |
There was a problem hiding this comment.
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->get('v1/emails/email_123');
+ $email = json_decode($response->getBody()->getContents(), true);
+} catch (\\GuzzleHttp\\Exception\\ClientException $e) {
+ // 4xx responses
+ error_log($e->getResponse()->getBody()->getContents());
</file context>
| } catch (\\GuzzleHttp\\Exception\\ClientException $e) { | |
| +} catch (\GuzzleHttp\Exception\ClientException $e) { |
| <?php | ||
| require __DIR__ . '/vendor/autoload.php'; | ||
|
|
||
| use GuzzleHttp\\Client; |
There was a problem hiding this comment.
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 @@
+<?php
+require __DIR__ . '/vendor/autoload.php';
+
+use GuzzleHttp\\Client;
+
+$apiKey = getenv('USESEND_API_KEY');
</file context>
| use GuzzleHttp\\Client; | |
| +use GuzzleHttp\Client; |
Summary
Issues
Screenshots
Migrations
Verification
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.
Written for commit 45c89cb. Summary will update automatically on new commits.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.