-
Notifications
You must be signed in to change notification settings - Fork 25
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
How to handle prefixed dependencies also used by dev-dependencies #81
Comments
I just ran into this as well, with a prefixed Symfony library used by both the Codeception tests library and in our code base. |
I'm not sure why you're ever getting a PHP error – since your project code should be using the copied + prefixed class and the original should still exist in your vendor directory. I use WP Browser/Codeception pretty widely and haven't had a problem. I see why it's a problem that the unprefixed package still remains after I'll break up the tool so commands can be run individually. I'm already working on that as part of a feature to prefix the call sites in project files. Which would also give the option of doing all development using the true namespaces and only prefixing as a build step. 2bd1b3f Another approach which might work ( |
The PHP error occurs when the namespaced dependency (GuzzleHttp/Guzzle) is deleted/replaced in situ, since the dev-dependency (Codeception) needs the nonprefixed copy. Codeception runs, tries to use a class from If the original is not deleted, then I need to bundle both the original (for use by the dev deps) and the prefixed dependency (for use by project code) in production, since I need the PSR-4 autoloader from Hope this clarify things. If not, happy to try again. As far as possible solutions go, Im over my head and happily defer to what you think the ideal mechanism would be. Will note that an additional possible solve would be to have Strauss provide the option to bring over the composer.json |
Same deal for me, with
Because |
I've started a branch which will probably take me months to finish. The idea is to track each file which is copied/deleted/prefixed and after changes have a list that can be queried. From that, I intend to build a file with a |
@BrianHenryIE what do you think about adding a Strauss command line argument to configure Right now we get around this issue by setting that to We are just changing with |
Yeah, absolutely. I only recently added a first CLI option and started writing progress to the terminal. I'll try add that soon. It should be easy enough to add, but probably a pain to add a unit test given the current state of that class! I did look into it a bit before and there was something weird about handling both a |
OK, new feature, undocumented except in release notes, Overrides the Still plenty to do on this issue. |
@BrianHenryIE finally had a chance to test this, working well. Thank you! |
I finally got started on this. It has one passing test for So far I'm creating a It is important the |
I've been struggling to understand the best way to handle prefixing a dependency that is in use by both the project itself and some of the project dev dependencies. I am unsure if this is a bug or a usage issue.
For example, over in this PR for axewp/wp-graphql-headless-login, we're namespacing several production dependencies that require
guzzlehttp/guzzle
. However, that package is also required by our dev-depscodeception/module-phpbrowser
, which fails since it doesn't know to use the namespaced version of the classes, causing errors like:PHP Fatal error: Uncaught Error: Class "GuzzleHttp\HandlerStack" not found in /var/www/html/wp-content/plugins/wp-graphql-headless-login/vendor/codeception/module-phpbrowser/src/Codeception/Lib/Connector/Guzzle.php:342
here.What I've tried
delete_vendor_packages
doesn't seem to prefix the usage of deps in non-namespaced packages, nor does it happen if thetarget_directory
is set tovendor
.exclude_from_copy
andexclude_from_prefix
don't make sense here, since we explicitly want the package to be namespaced to prevent conflicts with other plugins.delete_vendor_packages
tofalse
, and to conditionally requirevendor/autoload.php
, however I couldnt find an option for strauss to copy thePSR-4
autoloader over tovendor-prefixed/autoload.php
, and sincedelete_vendor_packages
doesn't seem to be configurable on a per-package level that means our distribution zip needs to include duplicates of all namespaced dependencies.config.strauss
provides a way to have separate commands forcomposer install --no-dev
(e.g. delete copy from vendor) andcomposer install
(e.g. dont delete copy from vendor), which would let me use both the strauss and composer autoloaders and still keep the duplicates out of the production build.Is this a bug, known limitation, or just something wrong with how I'm approaching strauss?
The text was updated successfully, but these errors were encountered: