Skip to content

[Process] Add Laravel Herd php detection path #58258

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

Merged
merged 1 commit into from
Sep 16, 2024

Conversation

mpociot
Copy link
Contributor

@mpociot mpociot commented Sep 13, 2024

Q A
Branch? 7.2
Bug fix? no
New feature? yes
Deprecations? no
Issues
License MIT

As of right now, using the PhpExecutableFinder in combination with Laravel Herd, results in an empty string, which is what this PR fixes.

As the PhpExecutableFinder is already aware of XAMPP, it might be a good idea to also add support for Laravel Herd, which is widely used - not only in the Laravel ecosystem.

Laravel Herd uses statically compiled PHP binaries, which is why the PHP_BINDIR folder always points to /bin instead of a user-specific folder.

As Laravel Herd adds a HERD_HOME environment variable, we can check for the existence of this variable and then add the bin subdirectory to the list of directories to search.

I couldn't find any tests for XAMPP, which is why I haven't included any for this addition.

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.2 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@stof
Copy link
Member

stof commented Sep 13, 2024

I would treat that as a new feature for 7.2 though, not as a bugfix (and if treated as a bugfix, it would not have 7.1 as its oldest impacted version)

@mpociot
Copy link
Contributor Author

mpociot commented Sep 13, 2024

Right, this is my first contribution to Symfony, so sorry about any formal issues.
Happy to send this to an older branch as well if that's what gets decided 👍

@xabbuh
Copy link
Member

xabbuh commented Sep 13, 2024

This looks like a new feature to me and should thus target the 7.2 branch.

@derrabus
Copy link
Member

Can we add a test that covers the change?

@mpociot
Copy link
Contributor Author

mpociot commented Sep 13, 2024

@derrabus Well, I don't know a good way to test this - and as I said, there are currently no tests for the xampp detection either, otherwise I would've used that as a starting point.

This is what the current coverage looks like:

image

(This coverage reported was generated by only running the Process component tests using ./phpunit src/Symfony/Component/Process/ --coverage-html=coverage

@xabbuh
Copy link
Member

xabbuh commented Sep 13, 2024

Can we try installing Laravel Herd in the integration test job?

@wouterj
Copy link
Member

wouterj commented Sep 15, 2024

Given Herd install PHP globally in the system (as far as I understand), an integration tests will be quite costly (a whole new CI job just for one test).

I think we should at most add a small unit test to make sure we don't break the behavior of checking the HERD_HOME env var.

@mpociot
Copy link
Contributor Author

mpociot commented Sep 15, 2024

@wouterj I don't know how this should be tested. As PHP_BINARY and PHP_SAPI will always be defined when running unit tests, none of the code after these lines can be tested as of right now (which is also why they aren't covered in any existing tests)

https://github.com/symfony/symfony/blob/7.2/src/Symfony/Component/Process/PhpExecutableFinder.php#L61-L64

@wouterj
Copy link
Member

wouterj commented Sep 15, 2024

Aha, indeed. Let's go without tests then 👍

Copy link
Member

@wouterj wouterj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small CS fix, but other than that good to go imho!

@xabbuh xabbuh modified the milestones: 7.1, 7.2 Sep 15, 2024
@carsonbot carsonbot changed the title Add Laravel Herd php detection path [Process] Add Laravel Herd php detection path Sep 15, 2024
@nicolas-grekas nicolas-grekas changed the base branch from 7.1 to 7.2 September 16, 2024 14:33
@nicolas-grekas nicolas-grekas force-pushed the herd-phpfinder-adjustments branch from 3af06f1 to 93ca4e9 Compare September 16, 2024 14:33
@nicolas-grekas
Copy link
Member

Thank you @mpociot.

@nicolas-grekas nicolas-grekas merged commit 0487a08 into symfony:7.2 Sep 16, 2024
9 of 10 checks passed
@fabpot fabpot mentioned this pull request Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants