04.
Namespaces make Class Names Longer
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
Whoops, an error! Please, try again later.
6 Comments
In challenge #4, the code example in the question contains:
namespace Model\Planet.Should that be a semicolon instead of a period?
Hey Brian!
Nice catch! that's definetely a mistake from our part, that should be a semicolon as you said, we will fix it as soon as we can
Have a nice day!
Hi!
I noticed the solution to challenge #1 on this video is incorrect. The RandomlyColoredPlanet implements PlanetInterface but of course PHP is looking for that interface in the namespace 'Model\Planet' and can't find it.
So, it needs to be:
I would have created a pull request on github for this but couldn't find where the challenge code was kept.
Edit:
Looking more closely it looks like a use PlanetInterface was used at the top of the class. Assuming this works the same as above?
Hey Syed,
Thanks for this report! Yes, it's the same. You need to use a full namespace of a class or you could add a use statement for the class and then use its class name. You'll find more info about use statement in this and More Fun with use Statements next chapter. Actually, it was a one more subtask you should solve in that challenge.
Cheers!
It seems that at this point I wasn't able to solve this coding challenge without the hint. But good to know that others do have the same problems. I am not alone ;)
Hey guys!
Yes, this challenge is a bit tricky, but valid! :) Because you get a clear message:
> Fatal error: Interface 'Model\Planet\PlanetInterface' not found in RandomlyColoredPlanet.php on line 5
And it's a very common problem when devs forget leading slashes for namespaces in some cases like this one, so I think it's good you were caught by it and understood the problem. It's important to read and understand error messages :)
Cheers!
"Houston: no signs of life"
Start the conversation!