Download the PHP package mfonte/hte-cli without Composer
On this page you can find all versions of the php package mfonte/hte-cli. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mfonte/hte-cli
More information about mfonte/hte-cli
Files in mfonte/hte-cli
Package hte-cli
Short Description [H]andle [T]est [E]nvironment CLI tool to create and manage VirtualHosts that are compatible with github.com/mauriziofonte/win11-wsl2-ubuntu22-setup or with any LAMP stack based on Debian or Ubuntu, with Multi PHP-FPM support via mpm_event, proxy_fcgi, and fcgid Apache modules.
License MIT
Homepage https://github.com/mauriziofonte/win11-wsl2-ubuntu22-setup
Informations about the package hte-cli
Ubuntu/Debian compatible LAMP Test Environment Creator CLI Tool
Heads Up! This utility perfectly couples with the https://github.com/mauriziofonte/win11-wsl2-ubuntu22-setup WSL2 setup, for a complete LAMP stack on Windows 11.
However, this utility can be used in any LAMP stack on Debian or Ubuntu , with Multi PHP-FPM support.
Ah, one more thing: checking a perfect companion for HTE-Cli? Check out the Gash Bash, another creation of mine :)
Screenshot of hte-cli create
Screenshot of hte-cli remove
Screenshot of hte-cli details
What is this utility for?
HTE stands for Homelab Test Environment.
It eases the process of creating Test Environments on both Local or Staging environments, when using Apache on a multi PHP-FPM flavour.
Basically, this utility takes care of :
- Creating a new VirtualHost for your.local.domain.tld
- Configuring the VirtualHost to work via php-fpm on the PHP version of User's Choice
- Enabling http/2 protocol and brotli compression
- Configuring the PHP fpm pool by adding a new specific configuration file for your.local.domain.tld, with security profiles (dev/staging/hardened)
- Automatically managing
/etc/hostsentries for your local domains - Providing configurable PHP-FPM security profiles for different use cases
Security
This tool is not intended to be used on internet-facing LAMP environments. It's intended to be used on local devices, or any other Cloud VM that is properly firewalled.
This is because this tool configures Apache and PHP with presets that are good only for local developing, testing and benchmarking.
For more informations, refer to LAMP Stack Hardening and Linux Security Bookmarks.
Installation
The easiest way to get started with Hte-Cli is to download the Phar files for each of the commands:
Global Composer Package
If you use Composer, you can install Hte-Cli system-wide with the following command:
Make sure you have the composer bin dir in your PATH.
The default value should be ~/.composer/vendor/bin/, but you can check the value that you need to use by running composer global config bin-dir --absolute
The HTE-Cli Tool will then be available on $(composer config -g home)/vendor/bin/hte-cli
It is suggested to modify your bash profile to expand your $PATH so that it includes the composer/vendor/bin directory. To do so, you can modify your .bashrc file by executing:
Composer Dependency
Alternatively, include a dependency for mfonte/hte-cli in your composer.json file on a specific project. For example:
You will then be able to run Hte-Cli from the vendor bin directory:
You can then create some Bash Aliases for your convenience:
Git Clone
You can also download the Hte-Cli source, and run your own hte-cli build:
Build setup is made possible via humbug/box. See Laravel Zero Doc for the internals of building a Laravel Zero app.
Environment Pre-requisites
As said before, this utility is intended to be used on Debian or Ubuntu , with Multi PHP-FPM support.
This means that you must have a LAMP stack compatible with multiple PHP versions and configured to use PHP-FPM by default. You can achieve this by following the instructions below:
The important things are:
- disable
mpm_preforkmodule - disable all
php**handler modules - enable all
php**-fpmhandler modules - enable
fcgid,mpm_event,proxy_fcgi,aliasmodules (and, obviously,sslandrewrite) -http2,brotli,headers,setenvifare optional, but suggested.
Usage
Create a new test LAMP Env
To create a new LAMP local testing/developing VirtualHost, run the HTE-Cli tool with option create.
In this example, the HTE-Cli create has been aliased with the hte-create command.
Command Line Options for Create
You can also run the create command non-interactively:
Modify an existing VirtualHost
To modify an existing VirtualHost configuration, use the modify command. This command provides an interactive menu to change any aspect of your VirtualHost.
Command Line Options for Modify
You can also run modify non-interactively:
Delete a Test Env created via HTE-Cli
To remove a LAMP local testing/developing VirtualHost previously created with HTE-Cli Tool, run the HTE-Cli tool with option remove.
The remove command now features an interactive selection menu and automatic index normalization.
Command Line Options for Remove
List all Test Envs created via HTE-Cli
To list all LAMP local environments previously created with HTE-Cli Tool, run the HTE-Cli tool with option details.
Fix old VirtualHost configurations
If you have VirtualHosts created with an older version of HTE-CLI, they may not have the localhost HTTPS bypass feature. The fix command updates these configurations.
Command Line Options for Fix
Manage /etc/hosts
The hosts command helps you manage /etc/hosts entries for domains created by HTE-CLI:
Example output for hosts list:
Example output for hosts sync:
PHP-FPM Security Profiles
HTE-CLI supports three security profiles for PHP-FPM pools, allowing you to balance between development convenience and security:
| Profile | Description | Use Case |
|---|---|---|
dev |
Minimal restrictions, high memory limits (1024M), basic disabled functions | Local development |
staging |
Moderate security with open_basedir, session hardening, pm.max_requests |
Staging/testing environments |
hardened |
Maximum restrictions, many functions disabled | Security testing only |
Profile Details
Dev Profile (Default)
- Memory limit: 1024M
- Disabled functions: Basic Apache functions only
- Best for: Day-to-day development work
Staging Profile
- Memory limit: 1024M
- Additional disabled functions:
dl,highlight_file,show_source,phpinfo - Additional security:
open_basedirrestricted to document root + /tmp + /usr/share/php- Session cookie
httponlyflag enabled - Session strict mode enabled
pm.max_requests = 500to prevent memory leaks
- Best for: Pre-production testing, CI/CD environments
Hardened Profile
- Memory limit: 256M
- Additional disabled functions:
exec,shell_exec,system,passthru,popen,proc_open,proc_close,proc_get_status,proc_terminate,pcntl_exec,pcntl_fork,pcntl_signal,symlink - Additional security:
- All staging security features
- Auto prepend/append files disabled
- PHP version hidden
- Reduced resource limits
- Best for: Security testing
Warning: The hardened profile disables exec, proc_open, and other functions used by Artisan, Composer, and PHPUnit. Use it only for security testing purposes.
Usage
Command Reference
Available Commands
| Command | Description |
|---|---|
create |
Create a new VirtualHost with PHP-FPM |
modify |
Modify an existing VirtualHost configuration |
remove |
Delete a VirtualHost and all its configurations |
details |
List all VirtualHosts with detailed information |
hosts |
Manage /etc/hosts entries |
fix |
Fix old VirtualHost configs to add localhost HTTPS bypass |
Command Options
create
| Option | Description | Default |
|---|---|---|
--domain= |
Domain name for the VirtualHost | (interactive) |
--docroot= |
Document root path | (interactive) |
--phpver= |
PHP version (e.g., 8.4, 8.3, 7.4) | Latest installed |
--ssl= |
Enable SSL (yes/no) | yes |
--forcessl= |
Force HTTPS redirect (yes/no) | yes |
--hosts= |
Add to /etc/hosts (yes/no) | yes |
--profile= |
PHP-FPM profile (dev/staging/hardened) | dev |
modify
| Option | Description |
|---|---|
--domain= |
Domain name to modify |
--phpver= |
New PHP version |
--ssl= |
Enable/disable SSL (yes/no) |
--forcessl= |
Enable/disable force HTTPS (yes/no) |
--profile= |
New PHP-FPM profile |
--docroot= |
New document root |
--interactive |
Force interactive mode |
remove
| Option | Description |
|---|---|
--domain= |
Domain name to remove |
--force |
Skip confirmation prompt |
--no-normalize |
Skip index normalization |
hosts
| Subcommand | Description |
|---|---|
list |
Show domains in /etc/hosts managed by hte-cli |
sync |
Sync /etc/hosts with configured VirtualHosts |
add --domain= |
Add a domain to /etc/hosts |
remove --domain= |
Remove a domain from /etc/hosts |
fix
| Option | Description |
|---|---|
--domain= |
Fix a specific domain only |
--force |
Skip confirmation prompt |
--dry-run |
Preview changes without applying them |
Localhost HTTPS Bypass
When Force HTTPS is enabled, HTE-CLI configures Apache to allow HTTP access from localhost (127.0.0.1 and ::1). This means:
- From localhost:
curl http://myapp.testworks without redirect - From external: Browser requests are redirected to HTTPS
This is useful for local development tools, scripts, and API testing that don't handle SSL certificates well.
.htaccess Override Warning
If your document root contains an .htaccess file with its own HTTPS redirect rules, those will override the VirtualHost configuration. The fix command automatically detects this situation and provides instructions to modify your .htaccess file.
Example .htaccess modification for localhost bypass:
Credits
A big thank you goes to Nuno Maduro and Owen Voke for their Laravel Zero micro-framework.
Contributing
See DEVELOPMENT.md for development setup, coding standards, and contribution guidelines.
License
MIT License - see LICENSE for details.