Skip to content
Codeskop

PHP

codeskop/codeskop-php captures errors, incoming requests and outgoing API calls from PHP 8.1 and later. No runtime dependencies, and nothing is sent until your response has gone out.

Supported frameworks

Version 0.1. Laravel 10 and later (including Octane and queue workers), plain PHP and Guzzle 7.

Install

Terminal
composer require codeskop/codeskop-php

Laravel

The service provider is discovered automatically. Add your project's public key:

.env
CODESKOP_API_KEY=cs_live_pk_…

That's all. Codeskop now:

  • reports exceptions through Laravel's handler, skipping anything in dontReport (404s, validation errors);
  • records every request by route (/api/orders/{order}) with the signed-in user's ID;
  • records calls made with the HTTP client (Http::get(…)).

To change the defaults, publish the config with php artisan vendor:publish --tag=codeskop-config.

Plain PHP

Call init at the top of your front controller. It reports uncaught exceptions (keeping any handler you already have), fatal errors including out-of-memory, and records the request.

index.php
<?phprequire __DIR__ . '/vendor/autoload.php'; \Codeskop\Codeskop::init(['api_key' => getenv('CODESKOP_API_KEY')]); // Optional: name the route of this request (otherwise IDs in the path become {id}).\Codeskop\Codeskop::setRoute('/orders/{id}');

Report errors yourself

use Codeskop\Codeskop; try {    $payments->charge($order);} catch (PaymentException $e) {    Codeskop::captureException($e, tags: ['provider' => 'stripe']);} Codeskop::captureMessage('Inventory sync skipped');Codeskop::setUser((string) $user->id); // your own ID, never an email

Outgoing calls with Guzzle

$stack = \GuzzleHttp\HandlerStack::create();$stack->push(\Codeskop\Guzzle\Middleware::create()); $http = new \GuzzleHttp\Client(['handler' => $stack]);

How events are sent

Under PHP-FPM, events are sent after the response is complete, so your users never wait on Codeskop. Queue workers and Octane send after each job or request. Remote settings are cached between requests in APCu when it's installed, otherwise in a small file in the system temp directory. ext-curl is recommended.

Options

OptionTypeDefaultDescription
api_keystringCODESKOP_API_KEYThe project's public key. Secret keys are refused and the SDK stays off.
environmentstringproductionLaravel uses APP_ENV. Env var CODESKOP_ENVIRONMENT.
releasestringautoAuto-detected from common hosts and CI. Env var CODESKOP_RELEASE.
capture_requests / capture_outgoingbooltrueIncoming requests / outgoing calls.
ignore_routesarrayhealth checksGlob patterns never recorded.
ignore_exceptionsarray[]Exception classes never sent.
before_sendcallablenullEdit or drop any event before it's sent.
send_user_idbooltrueAttach the signed-in user's ID.
flush_timeoutfloat2.0Seconds to spend sending at the end of a request.
debugboolfalseLog what the SDK does (to error_log).

Privacy

Never captured: request or response bodies, cookies, Authorization headers and query strings. See Privacy & Security.