dunglas / frankenphp

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

Trying to build-static without docker can only access app with explicit /index.php (especially using Caddyfile) #663

Open sawirricardo opened 5 months ago

sawirricardo commented 5 months ago

What happened?

cd ~ && git clone https://github.com/dunglas/frankenphp
cd ~ && composer create-project laravel/laravel build-static-laravel

Add Caddyfile

{
frankenphp
order php_server before file_server
}

# need to use port other than 80
:81 {
root * /public
encode zstd br gzip
php_server
}

then execute

cd ~/frankenphp && EMBED=~/build-static-laravel ./build-static.sh
./dist/frankenphp-mac-arm64 php-server

Here we have to access explicitly the index.php file like http://localhost:81/index.php instead of http://localhost:81 other explicit files such as http://localhost:81/robots.txt are being served fine

Build Type

Standalone binary

Worker Mode

No

Operating System

macOS

CPU Architecture

Apple Silicon

PHP configuration

none

Relevant log output

No response

d8vjork commented 5 months ago

Yesterday I was pulling my hair off with this too, didn't manage anything cause files are on an unzipped folder inside /tmp therefore no idea where they were pointing...

To me I was using the latest dev version (which I thing is more or less the same as this repo's master branch?): dunglas/frankenphp-dev:static-builder

Also: I'm using same kind of machine, did you get this UPX thing compressing stuff super slow too?

d8vjork commented 5 months ago

Adding this to the server/location block (no idea how is called in Caddy):

rewrite * /index.php?{query}&p={path}

Made everything work, might be some mistake from any parent/inherited config from FrankenPHP into the static-builder?

sawirricardo commented 5 months ago

Hm, I'm not sure, may as well need official comment for this @dunglas