Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.