frankenphp icon indicating copy to clipboard operation
frankenphp copied to clipboard

Handle symlinking edge cases

Open withinboredom opened this issue 6 months ago • 2 comments

This one is interesting — though I’m not sure the best way to provide a test. I will have to look into maybe an integration test because it is a careful dance between how we resolve paths in the Caddy module vs. workers. I looked into making a proper change (literally using the same logic everywhere), but I think it is best to wait until #1646 is merged.

But anyway, this change deals with some interesting edge cases. I will use gherkin to describe them:

Feature: FrankenPHP symlinked edge cases
  Background: 
    Given a `test` folder
    And a `public` folder linked to `test`
    And a worker script located at `test/index.php`
    And a `test/nested` folder
    And a worker script located at `test/nested/index.php`
  Scenario: neighboring worker script
    Given frankenphp located in the test folder
    When I execute `frankenphp php-server --listen localhost:8080 -w index.php` from `public`
    Then I expect to see the worker script executed successfully
  Scenario: nested worker script
    Given frankenphp located in the test folder
    When I execute `frankenphp --listen localhost:8080 -w nested/index.php` from `public`
    Then I expect to see the worker script executed successfully
  Scenario: outside the symlinked folder
    Given frankenphp located in the root folder
    When I execute `frankenphp --listen localhost:8080 -w public/index.php` from the root folder
    Then I expect to see the worker script executed successfully
  Scenario: specified root directory
    Given frankenphp located in the root folder
    When I execute `frankenphp --listen localhost:8080 -w public/index.php -r public` from the root folder
    Then I expect to see the worker script executed successfully    

Trying to write that out in regular English would be more complex IMHO.

These scenarios should all pass now with this PR.

withinboredom avatar Jun 18 '25 19:06 withinboredom

do the edge cases only affect workers, not regular php requests?

henderkes avatar Jun 19 '25 13:06 henderkes

@henderkes yes, only workers. I should have a nice test suite this weekend. Manually testing this is annoying.

withinboredom avatar Jun 25 '25 20:06 withinboredom