News Feed
Jobs Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

PHPBuilder.com:
Introducing Namespaces for PHP Developers
September 22, 2011 @ 10:13:05

On PHPBuilder.com today there's a new article from Jason Gilmore introducing you to namespaces in PHP 5.3+ development. Namespaces make it simpler to separate out your code into functional pieces and help keep it organized.

The inclusion of namespace support within PHP 5.3 effectively brought the need for gripes and workarounds to a halt, however adoption of this exciting new feature has seemed surprisingly slow in the more than two years since its release. [...] The utility of this new feature is simply undeniable. Therefore I thought it would be worthwhile to offer a formal introduction to namespaces for the benefit of those PHP developers who haven't yet had the opportunity to investigate the topic.

He starts by introducing the concept of a "namespace" as a sort of container for your code, providing separation that prevents errors like the infamous "cannot redeclare class" issue. He includes examples of PHP's namespace syntax to split out two "Account" classes into two different sections. Using them is as easy as referring to them by their namespaced "path" or using something like the "use" keyword to reassign it to another name.

0 comments voice your opinion now!
namespace introduction separation


blog comments powered by Disqus

Similar Posts

SitePoint PHP Blog: Building a Web App With Symfony 2: Development

Ryan Gantt's Blog: Horizontal reusability with traits in PHP 5.4

Stefan Koopmanschap's Blog: Using custom namespaces with (C/S)ilex and Composer

Lukas Smith's Blog: Who is using namespaces in PHP already?

Mike Naberezny's Blog: My First php|architect Article (Zend Framework)


Community Events











Don't see your event here?
Let us know!


introduction podcast hack application install example unittest overview opinion security symfony2 hhvm language framework component release package code composer facebook

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework