Urgent slim 3.8 does not recognize my classes and neither my Actions and middleware

Hello, I’m a beginner with framework
Slim in version 3.8 when it recognizes my middleware and neither my class
They are with correct namespace

Slim Application Error
The application could not run because of the following error:

Details

Type: RuntimeException
Message: Callable App \ Middleware \ Admin \ AuthMiddleware does not exist
File: C: \ Program Files (x86) \ EasyPHP-DevServer-14.1VC11 \ data \ localweb \ SIGA \ vendor \ slim \ slim \ Slim \ CallableResolver.php
Line: 90
Trace

You do need to post the code so people can help you.

Also, have you run composer dump after creating your middleware?

1 Like

Yes the modfleware was created first. Because it was from another project I copied the structure and the actions and then I downloaded the slim / slim depis I installed the views

again, am not sure how people can help without even see the code?

Usa o vendor 3.8

you need to fix your PSR4 section as the autoloader has no idea how to load your Classes http://d.zah.me/ckgIK8/9DzpzMiL

{
"require": {
    "slim/slim": "^3.8",
    "slim/php-view": "^2.2"
},
	"autoload": { 
		"psr-4": { 
			"":"Classes/",
            "App":"app/"
		} 
	}
}

From what I see I do advice you that you learn more about Composer and how to use it to Autoload your Classes

as you can see its working after I added App to the autoloader

This composer is the same way of a previous project and it was running i will study more about composer

This from of autoloaf is correct
"autoload": {
“psr-4”: {
"":“Classes/”,
“App”:“app/”
}
}

Or you charged more things

you code didnt have "App":"app/" which tells composer to autoload the classes under then name space App.

Mostly the other project that you have done, has a different structure and all the code was under Classes thats why it was working there.

I keep on giving error
A non-empty PSR-4 prefix must end with a namespace separator

Give me this project that is with you to see if it works