man in grey sweater holding yellow sticky note

Namespaces, explained.

As it turns out, this was way easier than I thought it’d be. Also, if you ever want a programming analogy, just use Humans or People. Works every time.

Let’s say you have a person named Jane. That’s great, as long as she’s the only Jane. But then, another Jane shows up! WHAT DO? On paper, this is tough. If you’re in person you’d be like well Jane 1 has brown hair, and Jane 2 has blond hair. But, if all we have is the name “Jane” to go by, what now? Why not just identify them by their last name? Jane Doe, and Jane Smith. BAM! Namespaces.

Basically in programming terms – Namespaces are a way to group classes together to identify them, and it’s super helpful when you may have classes that are named the same way (or there are multiple people working on the same program or project).

This site does a great job describing PHP Namespaces – why re-invent the wheel?

They also have a learn PHP track on this site – I may watch this after I’m done with my current track and see if it fills in some blanks.

Author: Greg
Middle-aged father of two - still a kid at heart! Lover of all things geeky, trivia, factoids, craft beers, and procrastination. #SnorlaxIsMySpiritAnimal. #CanadianEh! "I don't know. Fly casual."

Leave a Reply