An open API service indexing awesome lists of open source software.

https://github.com/mbpcoder/devlet

DevLet is a local Apache vhost manager for PHP projects. It auto-detects domain and PHP version (from .devlet or composer.json), creates SSL configs using mkcert, updates /etc/hosts, and enables required Apache modules โ€” perfect for WSL and Linux dev environments.
https://github.com/mbpcoder/devlet

Last synced: 5 months ago
JSON representation

DevLet is a local Apache vhost manager for PHP projects. It auto-detects domain and PHP version (from .devlet or composer.json), creates SSL configs using mkcert, updates /etc/hosts, and enables required Apache modules โ€” perfect for WSL and Linux dev environments.

Awesome Lists containing this project

README

          

# DevLet โ€” Local Development Environment Auto-Configurator

**DevLet** is a PHP-based CLI tool built for Laravel Artisan that automates the configuration of local development environments using Apache, SSL (via mkcert), and PHP-FPM.

It streamlines developer onboarding by managing domain setup, certificate generation, and system-level configuration based on a per-project `.devlet` file or `composer.json` fallback.

---

## ๐Ÿš€ Features

- ๐Ÿ” **Project Auto-Discovery** โ€” Scans source directories to detect Laravel or PHP projects
- ๐Ÿงพ **`.devlet` Support** โ€” Define project-specific domain and PHP version
- ๐Ÿ“ฆ **Composer Integration** โ€” Parses `composer.json` to extract PHP version if `.devlet` is missing
- ๐Ÿ” **SSL Certificates with mkcert** โ€” Automatically generates trusted certificates for each domain (supports WSL)
- ๐ŸŒ **Apache VirtualHost Generator** โ€” Generates VHost files with full PHP-FPM, SSL, redirect support
- ๐Ÿ““ **/etc/hosts Sync** โ€” Adds domain entries to the local `/etc/hosts` file
- โ†ช๏ธ **www to non-www Redirects** โ€” Auto-redirect `www.domain` to `domain` securely over HTTPS
- ๐Ÿงฉ **Laravel 12 Artisan Commands** โ€” Modular Laravel Artisan command structure

---

## ๐Ÿ“ Example `.devlet` File

Define custom domain and PHP version per project:

```ini
domain=api.local
php=8.2
```

If this file is missing, DevLet will fallback to `composer.json` and extract `"php": "^8.2"` from `require`.

---

## ๐Ÿงช Example Apache VHost (Generated)

```apache

ServerName api.local
ServerAlias www.api.local
Redirect permanent / https://api.local/

ServerName api.local
ServerAlias www.api.local

DocumentRoot "/home/user/Projects/api/public"

SSLEngine on
SSLCertificateFile /etc/ssl/certs/api.local.pem
SSLCertificateKeyFile /etc/ssl/private/api.local-key.pem

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]


SetHandler "proxy:unix:/run/php/php8.2-fpm.sock|fcgi://localhost/"


AllowOverride All
Require all granted

ErrorLog ${APACHE_LOG_DIR}/api.local-error.log
CustomLog ${APACHE_LOG_DIR}/api.local-access.log combined

```

---

## ๐Ÿงฐ Available Artisan Commands

### ๐Ÿ› ๏ธ `devlet:os-install`
Installs necessary packages based on `config/devlet.php`.
Handles PHP, Apache, SSL tools, and more.

### โœ… `devlet:os-verify`
Verifies required software and system configuration.

### โš™๏ธ `devlet:configure`
Auto-configures VHosts, SSL, hosts file, and PHP-FPM mappings.

---

## ๐Ÿง  How It Works

1. Scan all project directories (from config)
2. Parse `.devlet` or fallback to `composer.json`
3. Normalize and generate domain names
4. Create and trust SSL certificates (even under WSL)
5. Write Apache config files using Laravel stubs
6. Enable site, reload Apache
7. Update `/etc/hosts` file

---

## ๐Ÿ“‚ Configurable via `config/devlet.php`

- Project source directories
- Default PHP fallback version
- Apache vhost path
- SSL cert locations
- Auto-reload flags

---

## ๐Ÿชช Notes

- DevLet is strictly for **local development**
- Certificates are stored in `/etc/ssl/certs/` and `/etc/ssl/private/`
- Apache configs are prefixed with `devlet-`
- Auto-cleanup stale configs when projects are removed

---

## ๐Ÿค Contributing

Pull requests, ideas, and improvements are welcome!

---

## ๐Ÿ“œ License

MIT License ยฉ Your Name