# Why my Controller Error?

**URL:** <https://discourse.slimframework.com/t/why-my-controller-error/3816>\
**Category:** Questions\
**Created:** [January 26, 2020, 5:53am UTC](https://discourse.slimframework.com/t/why-my-controller-error/3816 "2020-01-26T05:53:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![edsulaiman](https://avatars.discourse-cdn.com/v4/letter/e/85f322/32.png) [@edsulaiman](https://discourse.slimframework.com/u/edsulaiman)\
**Post date:** [January 26, 2020, 5:53am UTC](https://discourse.slimframework.com/t/why-my-controller-error/3816/1 "2020-01-26T05:53:54Z")

</div>

Hello im new in slim,

i have some problem while creating a controller, here’s my code

**my directory**

> config  
> – routes.php  
> public  
> src  
> – Action  
> — AppAction.php

**routes.php**

```
<?php
use App\Action\AppAction;

// Routes Here
$app->get('/', AppAction::class . ':index');

```

**AppAction.php**

```
<?php

namespace App\Action\AppAction;

class AppAction {

public function index(){

    $response->getBody()->write("Hello world");
    return $response;
    }
}

```

**composer.json**

```
"autoload": {
    "psr-4": {
        "App\\": "src/"
    }
}

```

**I Got This error**

> Uncaught RuntimeException: Callable App\Action\AppAction does not exist

all this code gives me a headache, I will be very grateful to anyone who helps me, thank you

---

<div class="post-metadata">

**Author:** ![Manrix](https://avatars.discourse-cdn.com/v4/letter/m/ecb155/32.png) [@Manrix](https://discourse.slimframework.com/u/Manrix)\
**Post date:** [January 26, 2020, 10:08am UTC](https://discourse.slimframework.com/t/why-my-controller-error/3816/2 "2020-01-26T10:08:24Z")

</div>

Try to dump the autoloader:  
`composer dump-autoload`

---

<div class="post-metadata">

**Author:** ![edsulaiman](https://avatars.discourse-cdn.com/v4/letter/e/85f322/32.png) [@edsulaiman](https://discourse.slimframework.com/u/edsulaiman)\
**Post date:** [January 26, 2020, 12:45pm UTC](https://discourse.slimframework.com/t/why-my-controller-error/3816/3 "2020-01-26T12:45:25Z")

</div>

its return

```
Generated autoload files containing 0 classes
```

---

<div class="post-metadata">

**Author:** ![Manrix](https://avatars.discourse-cdn.com/v4/letter/m/ecb155/32.png) [@Manrix](https://discourse.slimframework.com/u/Manrix)\
**Post date:** [January 26, 2020, 1:23pm UTC](https://discourse.slimframework.com/t/why-my-controller-error/3816/4 "2020-01-26T13:23:43Z")

</div>

Have you installed the dependencies ?  
How have you installed slim ?

---

<div class="post-metadata">

**Author:** ![cess11](https://avatars.discourse-cdn.com/v4/letter/c/f1d935/32.png) [@cess11](https://discourse.slimframework.com/u/cess11)\
**Post date:** [January 27, 2020, 8:51am UTC](https://discourse.slimframework.com/t/why-my-controller-error/3816/5 "2020-01-27T08:51:52Z")

</div>

At a glance it looks like the namespace declaration in AppAction.php ought to be App\Action rather than App\Action\AppAction. In the latter case you would reference the AppAction class as App\Action\AppAction\AppAction::class.
