PHP Designing Interfaces in PHP Introducing Interfaces Implementing an Interface

Alexei Parphyonov
Alexei Parphyonov
34,128 Points

Inclusion/Requirement of the Interface

Hi there!

I found it strange that we never included or required one the file with the interface. It that something autoload does? I refollowed the code two times and indeed we never provide path to this file.

The project works as expected, but I tried php filename.php in the terminal for each PHP file in the project, and whenever it is JSONRepository.php, the terminal says: Fatal error: Interface 'RepositoryInterface' not found in /Users/alexeiparphyonov/Desktop/Coding Practices/PHP/Designing Interfaces/src/classes/JSONRepository.php on line 3

Can somebody explain please?

A lot of people have reported this error and I experienced it myself. Make sure that your "interfaces" folder is under the "src" folder and not under your root folder. Once I moved it in there, everything worked as it should.