php.tsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import ExternalLink from 'sentry/components/links/externalLink';
  2. import {Layout, LayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/layout';
  3. import {ModuleProps} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation';
  4. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  5. import {t, tct} from 'sentry/locale';
  6. // Configuration Start
  7. export const steps = ({
  8. dsn,
  9. }: Partial<Pick<ModuleProps, 'dsn'>> = {}): LayoutProps['steps'] => [
  10. {
  11. type: StepType.INSTALL,
  12. description: (
  13. <p>
  14. {tct(
  15. 'To install the PHP SDK, you need to be using Composer in your project. For more details about Composer, see the [composerDocumentationLink:Composer documentation].',
  16. {
  17. composerDocumentationLink: (
  18. <ExternalLink href="https://getcomposer.org/doc/" />
  19. ),
  20. }
  21. )}
  22. </p>
  23. ),
  24. configurations: [
  25. {
  26. language: 'bash',
  27. code: 'composer require sentry/sdk',
  28. },
  29. ],
  30. },
  31. {
  32. type: StepType.CONFIGURE,
  33. description: t(
  34. 'To capture all errors, even the one during the startup of your application, you should initialize the Sentry PHP SDK as soon as possible.'
  35. ),
  36. configurations: [
  37. {
  38. language: 'php',
  39. code: `\\Sentry\\init(['dsn' => '${dsn}' ]);`,
  40. },
  41. ],
  42. },
  43. {
  44. type: StepType.VERIFY,
  45. description: t(
  46. 'In PHP you can either capture a caught exception or capture the last error with captureLastError.'
  47. ),
  48. configurations: [
  49. {
  50. language: 'php',
  51. code: `
  52. try {
  53. $this->functionFailsForSure();
  54. } catch (\\Throwable $exception) {
  55. \\Sentry\\captureException($exception);
  56. }
  57. // OR
  58. \\Sentry\\captureLastError();
  59. `,
  60. },
  61. ],
  62. },
  63. ];
  64. // Configuration End
  65. export function GettingStartedWithPHP({dsn, ...props}: ModuleProps) {
  66. return <Layout steps={steps({dsn})} {...props} />;
  67. }
  68. export default GettingStartedWithPHP;