Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Fatal error: Uncaught Error: Class 'Slim\\Middleware\\HttpBasicAuthentication' not found #61

Closed
fernandocassola opened this issue Apr 18, 2018 · 7 comments

Comments

@fernandocassola
Copy link

Im having a strange error.

On my localhost (windows10 with xampp) all my slim api is working fine, but when i put it on my server (ubuntu) i've got the error:
PHP Fatal error: Uncaught Error: Class 'Slim\Middleware\HttpBasicAuthentication' not found /var/www/html ...

Some useful notes:
My composer.php
{
"require": {
"slim/slim": "^3.9",
"tuupola/slim-basic-auth": "^3.0",
"slim/middleware": "*",
"firebase/php-jwt": "^5.0",
"tuupola/slim-jwt-auth": "^3.0",
"tuupola/base62": "^0.10.0",
"tuupola/cors-middleware": "^0.7.0"
}
}

My bootstrap.php
$app->add(new \Tuupola\Middleware\HttpBasicAuthentication([

"users" => [
    "root" => "toor"
],
"path" => ["/"],
/**
 * Whitelist - Protege todas as rotas e só libera as de dentro do array
 */
"passthrough" => ["/auth"]

]));

Can you please give some tips?
Thank you

@tuupola
Copy link
Owner

tuupola commented Apr 18, 2018

The error message has a filename and a line number. What is the code in that line?

@fernandocassola
Copy link
Author

First of all, thank you for your attention.
Here is the complete error line:
[:error] [pid 26751] [client 193.136.33.222:10400] PHP Fatal error: Uncaught TypeError: Return value of Tuupola\Middleware\HttpBasicAuthentication::uservoid, none returned in /var/www/html/api/vendor/tuupola/slim-basic-auth/src/HttpBasicAuthentication.php:236\nStack trace:\n#0 [internal function]: Tuupola\Middleware\HttpBasicAuthenticatiupola/slim-basic-auth/src/HttpBasicAuthentication.php(171): call_user_func(Array, Array)\n#2 /var/www/html/api/vendor/tuupola/slim-basic-auth/src/HttpBasicAuthentication.php(55): Tuupola\My)\n#3 /var/www/html/api/public/bootstrap.php(13): Tuupola\Middleware\HttpBasicAuthentication->__construct(Array)\n#4 /var/www/html/api/public/index.php(8): require('/var/www/html/a...')/tuupola/slim-basic-auth/src/HttpBasicAuthentication.php on line 236

Many thanks

@tuupola
Copy link
Owner

tuupola commented Apr 19, 2018

This is different error. In the original post the error you mentioned was:

Uncaught Error: Class 'Slim\Middleware\HttpBasicAuthentication' not found

This error message is above is.

PHP Fatal error: Uncaught TypeError: Return value of Tuupola\Middleware\HttpBasicAuthentication::uservoid, none returned in...

It looks like the output is garbled or there is a copy paste mistake. The HttpBasicAuthentication::uservoid part does not make any sense. In any case the error message you posted in the last message looks similar to #60. Which PHP version you are running? Minimum requirement is PHP 7.1.

@fernandocassola
Copy link
Author

Yeah, you're right. Sorry for the cross error!

The first one i've just solutionated :)

Now reggarding to the other :
PHP Fatal error: Uncaught TypeError: Return value of Tuupola\Middleware\HttpBasicAuthentication::uservoid, none returned in...

On my developer machine (xampp) it's working fine, when i put it on my server (LINUX - PHP 7.1.16-1+ubuntu16.04.1+deb.sury.org )
It gives me that error!!!

Can you please help me?
Im desesperated right now ....

@fernandocassola
Copy link
Author

My bootstrap.php code is:

...
`$app->add(new Tuupola\Middleware\HttpBasicAuthentication([

// "users" => [
// "root" => "toor"
// ],
"path" => ["/"],
"secure" => false, // HTTPS -ATTENTION
"passthrough" => ["/auth", "/generatepass"],
"authenticator" => new PdoAuthenticator([
"pdo" => $pdo,
"table" => "user",
"user" => "username",
"hash" => "password"
])

]));`

@tuupola
Copy link
Owner

tuupola commented Apr 19, 2018

The error message has a filename and a line number. What is the code in that line? Other way to ask this is, you mention above that error message is:

Uncaught TypeError: Return value of Tuupola\Middleware\HttpBasicAuthentication::uservoid, none returned in /var/www/html/api/vendor/tuupola/slim-basic-auth/src/HttpBasicAuthentication.php:236

What is the contents of the file /var/www/html/api/vendor/tuupola/slim-basic-auth/src/HttpBasicAuthentication.php at line 236?

@fernandocassola
Copy link
Author

Thank you for your sugestion.
I've reinstaled the slim and Authentication on the linux server and all worked well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants