A strictly controlled, zero-anomaly wrapper for the official Laravel Herd Lite (php.new) installation script. Designed for Senior DevOps engineers and perfectionists who demand absolute OS hygiene, isolated environments, and surgical cleanup.
The official php.new installation script is incredibly fast and useful, but it hardcodes the installation path to ~/.config/herd-lite and provides a rudimentary uninstaller that leaves dead paths injected in your shell profiles.
This wrapper fixes that natively. It fetches the upstream script in memory, dynamically patches the hardcoded paths, and injects a self-aware, bulletproof deep uninstaller that cleans up your OS surgically without risking false positives or leaving orphan configurations.
- 100% User-Space: No
sudo, no root permissions, no/usr/local/binpollution. - Customizable Path: Install anywhere via a single environment variable (defaults to
~/Dev/herd-lite). - Defensive State Management: Uses
trapto ensure zero temporary files (/tmp/) are left behind, even on catastrophic failure orSIGINT. - Self-Aware Uninstaller: The uninstaller uses
pwd -Pto resolve physical paths, making it immune to symlink traps and directory renaming anomalies. - Surgical Shell Cleanup: Uses Extended Regex (
sed -E) to removePATHandPHP_INI_SCAN_DIRexports from your.zshrc/.bashrc. It completely ignores your personal aliases or comments, preventing accidental deletions. - Catastrophic Failure Guardrails: The uninstaller strictly validates paths before deletion, completely eliminating the risk of accidental
rm -rf /orrm -rf ~. - Cross-Platform Precision: Engineered specifically with exact standard matching for macOS (BSD
sed) and Linux (GNUsed).
You can run the script directly from this repository without cloning it.
# Default installation to ~/Dev/herd-lite
curl -fsSL https://raw.githubusercontent.com/daffaalam/php.new/main/mac | bash
# Or install to a custom directory
curl -fsSL https://raw.githubusercontent.com/daffaalam/php.new/main/mac | HERD_LITE_DIR="$HOME/Opt/MyPHP" bash# Default installation to ~/Dev/herd-lite
curl -fsSL https://raw.githubusercontent.com/daffaalam/php.new/main/linux | bash
# Or install to a custom directory
curl -fsSL https://raw.githubusercontent.com/daffaalam/php.new/main/linux | HERD_LITE_DIR="/opt/php_env" bashTo completely eradicate Herd Lite, its binaries, configurations, and shell profile injections, simply run the generated uninstaller located in the bin directory of your installation path.
# Example if installed in the default directory
~/Dev/herd-lite/bin/uninstall_herd_liteAfter running the uninstaller, reload your shell profile to clear the environment variables from your active session:
source ~/.zshrc # For Zsh users
# or
source ~/.bashrc # For Bash usersFor the technically curious, here is why this script is bulletproof:
sedDelimiters: Uses@(Linux) and#(macOS) instead of/insedto prevent syntax crashes when your custom paths contain special characters.pwd -P: The uninstaller calculates its own absolute physical path at runtime. You can move theherd-litefolder anywhere on your disk, and the uninstaller will still work perfectly without relying on human memory or environment variables.:-Parameter Expansion: Guarantees a safe fallback path if theHERD_LITE_DIRenvironment variable is accidentally passed as empty ("").- Regex Precision: The uninstaller targets exact string injections
^(export )?(PATH|PHP_INI_SCAN_DIR)=..., making it future-proof against upstream logic changes while leaving your custom aliases untouched.
Built for engineers who care about what runs on their machines.
⚡ Powered by Gemini AI