Set specific folder as document root for PHP app

manu-hubTRIAL

7 months ago

Hey guys,

i've created a custom php application without framewoks. The directory structure is nealry similar to symfony or laravel:

/app

/models

/controller

...

/public (index.php)

/vendor (librarys)

....

My problem is to correctly set the document root like classic apache config, to make the host point to a specific dir. Ive tried the "root directory" setting to "/public". Nginx then find correctly the index.php, but the app cannot find files outside from public. Ive also tried custom .toml with commands like "start = php -S 0.0.0.0:8080 -t public". And own nginx configs are apparently not supported.

Or is there maybe mis config in my app? My index.php is defining path constants based on this: define('BASE_DIR', dirname(__DIR__)); All other files are included based on these constant.

best regards

1 Replies

7 months ago

You may be looking for NIXPACKS_PHP_ROOT_DIR -

https://nixpacks.com/docs/providers/php