Categories


Archives


Recent Posts


Categories


Tip for PHP Namespace Newbies

astorm

Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

If Magento 2 is your first introduction to PHP namespaces, here’s one small thought technology that might help. Consider the following

namespace FooBaz;
class Bar {
}

The above does not define a class named Bar. It defines a class named “FooBazBar”. That’s how PHP sees the class internally, and once you start thinking about classes the same way PHP does, they start making more sense, (or, at least, they did for me)

Copyright © Alana Storm 1975 – 2023 All Rights Reserved

Originally Posted: 24th December 2014

email hidden; JavaScript is required