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 trialMister Moody
48,333 PointsImplementing an Interface
Hey ya'll,
I'm stuck up a creek without a paddle. I have reviewed the code and all looks well, but I get this:
PHP Fatal error: Interface 'RepositoryInterface' not found in /home/treehouse/workspace/src/classes/jsonRepository.php on line 3
If you have some time to spare, I kindly ask that you preview my snapshot
Woke up today with this on my mind and with a few moments to share learned that in the config.php
file, when I remove the final line that instantiates the $repo
class, no error occurs, so at the moment I am led to believe that
$repo = new jsonRepository(__DIR__ . '/database.json');
is the issue~
2 Answers
Mister Moody
48,333 PointsTried your suggestion @benpayne0925, to no avail. Nonetheless, I appreciate your support!
Ben Payne
1,464 PointsSo...don't get too mad, but the RepositoryInterface
in your snapshot is misspelled. See below:
<?php
interface RespositoryInterface { // RepositoryInterface is mispelled.
/* Retrieve ALL Items */
public function all($entity);
/* Retrieve a Single-Item */
public function find($entity, $id, $field = 'id');
}
?>
I removed the extra s and it seems to work now.
Cheers,
Ben
Mister Moody
48,333 PointsThanks Ben. Not beating myself up; grateful you were here to assist! I owe you a beer~ hit me up if you are ever in (Louisville) Kentucky!
Ben Payne
1,464 PointsBen Payne
1,464 PointsHey MM - It looks like in your autoloader you are breaking the loop once you find the first class? Maybe try looping through everything and try again?