Skip to content

Add support for PHP $uri, index, *then* script #1078

Open
@mqudsi

Description

@mqudsi

Presently, including a script app.php in a nginx-unit php application's definition causes any requests to that app to execute script, ignoring $uri and index.

This causes a problem for a lot of configurations where virtual paths are used in the same namespace (prefixed path) as physical php files, e.g. given the following directory tree, there is no way to service all of the following requests without pre-enumerating all possible directory names or all possible filename patterns:

app-root/
├─ dir1/
│  ├─ index.php
│  ├─ script.php
├─ static-file.css
├─ main.php
	"applications": {
		"php": {
			"type": "php",
			"targets": {
				"direct": {
					"index": "index.php",
					"root": "/var/www/app-root/"
				},
				"main": {
					"index": "index.php",
					"script": "main.php",
					"root": "/var/www/app-root/"
				}
			},
  • You can match *.php and pass it to applications/php/direct to get URLs like /dir1/index.php and /dir1/script.php to work
  • You can use share with /path/to/app-root/ to load static files with types: [ "!*/*php" ], and set fallback to applications/php/main which handles requests like /static-file.css and virtual paths such as /this/path/isnt/real that need to be mapped to /main.php
  • But that breaks the execution of /app-root/dir1 or /app-root/dir1/ because script overrides both $uri and index, meaning both those requests will be mapped to /app-root/main.php and not /app-root/dir1/index.php

Metadata

Metadata

Assignees

No one assigned

    Labels

    z-phpLanguage-Module for PHP (SAPI)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions