-
-
Notifications
You must be signed in to change notification settings - Fork 476
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
Questions on Packagist package updates and tag handling #1483
Comments
What package is this for? Why do you feel like including all deps prefixed is a good idea for you while 99.99% of packages do not do this? |
Thank you @Seldaek, for getting back to me! I'll try to explain my perspective as clearly as possible: My PackageThe package I'm investigating this for is a WordPress plugin in very early alpha stage. It can be found here: https://github.com/hirasso/placeholders. It's a simple plugin with only a few non-dev composer dependencies, but I’m planning to release other plugins with more dependencies in the future. Additonaly to the official WP.org plugin repository, I'd also love to be able to distribute my plugins via Packagist. I usually use a fully composer-managed WordPress boileerplate, roots/bedrock, so being able to manage my plugins via Packagist would be nice and I could skip the WP-org bottleneck (SVN, plugin review process, ...). The plugin ecosystem problemIn WordPress (or any other ecosystem like for example Statamic or Kirby CMS), it’s not uncommon for plugin dependencies to raise conflicts between each other at some point. Tools like php-scoper, mozart or strauss were created to solve this problem. For example, I recently encountered an issue where I couldn't install a composer package due to a strict dependency on ...and I just found out about phpstan/phpstan and phpstan/phpstan-src – where the first is used to distribute to packagist and the second is used to develop the package. For similar reasons: To avoid dependency conflicts. WordPressQuite a few of the more successful WordPress plugins have encountered dependency issues in the past and implemented custom solutions. Here is an example of one vendor talking about the issue and their solution to it. Sadly no info in that post about if and how they publish their scoped version to packagist. Another large plugin vendor, Yoast, provides the most popular WordPress SEO plugin, which can also be found on Packagist. They are going to great lengths to prefix and ship their non-dev dependencies and include them in their Packagist distribution. I haven't yet figured out exactly how they do it (the Other thoughts/questions
How will this look like in a few years? Like this?
That covers the PHP side of my thoughts. The other part concerns frontend assets with a build step: Frontend assets with a build stepIdeally, I wouldn’t want to commit my built frontend assets (scripts and styles) to my repos just to publish them with a Packagist package. Statamic, for example, compiles its frontend assets in a GitHub release action and attaches them to the release, and downloads them "manually" later via yet another Composer dependency/plugin. All of this would be so much simpler if there were an "official" way to distribute packages with a build step to Packagist. Similar to It's entirely possible that I’m making wrong assumptions here. But I'm certainly not the only one 😄 ...so I'd be extremely grateful for any guidance. Or even an open discussion about ways to improve the overall experience of composer and packagist. |
the reason for having a single version of a package installed at a time is because PHP does not work with a concept of modules exporting things. Instead, all classes are defined in the same naming space, so we cannot have 2 different versions of the class
Packagist does not store any code. It only stores metadata about packages. So there is no way to push code to Packagist (btw, this is the main point making it possible for Jordi and Niels to operate packagist.org, compared to the infrastructure of npmjs.com which is backed by Microsoft). What you can do is something similar to what phpstan does: use one GitHub repository for your source code where you develop things (ignoring anything you want to ignore) and a second repository in which the CI would automatically push the build output. That second repository would be the one registered in packagist. |
Yeah.. WP is a problem because it doesn't embrace Composer and then you end up with these plugins conflicting with each other.. If you had one composer.json for all plugins and their deps (like roots/bedrock does) this would not happen, but alas.. So right now yeah there are a few hacky ways to do this, and we are well aware of the problem and considering ways to fix it by hosting archives ourselves, but I cannot tell you when we get there.. So if you need a solution now then go the phpstan route or something else. And hopefully at some point we'll have better archive support. That being said, with scoped dependencies while you're right that disk size is not a huge problem, you do have much higher memory usage if you use the same library scoped into 5 namespaces. Classes will be kept in opcache 5 times, etc. It solves some problem for WP, but it's really not the solution, and packages having a simple git = zip relationship are much better IMO both for efficiency and from a code review / security perspective. |
Thank you @stof and @Seldaek for taking the time to answer! Much appreciated. And a big thank you to Jordi and Niels for maintaining Packagist. It's an amazing service to the whole community!! 🙏 Things I learned from your replies
Things I'm still asking myself
Regarding the dependency problem: WP is not really the issue
I'm not sure I agree here, or I'm missing something. With one
So a fully God I would love to meet in a call sometime for a coffee and talk about these things. Writing it all out is exhausting, especially as I'm not a native English speaker 😅 |
Composer (and by extension Packagist) has 2 different kinds of versions for packages:
As I said previously, this is not a restriction added by Composer itself. PHP makes it impossible to have 2 different definitions for a given class/interface. If you were installing |
Thank you @stof . Seems like I really need to rtfm for composer thoroughly 😅 |
Yes, you get a resolution conflict sometimes, and then you have to maybe settle for an older version of some software, or nag someone to update their requirements so that things become compatible. But then in the end composer resolves all packages to a single version that is compatible with all other installed libraries, and that is much better than scoping everything IMO. And it does seem to work for everyone using Composer, and it causes way less pain than the wordpress model of every plugin installing their own stuff but then trying to coexist in a single process. |
Thanks for taking the time and explaining your perspective! |
Hello! I have a few questions about how Packagist interacts with GitHub repositories, and I haven’t been able to find documentation that fully clarifies them.
1. When does Packagist pull updates from a GitHub repo?
v
)?2. Managing build artifacts and vendor folder with Packagist
My goal is to scope my dependencies with php-scoper. In the future, I may also need to include pre-processed JavaScript files in my package. Ideally, I’d like to avoid committing these build artifacts to my main repository just to have them appear on Packagist.
Current plan: I’m considering maintaining a separate
dist
branch where I would, on each merge frommain
:vendor
directory.Would this approach ensure that only the necessary files are visible on Packagist?
Or is there a better method to include the
vendor
directory in my package—something more similar to thenpm publish
process, where I could manually push releases with a version?Thanks for your help!
The text was updated successfully, but these errors were encountered: