Skip to content

Loading…

DCOM-48: Autoloading with a namespace is very restricted #648

Closed
doctrinebot opened this Issue · 4 comments

2 participants

@doctrinebot

Jira issue originally created by user matthieu:

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

@doctrinebot

Comment created by matthieu:

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

@doctrinebot

Comment created by @guilhermeblanco:

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,

@doctrinebot

Issue was closed with resolution "Invalid"

@doctrinebot

Comment created by @beberlei:

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

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.