Sites & PHP

PHP versions

Install several PHP versions, choose a default, pin a version per site, and use the php and composer shims.

Install as many PHP versions as you need, pick a default, and pin any site to its own version. In a terminal, php and composer automatically use the version of the project you're in.

Installing PHP

Open the PHP page and click Install next to a version under Available downloads. The download and progress show at the top of the page, and the version is ready the moment it finishes. From the terminal:

$ laramonster php:available        # versions you can install
$ laramonster php:install 8.4 8.3  # one or more at once
$ laramonster php:list             # what's installed, and the default
SystemWhere the builds come from
macOS, LinuxLaraMonster's own static builds (built with static-php-cli): no dependencies, with intl, sodium, mbstring and mbregex, GD with JPEG, WebP and FreeType, OPcache, and PDO for MySQL, PostgreSQL and SQLite.
WindowsThe official builds from windows.php.net. If the Microsoft Visual C++ runtime is missing, LaraMonster offers to install it (Windows asks for permission once).

PHP installed another way (Homebrew, apt, pacman, XAMPP, C:\php…) is found automatically and listed as a system PHP. You can use it for sites just like a downloaded version.

The default version

Sites without a version of their own use the default. Click Make default on the PHP page, or:

$ laramonster use 8.4
$ laramonster use [email protected]          # the same, Herd style

A version per site

Pin a site to a version with the PHP menu on its row on the Sites page, or from inside the project:

$ cd ~/Code/legacy-app
$ laramonster isolate 8.1          # this site now runs PHP 8.1
$ laramonster which
site  legacy-app  http://legacy-app.localhost:8080
php   8.1.31  /home/you/.config/laramonster/php/8.1/bin/php
$ laramonster unisolate            # back to the default

Each PHP version runs in its own pool (PHP-FPM on macOS and Linux, php-cgi on Windows), started only when a site needs it. Switching a site's version is instant.

php and composer in your terminal

Setup's Terminal commands option (or laramonster setup) adds small php and composer shims to your PATH. They look at the folder you're in and run the matching PHP:

$ cd ~/Code/legacy-app && php -v
PHP 8.1.31 (cli)
$ cd ~/Code/shop && php -v
PHP 8.4.3 (cli)
$ composer require laravel/horizon # runs with the site's PHP 8.4
$ php artisan migrate              # also with the site's PHP and its settings

Outside any site the default version is used. Composer is downloaded for you the first time you run it (or install it from Tools).

Open a new terminal after setting up the shims. Terminals that were already open keep their old PATH. If which php still points somewhere else, see The terminal uses another PHP.

Without the shims, laramonster php and laramonster composer do the same thing:

$ laramonster php artisan tinker
$ laramonster composer install

Removing a version

Click Uninstall on the PHP page, or run laramonster php:uninstall 8.2. Only versions LaraMonster downloaded can be removed this way; a site still pinned to a removed version shows a warning on the dashboard and is served without PHP until you pick another version.

Next

Change memory_limit, upload_max_filesize and other values, and turn on extensions like Xdebug or Redis: PHP settings & extensions.