dunglas / frankenphp

🧟 The modern PHP app server
https://frankenphp.dev
MIT License
6.68k stars 220 forks source link

Follow Soft Link folders #348

Closed peterfox closed 9 months ago

peterfox commented 9 months ago

Release: v1.0.0 (via Docker) MacOS 14.1.2 (23B2091)

When using a soft linked directory the files within the directory end up providing a 404.

For example in Laravel if you have a project and run php artisan storage:link this creates a soft link between the storage/app/public folder and public/storage. If a file exists in storage/app/public say example.png and I then try to access the file at https://localhost/storage/example.png the server fails to return the file.

This maybe caused by Docker. I've not succeeded in making the server work on the mac itself yet.

francislavoie commented 9 months ago

I think you need to set resolve_root_symlink in your config (under php_server). See https://frankenphp.dev/docs/config/

peterfox commented 9 months ago

@francislavoie thank you. This got it working for me:

{
    # Enable FrankenPHP
    frankenphp
    # Configure when the directive must be executed
    order php_server before file_server
}

localhost {
    # Serve files from the public directory
    root * public/
    # Enable compression (optional)
    encode zstd gzip
    # Execute PHP files in the current directory and serve assets
    php_server {
        # Required store /public/storage folder
        resolve_root_symlink
    }
}