Debugging

Learn how to debug your integration.

If you are experiencing issues with your integration, there are a few things you can do to diagnose the problem.

Croct's mascot winking
Need help?

If you have any questions, please contact us for assistance or join our community to get help from our team and other users.

Enable logging

The SDK reports internal failures through a PSR-3 logger. Provide one when you create the SDK to capture what happens during a request:

12345678910
<?phpuse Croct\Plug\Croct;use Croct\Plug\CookieStorage;
$croct = Croct::plug(    appId: 'APPLICATION_ID',    apiKey: 'API_KEY',    storage: CookieStorage::fromGlobals(),    logger: $logger,);

The logged messages help you detect and diagnose issues such as failed requests or misconfiguration.

Inspect the errors

When a request fails and no fallback is set, the SDK throws a CroctException. Catch it to log or inspect the failure:

1234567891011
<?phpuse Croct\Plug\Croct;use Croct\Plug\Exception\CroctException;
$croct = Croct::fromDotenv();
try {    $content = $croct->fetchContent('home-hero')->getContent();} catch (CroctException $error) {    error_log('Croct error: ' . $error->getMessage());}

For resilience, provide a fallback so personalization failures never break your application.