RuntimeException , Callable does not exist


#1

Hi,
I am new to Slim framework.
I was trying the tutorial for the basic setup. Successfully run a sample project.

While trying to separate the functionality in different classes and trying to load it with composer setting

"autoload": {
		"psr-4": {
		    "": "src/"
		}
	}

And finally using it as

$app->get('/route/', \Rain\AppEntry::class . ':home');

I am getting Slim Application Error as Type: RuntimeException Message: Callable Rain\AppEntry does not exist

The class which is at src/AppEntry.php looks like

<?php

namespace Rain;


use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;

class AppEntry
{
    public function home(Request $request, Response $response, $args)
    {
        return 'Home from AppEntry';
    }
}

The folder structure is as below

public
  home.php
src
  AppEntry.php
vendor

I am working on a Windows machine with XAMPP.

Any help would be a nice help.
thanks


#2

your autoload setting is wrong according to psr4 - your are using namespace Rain in your code but you defined that /src is without namespace

"autoload": {
		"psr-4": {
		    "Rain\\": "src/"
		}
	}

than run

 composer dump-autoload

make sure you have vendor/autoload.php required in your home.php


#3

Thanks!

The thing that did the trick is

php composer.phar dump-autoload