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
Unless all your code runs on your own servers, it's too early to start using them as 5.3 is relatively new.
ReplyDeleteOther 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.
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.
ReplyDeleteAnyway, 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.)
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.
ReplyDeleteI 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.
ReplyDeletehey 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