hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Namespaces in PHP
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

Namespaces in PHP

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 09-27-2008, 02:03 PM
Sheps Sheps is offline
Community Guide
 
Join Date: Dec 2002
Location: The Shadows
Posts: 2,900

Namespaces in PHP


What do you guys think about namespaces being added to PHP. I personally cannot find any use for them in my coding, but I imagine it will be useful for some people.

__________________
Dan Sheppard ~ Freelance whatever

Reply With Quote


Sponsored Links
  #2  
Old 09-27-2008, 02:10 PM
Steve_Arm Steve_Arm is offline
Community Guide
 
Join Date: Jan 2006
Location: Athens, Greece
Posts: 1,479
The main reason is avoiding conflicts with various libraries integrated in to a project.

__________________


Reply With Quote
  #3  
Old 09-27-2008, 02:10 PM
etogre etogre is offline
Web Hosting Master
 
Join Date: Aug 2003
Location: California, USA
Posts: 579
The main thing I see it being good for is things like the Zend framework, where you have class definitions like:
PHP Code:
class Zend_Auth_Adapter_Http_Resolver_File implements Zend_Auth_Adapter_Http_Resolver_Interface 
That's not to say that Zend will use namespaces, considering their naming conventions are directly based on the directory set up.

Personally, I probably won't have to use them. But I can definitely see a few frameworks taking it on, especially as people shift from PHP4 to the newer versions (It's hard to find a host without PHP5 at this point!)

Reply With Quote
Sponsored Links
  #4  
Old 09-27-2008, 02:12 PM
vibrokatana vibrokatana is offline
Web Hosting Guru
 
Join Date: May 2008
Location: FL
Posts: 337
Quote:
Originally Posted by Sheps View Post
What do you guys think about namespaces being added to PHP. I personally cannot find any use for them in my coding, but I imagine it will be useful for some people.
The main advantage IMO, is to avoid collisions between multiple libraries. If you import two files with the same function name, then you will have a fun time with things.

Reply With Quote
  #5  
Old 09-29-2008, 10:30 AM
Czaries Czaries is offline
Junior Guru
 
Join Date: Aug 2001
Location: Central USA
Posts: 200
I probably won't personally use them, at least not at first. A good class naming convention like Zend uses already addresses this problem, and I have been using that already in my own class library and framework.

It may be helpful in some areas though, like naming Models and Controllers that aren't in the core library and don't really follow the directory naming convention. I could easily see using 'Zend::BlogController' instead of 'BlogController' as being very helpful.

__________________
InvoiceMore - Online Billing & Invoicing
phpDataMapper - Object-Oriented PHP5 Data Mapper ORM

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?