Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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.