kanian / containerx

Simple PHP DI Container
4 stars 2 forks source link

Cannot find autoload.php inside an executable phar #1

Open suhaimimansor opened 4 years ago

suhaimimansor commented 4 years ago

I created a executable phar with your code as part of its library using Box. The container could not find the autoload.php file. I added a hack to get around the issue in your Loader.php code:

` <?php namespace Kanian\ContainerX\Loader;

class Loader{

public static function getLoader(){
    if(\Assoa\Loader\Loader::getLoader() === null){
        if(is_file("./vendor/autoload.php")) {
            \Assoa\Loader\Loader::setLoader(require ("./vendor/autoload.php"));
        } else {
            \Assoa\Loader\Loader::setLoader(require (__DIR__."/../../../../autoload.php"));
        }
    }
    return \Assoa\Loader\Loader::getLoader();
}

} `

kanian commented 2 years ago

Hi @suhaimimansor , wow, I'm just seeing the comment now after months. Do you still remember what was your work around?