Using Composer with PHP global include path

autoload, composer-php, php

Solution

Did you try this?

"autoload": {
    "psr-0": {"MyLib": "c:\somewhere\project\src"}
}

On Linux soft linking folders would be a possible solution, I don't know if Windows do support it this days or not.

Problem

I was using Zend's autoloader before meeting with Composer. I have got a library (let's call it LibEx) which is in PHP's global include path (`c:\xampp\php\pear`). It must be in a global include folder because a lot of project uses it. So, if I change a function in LibEx every project can access the latest version. And if I want to push my code to server, I simply copy my LibEx folder to `library` folder which is autoloadable by Zend. Before Composer I was using this method: ``` set_include_path(implode(PATH_SEPARATOR, array( realpath(APPLICATION_PATH . '/library'), realpath(APPLICATION_PATH . '/library/Zend'), get_include_path(), ))); include "Zend/Loader/Autoloader.php"; Zend_Loader_Autoloader::getInstance()->registerNamespace('LibEx'); ``` Now I'm in love with Composer. It's really fantastic and I can autoload my project specific library with it too: ``` "autoload": { "psr-0": {"MyLib": "src/"} } ``` But how can I autoload LibEx folder which is not in the DocumentRoot or WebRoot? And how to still autoload even if it's in server and copied under `src` folder?

Original source