# C3 routes on slim's API

**URL:** <https://discourse.slimframework.com/t/c3-routes-on-slims-api/771>\
**Category:** Questions\
**Created:** [September 29, 2016, 6:45pm UTC](https://discourse.slimframework.com/t/c3-routes-on-slims-api/771 "2016-09-29T18:45:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Horvat82](https://avatars.discourse-cdn.com/v4/letter/h/7ea924/32.png) [@Horvat82](https://discourse.slimframework.com/u/Horvat82)\
**Post date:** [September 29, 2016, 6:45pm UTC](https://discourse.slimframework.com/t/c3-routes-on-slims-api/771/1 "2016-09-29T18:45:27Z")

</div>

Hello, [here](https://github.com/Horki/remotecoverage/tree/master/api) I have my simple API that I would like to have code coverage

Routes that I want provide by [this](https://github.com/Codeception/c3#predefined-routes)

- c3/report/clover
- c3/report/serialized
- c3/report/html
- c3/report/clear

```auto
$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?

ex:

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

```

---

<div class="post-metadata">

**Author:** ![llvdl](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/llvdl/32/78_2.png) [@llvdl](https://discourse.slimframework.com/u/llvdl)\
**Post date:** [October 1, 2016, 4:53pm UTC](https://discourse.slimframework.com/t/c3-routes-on-slims-api/771/2 "2016-10-01T16:53:39Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![Horvat82](https://avatars.discourse-cdn.com/v4/letter/h/7ea924/32.png) [@Horvat82](https://discourse.slimframework.com/u/Horvat82)\
**Post date:** [October 2, 2016, 2:51pm UTC](https://discourse.slimframework.com/t/c3-routes-on-slims-api/771/3 "2016-10-02T14:51:00Z")

</div>

Hej, it still throws 404 error

---

<div class="post-metadata">

**Author:** ![llvdl](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/llvdl/32/78_2.png) [@llvdl](https://discourse.slimframework.com/u/llvdl)\
**Post date:** [October 2, 2016, 6:58pm UTC](https://discourse.slimframework.com/t/c3-routes-on-slims-api/771/4 "2016-10-02T18:58:39Z")

</div>

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](https://github.com/Codeception/c3#predefined-routes) you provided correctly, you need to include the `c3.php` file at the start of your front controller (`index.php`):

```php
<?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) {
    // ...
});

$app->run();

```

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](https://github.com/Codeception/c3#debug) in the c3 documentation for instructions on removing this check and enabling debugging.

---

<div class="post-metadata">

**Author:** ![Horvat82](https://avatars.discourse-cdn.com/v4/letter/h/7ea924/32.png) [@Horvat82](https://discourse.slimframework.com/u/Horvat82)\
**Post date:** [October 3, 2016, 4:44pm UTC](https://discourse.slimframework.com/t/c3-routes-on-slims-api/771/5 "2016-10-03T16:44:16Z")

</div>

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

> **[Horki/remotecoverage](https://github.com/Horki/remotecoverage)**
>
> Remote code coverage with codeception. Contribute to Horki/remotecoverage development by creating an account on GitHub.
