Zend Framework 2 - Composer - Manual installation

2019-08-01 05:30发布

问题:

I wrote an own library and included it manually in my composer/autoload_namespaces.php like I was told here.

It works fine until I use the install or update command. Then this line is removed and I get an error when trying to use the lib.

Any ideas how to prevent this?

回答1:

The suggestions you got in the other thread were not very good ones. Composer rewrites the autoload file with information from composer.json and thus you should never edit the php file directly. What you should do is add an autoload block to your composer.json.

For example:

{
    "autoload": {
        "psr-0": {
            "Vendor\\Namespace\\": "src/"
        }
    }
}

Full docs on http://getcomposer.org/doc/04-schema.md#autoload