Phive is a professional Visual Studio Code extension designed to streamline PHP development by providing a modern, live-reloading environment. It eliminates the need for manual browser refreshes and complex server configurations, making it ideal for both local and cross-device testing.
Core Features
Instant PHP Server: Launch a built-in PHP server instance directly from your workspace with a single click.
Smart Live Reloading: Automatically refreshes connected browsers (desktop and mobile) upon saving .php, .html, .css, .js, or .json files.
Network Sharing: Automatically detects your local IPv4 address, allowing seamless testing on mobile devices or tablets connected to the same network.
Integrated Request Logging: Real-time output channel providing detailed logs of incoming HTTP requests and server status.
Multi-root Workspace Support: Intelligent folder selection for developers working on multiple projects simultaneously.
Customizable PHP Path: Support for custom PHP binary locations, ensuring compatibility with XAMPP, WAMP, Laragon, or standalone PHP installations.
Automated Routing: Generates a temporary, hidden router script to handle asset serving and WebSocket injection without polluting your project structure.
Requirements
PHP: PHP must be installed on your system.
Environment: By default, the extension expects the php executable to be in your system's PATH.
Installation
Open Visual Studio Code.
Navigate to the Extensions view (Ctrl+Shift+X).
Search for Phive and click Install.
Configuration
Phive provides the following configuration options through VS Code Settings (Ctrl+,):
phive.phpPath: Specifies the absolute path to the PHP executable. Set this if php is not in your system PATH (e.g., C:\xampp\php\php.exe on Windows).
Usage
Start the Server: Open a PHP project folder. Click the Phive: Go Live button in the Status Bar (bottom right) or use the Command Palette (Ctrl+Shift+P -> Phive: Start PHP Server).
Select Folder: If using a multi-root workspace, select the specific project folder you wish to serve.
Development: The extension will automatically open your default browser. Any changes saved to supported files will trigger an immediate reload across all connected devices.
Stop the Server: Click the active server info in the Status Bar or use the Phive: Stop PHP Server command.
Technical Overview
Phive utilizes a WebSocket-based architecture (ws library) to maintain a persistent connection between the server and the client. During execution, it injects a lightweight JavaScript client into the PHP output stream via a temporary router file (.phive_router.php). This router file is automatically hidden from the VS Code File Explorer and securely deleted upon server termination to maintain workspace cleanliness.