Starting from version 2.3.5, we have centralized the environment variables in the `config/env.ini` file.
You can set environment variables by modifying this file.
We divide the environment variables supported by static-php-cli into three types:
- Global internal environment variables: declared after static-php-cli starts, you can use `getenv()` to get them internally in static-php-cli, and you can override them before starting static-php-cli.
- Fixed environment variables: declared after static-php-cli starts, you can only use `getenv()` to get them, but you cannot override them through shell scripts.
- Config file environment variables: declared before static-php-cli build, you can set these environment variables by modifying the `config/env.ini` file or through shell scripts.
You can read the comments for each parameter in [config/env.ini](https://github.com/crazywhalecc/static-php-cli/blob/main/config/env.ini) to understand its purpose.
Generally, you don't need to modify any of the following environment variables as they are already set to optimal values.
However, if you have special needs, you can set these environment variables to meet your needs
(for example, you need to debug PHP performance under different compilation parameters).
If you want to use custom environment variables, you can use the `export` command in the terminal or set the environment variables directly before the command, for example:
Or, if you need to modify an environment variable for a long time, you can modify the `config/env.ini` file.
`config/env.ini` is divided into three sections, `[global]` is globally effective, `[windows]`, `[macos]`, `[linux]` are only effective for the corresponding operating system.
For example, if you need to modify the `./configure` command for compiling PHP, you can find the `SPC_CMD_PREFIX_PHP_CONFIGURE` environment variable in the `config/env.ini` file, and then modify its value.
Starting from 2.2.0, static-php-cli supports custom environment variables for all compilation dependent library commands of macOS, Linux, FreeBSD and other Unix systems.
In this way, you can adjust the behavior of compiling dependent libraries through environment variables at any time.
For example, you can set the optimization parameters for compiling the xxx library through `xxx_CFLAGS=-O0`.
Of course, not every library supports the injection of environment variables.
We currently provide three wildcard environment variables with the suffixes:
-`_CFLAGS`: CFLAGS for the compiler
-`_LDFLAGS`: LDFLAGS for the linker
-`_LIBS`: LIBS for the linker
The prefix is the name of the dependent library, and the specific name of the library is subject to `lib.json`.
Among them, the library name with `-` needs to replace `-` with `_`.
Here is an example of an optimization option that replaces the openssl library compilation:
```shell
openssl_CFLAGS="-O0"
```
The library name uses the same name listed in `lib.json` and is case-sensitive.
::: tip
When no relevant environment variables are specified, except for the following variables, the remaining values are empty by default: