Comments (4)
Actually, since PSR-0 is backward-compatible with PEAR, it is supported. You just need to do prefix matching:
$loader = new ClassLoader();
$loader->add('Twig_', __DIR__.'/vendor/twig/lib');
$loader->add('Symfony\\', __DIR__.'/vendor/symfony/src');
$loader->register();
The current loader does support multiple directories per namespace, you just need to set them in the initial add() call. Being able to add others later is a detail, and could easily be added.
from composer.
Another argument to generate a map instead of the autoloader: PHP 5.4 is likely to have an SplClassLoader which will probably be more efficient than PHP implementations so it should be possible to use it.
from composer.
As per Igor, the class loader in composer is just as powerful as the Symfony2 one, it's just a lot simpler. However I agree that generating just the map in case someone wants to use their own autoloader, but the default mappings, makes sense. So I would simply generate both. One file with the mappings, one file with a default autoloader and one file which adds the map entries to the default auto loader. A project can then decide on its own which file(s) to include.
from composer.
@fabpot: As @igorw said, it is compatible with PEAR. The implementation is more than sufficient imo. The fallbacks and such can easily be done in a second autoloader if that is required, but IMO it'd be just as easy to allow users to configure their namespaces in their composer.json file too. Usually you have only one namespace in the src/ dir anyway.
@stof: You may have noticed that I used add() and register() which AFAIK are the proposed method names for the SplClassLoader (the new version, not the one in the RFC). The point being that we could just use the php one if it's available, once it's merged. Whatever happens with that I'll definitely keep our autoloader in sync. I want it to be a fallback implementation and that's it. Unless the one in core is really not made flexible enough, in which case we can still extend from it or wrap it to speed things up a bit.
Another thing regarding generating a map, I don't really like this too much because I don't think every single project should have an autoloader. It's just commodity stuff that should be given for free. What I would like to do though is have a command that will generate a hardcoded MapClassLoader-like thing on demand. For production this would be nice.
from composer.
Related Issues (20)
- Mercurial repository type doesn't allow for SSH URLs HOT 5
- symfony/console should be updated to fix color detection
- `http_proxy` is used for `https://` URLs HOT 8
- in swoole projects, class_exists() causes "include" the same class more than once HOT 4
- Unable to resolve circular dependency HOT 3
- Tilde/Caret versioning range and specifying the stability like ^x.y.*-dev HOT 5
- Invalid JSON returned by composer show --format=json since Composer 2.7.2 HOT 5
- [feature] Build and distribute scoped version of Composer HOT 2
- wpackagist.org wordpress plugins are not installed with composer 2.7.2 HOT 5
- JSON Format when sending to discord like discohook HOT 4
- Update schema for version value HOT 1
- Surface remote IDs for advisories without a CVE so they can be ignored HOT 2
- 'requirements-checker' does not run on windows HOT 1
- I can't install composer HOT 1
- Composer validate: keywords invalid value, must match regex HOT 3
- Composer install issue Cannot authenticate with bitbucket repository
- [feature] Add native NPM support HOT 3
- Windows 11/PHP8.3.3 install fails - missing or invalid info (exit code -1073741643) HOT 1
- Invalid package information: funding.1.url HOT 2
- Cannot install 3.0 with new Symfony project HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from composer.