1

From PHP, how can I check if my server was started with something like:

php -S localhost:8080 -t public index.php

? I need some special logic to serve static files during development. Nginx won't need this code, so I want to put in a check.

1 Answer 1

2

By calling php_sapi_name(). It'll return "cli-server" when running under the built-in server, and another value (probably "cgi-fcgi" or "fpm-fcgi", depending on your setup) when running from nginx.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.