Namespace issue with PhpAuth

Hi guys,

I’m using Composer for the first time in a PHP project because I wanted to give PhpAuth a try. I’ve used the handy PhpStorm Composer tool to add PhpAuth to my project:

In my index.php, I’ve added this to the top:

However, when I visit index.php in my browser, I’m getting the error
Fatal Error: Class 'ZxcvbnPhp\Zxcvbn' not found in ../vendor/phpauth/phpauth/Auth.php on line 178

It seems to be a namespacing error. Can anyone shed some light on this issue?

Use require instead of include. What is the result?

First line should be:

require ('../vendor/autoload.php');

Need that so namespaced classes can be found.

And you probably won’t need the leading back slash on your classes. Might take a look at the namespace use statement: http://php.net/manual/en/language.namespaces.importing.php

2 Likes

Thanks! I’ve added the autoload line and left everything as it was and the class seems to be working now!

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.