Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

php.new Defensive Wrapper & Uninstaller

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.

🎯 Philosophy

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.

✨ Features

  • 100% User-Space: No sudo, no root permissions, no /usr/local/bin pollution.
  • Customizable Path: Install anywhere via a single environment variable (defaults to ~/Dev/herd-lite).
  • Defensive State Management: Uses trap to ensure zero temporary files (/tmp/) are left behind, even on catastrophic failure or SIGINT.
  • Self-Aware Uninstaller: The uninstaller uses pwd -P to resolve physical paths, making it immune to symlink traps and directory renaming anomalies.
  • Surgical Shell Cleanup: Uses Extended Regex (sed -E) to remove PATH and PHP_INI_SCAN_DIR exports 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 / or rm -rf ~.
  • Cross-Platform Precision: Engineered specifically with exact standard matching for macOS (BSD sed) and Linux (GNU sed).

🚀 Quick Install (One-Liner)

You can run the script directly from this repository without cloning it.

macOS (Apple Silicon & Intel)

# 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

Linux

# 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" bash

🧹 Deep Uninstallation

To 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_lite

After 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 users

🔬 Under the Hood

For the technically curious, here is why this script is bulletproof:

  • sed Delimiters: Uses @ (Linux) and # (macOS) instead of / in sed to 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 the herd-lite folder 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 the HERD_LITE_DIR environment 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

About

No description or website provided.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Used by

Contributors

Languages