Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2002
    Location
    The Shadows
    Posts
    2,925

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Athens, Greece
    Posts
    1,481
    The main reason is avoiding conflicts with various libraries integrated in to a project.

  3. #3
    Join Date
    Aug 2003
    Location
    California, USA
    Posts
    582
    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!)

  4. #4
    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.

  5. #5
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •