Why my Controller Error?

Hello im new in slim,

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

my directory

– routes.php
– Action
— AppAction.php


use App\Action\AppAction;

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



namespace App\Action\AppAction;

class AppAction {

public function index(){

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


"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

Try to dump the autoloader:
composer dump-autoload

its return

Generated autoload files containing 0 classes

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

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.