RFC: add an experimental php backend
#23173
TiagoGoddard
started this conversation in
Development
Replies: 2 comments 2 replies
|
I have not used php in many years, but I'll try try to offer some really general thoughts.
Good luck! |
1 reply
|
So, my main question about all of this would be who owns and maintains this backend. None of the current Pants maintainers (to my knowledge) have much experience with PHP, or any current investment in it, so we are not in a good position to do this. So what I'm really asking is - are you motivated enough to not just develop this but to own it going forward? :) Is this more of a personal project, or does your employer have a use case for this? Obviously in the latter case it's more likely that there could be resources and motivation for maintenance. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I've been interested in a
phpbackend that brings support for PHP projects, integrating Composer, PHPUnit, and static analysis into the Pants ecosystem instead of adhoc-tools.The
phpbackendThe
phpbackend would be functionally similar to the existingjavascript,cc, orgobackends. It would manage third-party dependencies via Composer and provide standard targets for PHP sources, tests, and packaged binaries alongside autoload files.I imagine this backend would be most useful for teams managing mixed-language environments with PHP microservices or APIs, maybe some legacy monoliths too or frameworks like Laravel. It could also be highly useful to audit and format PHP codebases uniformly.
Proposed Approach:
Since I am just starting to scope this out, and I'm new to Pants in general, I haven't written any code yet. However, I envision the core functionality focusing on:
php_sourcestarget and mapping internal dependencies based on directory structures.composer_requirementsmacro to parsecomposer.jsonandcomposer.lockfiles, which would generate individual third-party targets for vendor packages.php_testrunner that extracts the required closure of source files and invokesPHPUnitin an isolated, temporary environment.Note
As far as I know, there aren't many build systems that handle PHP so this could actually prove a lot of trouble (I could be wrong though!).
Warning
Composer itself doesn't break hermeticity, but it is also not hermetic by default because it relies on the system's PHP installation and global environment, that can make caching unreliable. My goal for this backend would be to handle toolchain structure and isolate the
vendordirectory requirements per target, similar to howjavascripthandles package.json files. This ensures that a cache hit for a specific microservice's test suite remains accurate regardless of what other PHP projects exist in the repository or how currently installed tools handle it.Potential scope of the
phpbackend:I'm calling this a
phpbackend to encapsulate the entire PHP ecosystem. In figuring out how best to analyze and build PHP codebases in a strict environment, handle estabilished frameworks like Laravel, Wordpres and Zend, these tools and features seem like natural fits under a backend, and PHP already have tools that could help with most required features.Scopes that could be done:
use namespace\Class;and also require/import statements in.phpfiles to automatically infer dependencies between internal Pants targets, eliminating manualBUILDfile boilerplate, should probably handlecomposer.jsonandcompoer.lockfiles too.packagestandalone executable binaries for CLI tools written in PHP.checkgoal to enforce type safety and catch errors across the repository before builds or deployments.Request for feedback
test,lint,package) would be the most valuable for an MVP?pants.backend.experimental.php, and would anyone (besides me) be willing to collaborate or test it?All reactions