Problem getting class instantiated

Jump Start PHP Environment Course

database = new medoo([
    'database_type' => 'sqlite',
    'database_file' => '../storage/database.db'
]);

Class not found. I used the instructions given in the book. catfan/medoo is in the vendor folder. Composer.json

Needed to include Medoo/Medoo not in book.

Class names are case sensitive, so new Medoo should work.

1 Like

It did but I also had to drop strong typing in the constructor. By the way, there is also a check that a comment must be greater than 10 chars. “It works” is only nine so an error is thrown.

Have you included composer’s autoloader?

Did that change in PHP 7? At least in PHP 5 class names are case-insensitive.

To be more accurate, the PSR-4 autoloader standard used by composer forces case sensitivity (on most systems!), effectively making class names case sensitive the first time you use them.

I wrote in detail about problems this causes here: https://r.je/php-autoloaders-should-not-be-case-sensitive.html Unfortunately we’re stuck with it. At this point it would be better if PHP enforced case sensitivity.

1 Like

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