Uploaded image for project: 'Doctrine Common'
  1. Doctrine Common
  2. DCOM-48

Autoloading with a namespace is very restricted

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Invalid
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Class Loading
    • Security Level: All
    • Labels:
      None

      Description

      Sorry for the vague title of the issue, but here is the problem:

      $classLoader = new ClassLoader('Tests', '/basePath/tests');

      If I want to autoload \Tests\Class1, it will look for /basePath/tests/Tests/Class1.php.

      I would like it to load: /basePath/tests/Class1.php. i.e., the namespace registered is removed from the path.

      Do you see what I mean ? Zend Framework autoloader allow this behavior, I am surprised the Doctrine autoloader doesn't allow that.

      Thanks

        Activity

        Hide
        matthieu Matthieu Napoli added a comment -

        Hi, any news on this ?

        I'd like to know if this is going to be corrected some day, or if I should not wait for it and find another solution ?

        Thank you

        Show
        matthieu Matthieu Napoli added a comment - Hi, any news on this ? I'd like to know if this is going to be corrected some day, or if I should not wait for it and find another solution ? Thank you
        Hide
        guilhermeblanco Guilherme Blanco added a comment -

        Hi,

        Zend Framework (v1) does not follow PSR-0 (http://groups.google.com/group/php-standards/web/psr-0-final-proposal) so it does whatever it wants.
        Second version of Zend Framework is PSR-0 compliant, so your wish will probably fail too.

        Let me explain what is the deal: Every single project, no matter what it is, can be contained in a package (aka. namespace in PHP). This means that:

        library
        - Controller.php
        - Controller/
          - Action.php
        

        Is plain wrong. Why? Because it's part of a project (Your app (Application), Zend, Doctrine, Symfony, etc).
        Due to this, PSR-0 stricts that it only loads namespaced classes, and nothing else. It was an agreement between 18 big PHP projects, including ZF, Symfony, Lithium, CodeIgniter, etc.

        Cheers,

        Show
        guilhermeblanco Guilherme Blanco added a comment - Hi, Zend Framework (v1) does not follow PSR-0 ( http://groups.google.com/group/php-standards/web/psr-0-final-proposal ) so it does whatever it wants. Second version of Zend Framework is PSR-0 compliant, so your wish will probably fail too. Let me explain what is the deal: Every single project, no matter what it is, can be contained in a package (aka. namespace in PHP). This means that: library - Controller.php - Controller/ - Action.php Is plain wrong. Why? Because it's part of a project (Your app (Application), Zend, Doctrine, Symfony, etc). Due to this, PSR-0 stricts that it only loads namespaced classes, and nothing else. It was an agreement between 18 big PHP projects, including ZF, Symfony, Lithium, CodeIgniter, etc. Cheers,
        Hide
        beberlei Benjamin Eberlei added a comment -

        You can use any autoloader you want for your own classes, the Doctrine one is just focused on namespaces becuse Doctrine only uses namespaces.

        Show
        beberlei Benjamin Eberlei added a comment - You can use any autoloader you want for your own classes, the Doctrine one is just focused on namespaces becuse Doctrine only uses namespaces.

          People

          • Assignee:
            beberlei Benjamin Eberlei
            Reporter:
            matthieu Matthieu Napoli
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: