> ## Documentation Index
> Fetch the complete documentation index at: https://documentation.bearsampp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PHP Module in Bearsampp: Versions and Extensions

> Switch PHP versions, toggle extensions, and adjust php.ini settings in Bearsampp from the system tray — no manual config editing required for common changes.

PHP is the scripting language that powers most web applications running on Bearsampp. Bearsampp ships with multiple PHP versions that you can install side by side and switch between instantly. It also gives you a tray-based interface for toggling extensions and common `php.ini` settings so you can match the environment your project requires.

## Multiple PHP versions

You can have several PHP versions installed at the same time. Only one version is active at a given moment, and it is shared by Apache. Switch versions without restarting your machine:

<Steps>
  <Step title="Open the PHP versions menu">
    Right-click the tray icon → **PHP** → **Versions**.
  </Step>

  <Step title="Select the version you need">
    Click a version number. Bearsampp stops Apache, switches the active PHP version, updates all configuration links, and restarts Apache automatically.
  </Step>
</Steps>

<Warning>
  Not every PHP version is compatible with every Apache version. Bearsampp will warn you if there is a known incompatibility between the PHP and Apache versions you have selected.
</Warning>

## Configuration file

Each PHP version has its own `php.ini` file located at:

```
bin/php/phpX.X.X/php.ini
```

Replace `phpX.X.X` with the version you are using (for example, `php8.3.0`). You can open this file directly from the tray menu.

## Tray menu reference

Right-click the tray icon → **PHP** to access:

<CardGroup cols={2}>
  <Card title="Edit php.ini" icon="pen-to-square">
    Open the active `php.ini` in your default text editor.
  </Card>

  <Card title="Versions" icon="code-branch">
    Switch to a different installed PHP version.
  </Card>

  <Card title="Extensions" icon="puzzle-piece">
    Enable or disable individual PHP extensions.
  </Card>

  <Card title="Settings" icon="sliders">
    Toggle common `php.ini` directives without editing the file manually.
  </Card>

  <Card title="Logs" icon="file-lines">
    Open the PHP error log to see runtime errors and warnings.
  </Card>
</CardGroup>

## Managing extensions

PHP extensions add capabilities to the language — database drivers, image processing, cryptography, and more. Bearsampp lets you toggle them without editing `php.ini` by hand.

<Steps>
  <Step title="Open the extensions menu">
    Right-click the tray icon → **PHP** → **Extensions**.
  </Step>

  <Step title="Toggle an extension">
    Click an extension name to enable or disable it. Bearsampp adds or removes the `extension=` line in `php.ini` and restarts Apache.
  </Step>
</Steps>

<Note>
  Enabling an extension only works if the corresponding `.dll` file exists in `bin/php/phpX.X.X/ext/`. If you do not see an extension listed, the DLL is not bundled with that PHP version.
</Note>

## Adjusting PHP settings

Common `php.ini` directives — such as `display_errors`, `short_open_tag`, `file_uploads`, and session settings — can be toggled through the tray menu:

Right-click the tray icon → **PHP** → **Settings** → click a setting to flip it on or off.

For settings that are not exposed in the tray menu, open `php.ini` directly (**PHP** → **Edit php.ini**), make your changes, and save. Then restart Apache for the changes to take effect.

## PEAR

PHP Extension and Application Repository (PEAR) is bundled with each PHP version in Bearsampp. The `pear` executable is located alongside the PHP binary in `bin/php/phpX.X.X/`. You can run PEAR commands from the PHP or Git console.

## Accessing PHP logs

PHP errors are written to a dedicated log file. To open it:

Right-click the tray icon → **PHP** → **Logs**.

You can also tail the log file directly. It is stored in the Bearsampp `logs/` folder as `php_error.log`.

## Service details

| Property          | Value                          |
| ----------------- | ------------------------------ |
| Config file       | `bin/php/phpX.X.X/php.ini`     |
| Error log         | `logs/php_error.log`           |
| PEAR              | Included with each PHP version |
| Version switching | Tray → PHP → Versions          |
