Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the correct file package key so composer requires cache works #66

Merged
merged 1 commit into from
May 28, 2021

Conversation

andythorne
Copy link
Contributor

Autoloading files is broken because composer requires the same file in the sub-package and root autoloaders. It does this because the fileIdentifier key is different due to the vendor path being included in the package name.

This PR normalises the package name so a consistent key can be generated, and the composer cache used when autoloading files.

Fixes #38

@beberlei
Copy link
Owner

beberlei commented Mar 9, 2021

Sorry have not seen this PR and the issue #38 before. I need to think about this a bit and check the Composer code to verify that the fix does what it should.

@beberlei
Copy link
Owner

This works, except when you have the laminas/laminas-zendframework-bridge that is loaded from friendsofphp/proxy-manager-lts, which will wrack havoc. I only solved it by adding a custom files autoloader that directly loads the Laminas classes and declares aliases:

<?php

require_once __DIR__ . '/vendor/laminas/laminas-code/src/Generator/GeneratorInterface.php';
require_once __DIR__ . '/vendor/laminas/laminas-code/src/Generator/AbstractGenerator.php';
require_once __DIR__ . '/vendor/laminas/laminas-code/src/Generator/TraitUsageInterface.php';
require_once __DIR__ . '/vendor/laminas/laminas-code/src/Generator/ClassGenerator.php';

class_alias("Laminas\Code\Generator\GeneratorInterface",
    "Zend\Code\Generator\GeneratorInterface");
class_alias("Laminas\Code\Generator\AbstractGenerator",
    "Zend\Code\Generator\AbstractGenerator",);
class_alias("Laminas\Code\Generator\TraitUsageInterface",
    "Zend\Code\Generator\TraitUsageInterface",);
class_alias("Laminas\Code\Generator\ClassGenerator",
    "Zend\Code\Generator\ClassGenerator",);

plus the following in root autoload:

    "autoload": {
        "files": ["laminas.php"]
    },

@beberlei beberlei merged commit babae8f into beberlei:master May 28, 2021
@andythorne andythorne deleted the file-loader branch May 30, 2021 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AutoloadGenerator.php messes up order of autoloading
2 participants