Autoload psr-4 is lost during installation

this is my node .json composer (abbreviated)

{
    "name": "acme/my-bundle",
    "type": "library",
    "version": "0.5.0",
    "autoload": {
        "psr-4": {
            "Acme\\MyBundle\\": ""
        }
    }
}

and in my project:

"require": {
    "acme/my-bundle": "dev-master"
},

then I started composer install, as a result, installed .json as

[
    {
        "name": "acme/my-bundle",
        "version": "dev-master",
        "version_normalized": "9999999-dev",

        "type": "library",
        "installation-source": "source"
        //
        // here must be this:
        // "autoload": {
        //    "psr-4": {
        //        "Acme\\MyBundle\\": ""
        //    }
        // },
        // but these lines are missing!
        //
    }
]

and autoload-psr4.php:

<?php

// autoload_psr4.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
    /* here must be this:
     * 'Acme\\MyBundle\\' => array($vendorDir . '/acme/my-bundle'),
     * but this line is missing!
     */
);

startup has disappeared, as well as other keys such as require

What am I missing?

I also tried psr-0 but did not succeed. autoload_namespaces.php is just an empty array.

+4
source share
1 answer

I did not mention that I wanted to get a package from a private repo! It will make a difference!

So I had to reinstall autoload

"require": {
    "acme/my-bundle": "dev-master"
},
"repositories": [
    {
        "type": "package",
        "package": {
            "version": "dev-master",
            "name": "acme/my-bundle",
            "source": {
                "url": "ssh://git@example.com/acme/my-bundle",
                "type": "git",
                "reference": "test"
            }, 
            //    THIS IS      |
            //    ADDITIONAL   V
            "autoload": {
                "psr-4": {
                    "Acme\\MyBundle\\": ""
                }
            }
        }
    }
]

see fooobar.com/questions/1546237 / ... Thanks @zacharydanger

+2

Source: https://habr.com/ru/post/1546234/


All Articles