I have a Laravel 5.8 project that is dependent on a private package from a private repository.
The private package is dependent on another private package from the same repository.
When I run composer install, the sub-package is intalled and shows in the vendor folder, but I still get a PHP exception 'Class not found' until I run composer dumpautoload
The following questions don't touch on my issue:
Composer package class not found
Composer won't install private package dependencies
Laravel : Code worked after composer dumpautoload
Google has been unable to help me on this one
Project composer.json
{
    ...
    "repositories": [
        {
            "type": "composer",
            "url": "https://PRIVATE-REPOSITORY"
        }
    ],
    "require": {
        "php": ">=7.0",
        "PRIVATE-PACKAGE": ">=1.0.0"
    }
    ...
}
Private package composer.json
{
    ...
    "require": {
        "php": ">=7.0.0",
        "PRIVATE-SUB-PACKAGE": ">=1.0.0"
    },
    "autoload": {
        "psr-4": {
            "PACKAGE\\NAMESPACE\\": "src/"
        }
    }
    ...
}
Private sub-package composer.json
{
    ...
    "autoload": {
        "psr-4": {
            "SUBPAKCAGE\\NAMESPACE": "src/"
        }
    }
    ...
}
I am not having any problems installing the sub-package, as other questions have mentioned, it is the autoloading that seems to be the issue.
The PHP error message
Message: Class 'SUBPACKAGE\NAMESPACE' not found
is coming from code inside the first package, where the sub-package is used.
I know the PHP syntax is correct because I am able to fix the error with
composer dumpautoload -o
but why is it necessary?
I expect composer install or composer update should be sufficient; I have no problem with sub-dependencies from external packages.
Am I missing anything here?
via Chebli Mohamed
 
Aucun commentaire:
Enregistrer un commentaire