C3 routes on slim's API

Hello, here I have my simple API that I would like to have code coverage

Routes that I want provide by this

  • c3/report/clover
  • c3/report/serialized
  • c3/report/html
  • c3/report/clear
$app->get('/test', function () use ($app) {
    $app->render(200, [
        'status' => 200,
        'data'   => 'this is some test',

is there a any way to provide router for c3 endpoints with SLIM?


$app->get('/c3/*', function () use ($app) {
    // render a php file
    $app->load(__DIR__ . '../c3.php');

If you want a route for all GET request starting with /c3/, you can do the following:

$app->get('/c3/{path:.*}', function($request, $response, $args) use ($app) {
    // render a php file
    $app->load(__DIR__ . '../c3.php');

Hej, it still throws 404 error

Hello Horvat,

The route should work just fine. But you probably don’t want a Slim defined route for the c3 routes. Those are handled by c3.php.

If I understand the documentation for c3 you provided correctly, you need to include the c3.php file at the start of your front controller (index.php):


require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/c3.php'; // c3.php will add the /c3/report/* routes

$app = new \Slim\App();

$app->get('/test', function($request, $response) use ($app) {
    // ...


Note that if you try to call the /c3/report/* routes using your browser, you will get a 404 error. This is because the route is only handled by c3 if the X_CODECEPTION_CODECOVERAGE header is included in the request. See the debug section in the c3 documentation for instructions on removing this check and enabling debugging.

1 Like

Thank you works now, I had a bit different slim setup