{"id":27376729,"url":"https://github.com/open-technology-foundation/php-localhost","last_synced_at":"2025-08-05T04:21:04.316Z","repository":{"id":287485636,"uuid":"964891829","full_name":"Open-Technology-Foundation/php-localhost","owner":"Open-Technology-Foundation","description":"Utility script that creates and manages PHP development servers with ease.","archived":false,"fork":false,"pushed_at":"2025-06-04T04:02:06.000Z","size":96,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-04T10:58:04.387Z","etag":null,"topics":["bash","localhost","localhost-management","php","php-localhost","webdev"],"latest_commit_sha":null,"homepage":"https://yatti.id/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Open-Technology-Foundation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-12T01:19:00.000Z","updated_at":"2025-06-04T04:02:08.000Z","dependencies_parsed_at":"2025-04-12T02:42:54.562Z","dependency_job_id":"921b4669-41f1-43e9-be24-29000d826eff","html_url":"https://github.com/Open-Technology-Foundation/php-localhost","commit_stats":null,"previous_names":["open-technology-foundation/php-localhost"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Open-Technology-Foundation/php-localhost","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-Technology-Foundation%2Fphp-localhost","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-Technology-Foundation%2Fphp-localhost/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-Technology-Foundation%2Fphp-localhost/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-Technology-Foundation%2Fphp-localhost/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Open-Technology-Foundation","download_url":"https://codeload.github.com/Open-Technology-Foundation/php-localhost/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-Technology-Foundation%2Fphp-localhost/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265705646,"owners_count":23814488,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","localhost","localhost-management","php","php-localhost","webdev"],"created_at":"2025-04-13T12:53:23.457Z","updated_at":"2025-07-18T05:37:25.316Z","avatar_url":"https://github.com/Open-Technology-Foundation.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP-Localhost\n\nA bash utility for creating and managing PHP development servers with ease.\n\n## Features\n\n- Start a PHP development server with a single command\n- Auto-selects random available port from configurable range (8100-8999 by default)\n- Auto-detects common web directories (html, public, www, httpdocs, htdocs, webroot, web, wwwroot)\n- Multiple running modes: foreground, background, or screen session\n- Automatic port collision detection and resolution\n- Router file support for custom URL handling\n- Auto-detects and launches browser in both GUI and terminal environments\n- Interactive management of running servers via companion script\n- Comprehensive error handling and dependency checking\n- Clean shutdown via signal trapping\n- Named parameter support with intuitive options\n\n## Installation\n\n1. Clone this repository\n2. Make the scripts executable: `chmod +x php-localhost php-localhost-screens`\n3. Optionally, add to your PATH or run the included install.sh script\n\n## Dependencies\n\n- PHP (with CLI support)\n- lsof (for process detection)\n- netcat (for port checking)\n- screen (optional, for screen mode)\n- A web browser (optional, for the -x/--execute option)\n\n## Usage\n\n```\nphp-localhost [-q] [-v] [-V] [-h] [-p PORT] [-d DIR] [-i MIN] [-a MAX] [-x] [--fg|--bg|--screen] [port] [dir] [mode]\n```\n\n### Parameters\n\nArguments can be in any order.\n\n- `port` - Port number to use (default: auto-assign from port range 8100-8999)\n- `dir` - Directory to serve (auto-detects common web directories)\n- `mode` - Server run mode (default: fg)\n  - `fg` - Run in foreground\n  - `bg` - Run in background\n  - `screen` - Run in screen session\n\n### Options\n\n- `-p, --port PORT` - Specify port number (0 = auto-assign from port range)\n- `-d, --directory DIR` - Specify directory to serve\n- `-i, --minport MIN` - Set minimum port for auto-assignment (default: 8100)\n- `-a, --maxport MAX` - Set maximum port for auto-assignment (default: 8999)\n- `--fg` - Run in foreground mode\n- `--bg` - Run in background mode\n- `--screen` - Run in screen session\n- `-x, --execute` - Open URL in browser when server starts\n- `-q, --quiet` - Suppress output and auto-kill existing servers on the same port\n- `-v, --verbose` - Show verbose output (default)\n- `-V, --version` - Display version information\n- `-h, --help` - Display the help message\n\n## Management\n\nUse the companion script `php-localhost-screens` to:\n- List all running PHP server instances (both standalone and screen sessions)\n- Interactively select servers by PID\n- Kill servers or attach to screen sessions\n- Auto-refresh the server list\n\nSimply run `php-localhost-screens` without arguments for an interactive menu.\n\n## Router Support\n\nIf a file named `router.php` exists in the served directory, it will be used automatically to handle URL routing and custom request processing.\n\nA router file allows you to:\n- Handle URLs that don't match physical files\n- Create custom API endpoints\n- Define rewrite rules and redirects\n- Implement custom 404 handlers\n\n## Browser Integration\n\nWhen using the `-x/--execute` flag, the script will:\n- Attempt to detect the default browser in GUI environments using:\n  - xdg-settings\n  - xdg-mime\n  - update-alternatives\n  - $BROWSER environment variable\n  - Common browser executables\n- In terminal-only environments, it will try to find terminal browsers:\n  - w3m, lynx, elinks, links\n- Launch the detected browser with the localhost URL\n\n## Web Interface\n\nThe project also includes a PHP file browser interface that:\n- Provides directory navigation with breadcrumb trails\n- Offers file viewing with syntax highlighting for common file types\n- Supports file downloads\n- Includes file/directory management features\n- Displays system information\n- Supports dark/light theme switching\n\nAccess this interface by navigating to the server URL in any browser.\n\n## Examples\n\n```bash\n# Auto-detect port and directory, run in foreground\nphp-localhost\n\n# Run on port 8001 serving html/ in background\nphp-localhost 8001 html bg\n\n# Set custom port range (1024-2048) and auto-select\nphp-localhost -i 1024 -a 2048\n\n# Serve current directory on port 8086\nphp-localhost . 8086\n\n# Screen session on port 8087 serving public/\nphp-localhost screen 8087 public\n\n# Quiet mode, auto-kill existing servers on port 8080\nphp-localhost -q 8080 .\n\n# Run in background with auto-port and open browser\nphp-localhost --bg -x\n\n# List and manage running PHP servers\nphp-localhost-screens\n```\n\n## Current Version\n\nVersion 1.0.431\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-technology-foundation%2Fphp-localhost","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopen-technology-foundation%2Fphp-localhost","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-technology-foundation%2Fphp-localhost/lists"}