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

Removal of helper.php in package #124

Open
JUVOJustin opened this issue Oct 16, 2024 · 2 comments
Open

Removal of helper.php in package #124

JUVOJustin opened this issue Oct 16, 2024 · 2 comments

Comments

@JUVOJustin
Copy link

JUVOJustin commented Oct 16, 2024

With prefixing and copying enabled strauss removes the following file of the extended ACF library: https://github.com/vinkla/extended-acf/blob/master/src/helpers.php

This leads to errors since the function can not be loaded as mentioned in extended acf´s readme. The workaround for now is to exclude the package.

"strauss": {
            "target_directory": "vendor/vendor-prefixed",
            "namespace_prefix": "My_Project\\Dependencies\\",
            "classmap_prefix": "My_Project",
            "constant_prefix": "MY_PROJECT",
            "exclude_from_copy": {
                "packages": [
                    "phpseclib/phpseclib",
                    "johnbillion/extended-cpts",
                    "symfony/polyfill-php80",
                    "wp-cli/wp-cli",
                    "timber/timber",
                    "twig/twig",
                    "vinkla/extended-acf"
                ],
                "namespaces": [
                ]
            },
            "exclude_from_prefix": {
                "packages": [
                    "johnbillion/extended-cpts",
                    "phpseclib/phpseclib",
                    "timber/timber",
                    "twig/twig",
                    "wp-cli/wp-cli",
                    "vinkla/extended-acf"
                ]
            },
            "delete_vendor_files": true
        }

The conent of the file is: <?php // This file was deleted by {@see https://github.com/BrianHenryIE/strauss}.

@JUVOJustin
Copy link
Author

Actually i just got the same error for another package:

Fatal error: Uncaught My_Project\Dependencies\Symfony\Component\Intl\Exception\ResourceBundleNotFoundException: The resource bundle "/var/www/html/wp-content/plugins/my-project/vendor/vendor-prefixed/symfony/intl/Resources/data/regions/root.php" does not exist.

@BrianHenryIE
Copy link
Owner

BrianHenryIE commented Nov 13, 2024

Hey, sorry, I thought I had replied to this.

When delete_vendor_files is enabled, Composer itself still tries to autoload files autoloader entries. I think I opted to place an empty file in their place to avoid a different error message.

If the file were to be deleted, it needs to be removed from Composer's autoloaders, i.e. vendor/composer/autoload_static.php and vendor/composer/autoload_files.php and also vendor/composer/installed.json.

In your first case, the file should be present at vendor-prefixed/vinkla/extended-acf/src/helpers.php and would be autoloaded by the Strauss generated autoloader if you were using that. I guess you're not. The quick fix is to add a files autoloader to your project containing vendor-prefixed/vinkla/extended-acf/src/helpers.php in its array.

Looking at ResourceBundleNotFoundException, I don't see root.php in symfony/intl/Resources/data/regions/, so is that the problem?

Longer-term, I've been refactoring a lot, adding DiscoveredFiles, File, DiscoveredSymbols classes and similar so I can track the changes done to each file as they're processed. Once that's complete I'll take a look at editing the Composer autoloaders to point at the files' new locations and delete the old ones.

This is part of #34 (but it is a case I wasn't thinking of correctly)

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

No branches or pull requests

2 participants