Skip to main content

To PHP Namespace or not to PHP Namespace



ok, I'm relatively new to PHP programming and have been plodding along quite unaware that it is possible to actually use namespaces in PHP as I can in c# etc.





It's really ugly though as they have decided to use backslashes - why!?





Anyway, I am interested in other PHP programmers' views on whether namespaces will catch on in PHP and whether I should begin to use them now?



Source: Tips4all

Comments

  1. Unless all your code runs on your own servers, it's too early to start using them as 5.3 is relatively new.

    Other than that, I'm not sure if they will ever really catch on. Even classes took a long time to catch on with a large portion of the PHP programming population.

    ReplyDelete
  2. Its use is already catching on. A couple of projects use it in their upcoming/beta versions. Most examples I've seen however use it like a cargo cult. Doctrine2 for example uses five or more nested namespaces (code smell), probably to provide a 1:1 mapping of namespace/class to the filesystem/directories. I guess the novelty makes PHP namespaces prone to unreasoned overuse.

    Anyway, the syntax doesn't help with readability that much. And it's a big turn off for professional programmers. But if there is a serious use case in your project, just go for it. (Hypothetical naming conflicts are not the best reason.)

    ReplyDelete
  3. They will most likely not catch on until the core starts using them (in PHP 7 maybe possibly perhaps...), but using Python for a few months will show you that namespaces are AWESOME.

    ReplyDelete
  4. I would start learning how to use namespaces as soon as possible. Zend Framework 2.0 will use namespaces, which will mean that anyone using PHP 5.2 or lower will be out of luck. I use a virtual dedicated server, so I can control my PHP version. If you use cPanel/WHM, you can install PHP 5.3 very easily. If you are on shared hosting, it may be a little bit before you see 5.3 installed, although there are 5.3 adopters out there.

    ReplyDelete
  5. hey look up this wesite for programmers...www.countcode.com, i worked be myself for 5 months to make it run...you can share and download codes, ask or answer forum questions, and you can count your code lines from your whole life of programming, sincerely Emi

    ReplyDelete

Post a Comment

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?