update docs

This commit is contained in:
2026-11-27 17:23:32 +01:00
parent 200aee2106
commit f347ce126a
5 changed files with 165 additions and 89 deletions
+32 -16
View File
@@ -2,28 +2,44 @@
Plugi is configured through two files:
- **`.env`** — Environment variables for database connection and application stage.
- **`config.php`** — PHP array that controls all framework behavior, modules, themes, and extensions.
- **`.env`** — Environment-specific database, stage, admin-login, and mail settings.
- **`config.php`** — PHP array that controls framework behavior, modules, themes, and extensions; copy it from `config.dist.php` for a fresh checkout.
## The `.env` File
The `.env` file is loaded by `EnvLoader` at boot time. It must exist in the project root. Typical contents:
The `.env` file is loaded from the project root by `EnvLoader` at boot time. Start with `.env.dist` and use the exact variable names below:
```ini
DB_HOST=mysql
DB_NAME=plugi
DB_USER=plugi
DB_PASSWORD=plugi
STAGE=development
STAGE=production
BASE_URL=https://example.com
DATABASE_DRIVER=mysql
DATABASE_HOST=localhost
DATABASE_DATABASE=plugi
DATABASE_USERNAME=plugi
DATABASE_PASSWORD=replace-with-a-unique-password
DATABASE_CHARSET=utf8mb4
DATABASE_PREFIX=
USERNAME=admin
PASSWORD=
PASSWORD_HASH=
MAIL_HOST=
MAIL_PORT=587
MAIL_ENCRYPTION=tls
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_FROM_ADDRESS=
MAIL_FROM_NAME=
MAIL_TIMEOUT=10
```
| Variable | Description | Default |
|----------------|----------------------------------------------|------------------|
| `DB_HOST` | MySQL host (e.g., `localhost` or `mysql`) | `mysql` |
| `DB_NAME` | Database name | `plugi` |
| `DB_USER` | Database user | `plugi` |
| `DB_PASSWORD` | Database password | `plugi` |
| `STAGE` | Application stage (`development` or `production`) | `development` |
| Variables | Purpose |
|-----------|---------|
| `STAGE`, `BASE_URL` | Select the application stage and public URL. Set the stage to `production` for a deployed site. |
| `DATABASE_DRIVER`, `DATABASE_HOST`, `DATABASE_DATABASE`, `DATABASE_USERNAME`, `DATABASE_PASSWORD`, `DATABASE_CHARSET`, `DATABASE_PREFIX` | Database connection settings read by `DB`. Use `DATABASE_HOST=mysql` only when connecting to the supplied Compose service. |
| `USERNAME`, `PASSWORD_HASH`, `PASSWORD` | Admin login read by the Auth module. Prefer `PASSWORD_HASH`; `PASSWORD` is a legacy plaintext fallback. |
| `MAIL_HOST`, `MAIL_PORT`, `MAIL_ENCRYPTION`, `MAIL_USERNAME`, `MAIL_PASSWORD`, `MAIL_FROM_ADDRESS`, `MAIL_FROM_NAME`, `MAIL_TIMEOUT` | SMTP settings mapped from the environment into the existing mail configuration by `config.php` / `config.dist.php`. |
`MYSQL_ROOT_PASSWORD` is only used by the local Compose database container; it is not the application's database password. Keep `.env` private and never commit it.
Setting `STAGE=production` disables PHP error display in `index.php`.
@@ -77,7 +93,7 @@ Copy `config.dist.php` to `config.php` and adjust the settings. The configuratio
| `class` | Fully qualified class name implementing `AuthContract`. |
| `url` | URL prefix for auth endpoints (login/logout). |
The default `Auth` class checks credentials stored in the database settings table. Change the admin username and password from the admin panel after first login.
The default `Auth` class reads `USERNAME` and either `PASSWORD_HASH` or the legacy `PASSWORD` value from `.env`; credentials are not configured in the PHP `auth` array. Use a password hash for deployments and leave `PASSWORD` empty.
### Website Manager Settings
+14 -61
View File
@@ -1,70 +1,23 @@
# Getting Started
This guide will help you get Plugi up and running on your local machine or server.
This guide introduces Plugi and links to the complete [installation guide](installation.md), which covers fresh manual deployments and local Docker development.
## Requirements
- **PHP 8.2** or higher
- **MySQL 8.0** or higher
- **Apache** or **Nginx** web server
- **PDO MySQL** extension enabled
- **PHP 8.4** with the **PDO MySQL** extension
- **MySQL 8.0** or a compatible MySQL server
- **Apache** with the required routing support for a manual deployment
- **Docker Compose** for the optional local development stack
## Installation
## Setup summary
### Option 1: Manual Installation
1. Copy `.env.dist` to `.env` and `config.dist.php` to `config.php`.
2. Set the database connection, public base URL, and admin credentials in `.env`.
3. Create an empty database and a dedicated database user, then make `uploads/` writable by the web-server user.
4. Open the site and sign in at `/admin/auth`.
5. Use the Website Manager database update flow to create or update the schema.
1. **Download Plugi** and upload it to the webroot directory of your website.
2. **Create the `.env` file** by copying `.env.example` (if available) or creating one with the following variables:
```ini
DB_HOST=mysql
DB_NAME=plugi
DB_USER=plugi
DB_PASSWORD=plugi
STAGE=development
```
Adjust the database credentials to match your MySQL server.
3. **Create the config file** by copying `config.dist.php` to `config.php`:
```bash
cp config.dist.php config.php
```
4. **Edit `config.php`** and update the settings as needed. At a minimum, change the default login credentials in the `auth` section.
5. **Set up the database**. On first access, Plugi will create the required tables automatically. If the database schema changes in a future version, the admin panel will prompt you to update it.
6. **Access the admin panel** by navigating to `/admin` on your website and logging in with the credentials you set in `config.php` (defaults are `admin` / `admin`).
### Option 2: Docker
The quickest way to get started is with Docker Compose:
1. **Clone or download** the Plugi repository.
2. **Create the `.env` file** with your environment variables (see above).
3. **Create `config.php`** from `config.dist.php`:
```bash
cp config.dist.php config.php
```
4. **Start the services**:
```bash
docker-compose up -d
```
This will start three services:
- **Web** (PHP 8.2 + Apache) on port `63000`
- **MySQL 8.0** database
- **Adminer** (database management) on port `63001`
5. **Open your browser** and navigate to `http://localhost:63000/admin` to access the admin panel.
See the [installation guide](installation.md) for exact environment variable names, database provisioning, the schema update process, production security, and Docker-specific steps. The supplied Compose stack is for local development only.
## First Steps
@@ -105,10 +58,10 @@ project-root/
Before deploying to production:
1. Set `STAGE=production` in your `.env` file to disable error reporting.
2. Change the default admin credentials in `config.php`.
2. Set a unique admin username and a `PASSWORD_HASH` in `.env`; do not use the legacy plaintext `PASSWORD` setting in production.
3. Enable caching in `config.php` (`cache.enabled => true`) for better performance.
4. Ensure the `uploads/` directory is writable but not executable.
5. Consider using `.htaccess` (Apache) or Nginx config to serve `/uploads` directly, bypassing PHP for faster file delivery.
5. Configure the web server to serve uploaded files safely; do not allow uploaded PHP files to execute.
## Next Steps
+13 -12
View File
@@ -8,20 +8,20 @@ A lightweight PHP-based website builder with a drag-and-drop page editor, themin
## Quick Start
Get up and running in minutes:
Follow the [installation guide](installation.md) for complete manual deployment and local Docker instructions. In brief:
1. **Download** Plugi and upload it to your webroot.
2. **Create** a `.env` file with your database credentials.
3. **Copy** `config.dist.php` to `config.php` and adjust settings.
4. **Navigate** to `/admin` and log in with the default credentials (`admin` / `admin`).
1. Use PHP 8.4 with `pdo_mysql` and MySQL 8.0 or a compatible database.
2. Copy `.env.dist` to `.env` and `config.dist.php` to `config.php`.
3. Configure the database, public `BASE_URL`, and a unique admin login in `.env`; create the database and user.
4. Sign in at `/admin/auth` and apply the schema through the Website Manager database update flow.
Or use Docker for a quick local setup:
For local development only, the Compose stack starts with:
```bash
docker-compose up -d
docker compose up --build -d
```
Then open `http://localhost:63000/admin` in your browser.
Then open `http://localhost:63000`. Do not use the supplied Compose stack as a production deployment.
## Key Features
@@ -30,22 +30,23 @@ Then open `http://localhost:63000/admin` in your browser.
- **Extensions** — Extend functionality with plugins that add routes, admin pages, blocks, and more.
- **Multilingual** — Built-in translation support for pages, themes, and extensions.
- **Caching** — Optional page caching for production performance.
- **Database-Driven** — All content stored in MySQL with automatic schema management.
- **Database-Driven** — All content is stored in MySQL; create or update the schema through the Website Manager.
## Documentation
| Section | Description |
|---------|-------------|
| [Getting Started](GettingStarted.md) | Installation, requirements, and first steps. |
| [Installation](installation.md) | Manual deployment, local Docker development, database setup, and security guidance. |
| [Getting Started](GettingStarted.md) | Requirements and a short setup overview. |
| [Configuration](Configuration.md) | Full reference for `.env` and `config.php` settings. |
| [Themes](Themes.md) | How to create and structure custom themes with blocks and layouts. |
| [Extensions](Extensions.md) | How to build extensions that add routes, admin pages, blocks, and more. |
## Requirements
- **PHP 8.2** or higher
- **PHP 8.4**
- **MySQL 8.0** or higher
- **Apache** or **Nginx** web server
- **Apache** web server for the documented manual setup
- **PDO MySQL** extension enabled
## Project Structure
+1
View File
@@ -2,6 +2,7 @@
- [Home](Readme.md)
- [Getting Started](GettingStarted.md)
- [Installation](installation.md)
- [Configuration](Configuration.md)
- Customization
+105
View File
@@ -0,0 +1,105 @@
# Installation
This guide covers a fresh manual deployment and the supplied local Docker development stack.
## Requirements
- Use PHP 8.4, the runtime used by the supplied Docker image (`php:8.4-apache-bookworm`).
- Enable PHP's PDO MySQL driver (`pdo_mysql`).
- MySQL 8.0 or a compatible MySQL server.
- For Apache, enable `mod_rewrite` and `mod_dir`, allow `.htaccess` overrides for the project directory, and use the repository root as the document root. The included `.htaccess` uses `FallbackResource /index.php` for application routes.
- The web-server user needs write access to the project `uploads/` directory.
## Configure the environment
From the project root, create the local environment and PHP configuration files required by the bootstrap:
```sh
cp .env.dist .env
cp config.dist.php config.php
```
The application loads `.env` from the project root, regardless of the web server's working directory. Keep both generated files local; `.env` and `config.php` are ignored by Git. Edit `.env` before serving the site:
| Variable | Purpose |
| --- | --- |
| `STAGE` | Use `production` for a deployed site. |
| `BASE_URL` | Public URL for the installation, for example `https://example.com`. For a subdirectory deployment, also configure the web server to route requests to this installation. |
| `DATABASE_DRIVER` | Use `mysql`. |
| `DATABASE_HOST` | Database server hostname; use `mysql` only when connecting to the Compose service. |
| `DATABASE_DATABASE` | Database name. |
| `DATABASE_USERNAME` / `DATABASE_PASSWORD` | Application database user credentials. |
| `DATABASE_CHARSET` | The DB connection charset; `utf8mb4` is recommended. |
| `DATABASE_PREFIX` | Optional table prefix; leave empty unless required. |
| `MYSQL_ROOT_PASSWORD` | Compose-only MySQL root password; set it for local Docker development and do not use it as the app's database password. |
| `USERNAME` | Admin login name read directly by the existing Auth module. |
| `PASSWORD_HASH` | Recommended admin password value; generate it as shown below. |
| `PASSWORD` | Legacy plaintext fallback. Leave empty when using `PASSWORD_HASH`. |
| `MAIL_HOST`, `MAIL_PORT`, `MAIL_ENCRYPTION` | SMTP server settings. Encryption may be `tls`, `ssl`, or `none`. |
| `MAIL_USERNAME`, `MAIL_PASSWORD` | SMTP authentication credentials; leave empty when not required. |
| `MAIL_FROM_ADDRESS`, `MAIL_FROM_NAME` | Sender identity used by the mailer. |
| `MAIL_TIMEOUT` | SMTP connection timeout in seconds. |
Generate a password hash with PHP, then paste the output into `PASSWORD_HASH`:
```sh
php -r 'echo password_hash("choose-a-unique-password", PASSWORD_DEFAULT), PHP_EOL;'
```
`PASSWORD_HASH` takes precedence over `PASSWORD`. The plaintext option remains only for backward compatibility; do not use it for a production deployment. Keep `.env` private, restrict its filesystem permissions, and ensure the web server cannot serve dotfiles. Never commit it.
## Manual deployment
1. Install PHP 8.4 with `pdo_mysql`, MySQL 8, and Apache with the modules and `.htaccess` settings listed above.
2. Create an empty database and a dedicated application user. Grant that user the permissions needed to create and alter tables in this database; do not use the MySQL root account for the app.
For a local MySQL server, an administrator can use SQL similar to the following, replacing the sample password and adapting the user host for your deployment:
```sql
CREATE DATABASE plugi CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'plugi'@'localhost' IDENTIFIED BY 'replace-with-a-unique-password';
GRANT ALL PRIVILEGES ON plugi.* TO 'plugi'@'localhost';
```
3. Place the project in the web root, copy `.env.dist` to `.env` and `config.dist.php` to `config.php`, and set the database name, user, password, host, public `BASE_URL`, admin login, and any SMTP settings. For a non-Docker deployment, `DATABASE_HOST` is usually `localhost` or the database host provided by your hosting provider—not `mysql` unless the host is actually named `mysql`.
4. Make `uploads/` writable by the PHP/web-server user. Use the narrowest owner/group permissions appropriate to your server; avoid making the whole project world-writable.
5. Open the configured `BASE_URL`. Sign in with the `USERNAME` and password represented by `PASSWORD_HASH` at `/admin/auth`.
6. On a fresh or outdated database, Plugi directs the administrator to the Website Manager database information/update flow. Use its database update action to create or update the schema, then reload the site.
The current schema definition is `plugi-core/config/tables.php`; the Website Manager update action applies the schema expected by the running application. Do not use `plugi-core/config/create-tables.sql` for a fresh setup: it is an old 2023 export and can be out of date. Back up any existing database before applying schema updates.
## Local Docker development
The Compose stack is intended for local development only, not production. It uses PHP 8.4, MySQL 8.0, and the database hostname `mysql`; the web app and Adminer ports are bound to `127.0.0.1`.
1. Copy `.env.dist` to `.env` and `config.dist.php` to `config.php`.
2. Set unique values for `DATABASE_PASSWORD` and `MYSQL_ROOT_PASSWORD` in `.env`. The same `DATABASE_PASSWORD`, `DATABASE_DATABASE`, and `DATABASE_USERNAME` values are used to initialize MySQL and connect the app. These values are development examples only.
3. Keep `DATABASE_HOST=mysql` and set `BASE_URL=http://localhost:63000` for the supplied ports. Set the admin login and password hash as described above.
4. Start the stack from the project root:
```sh
docker compose up --build -d
```
5. Open `http://localhost:63000`, sign in at `/admin/auth`, and use the Website Manager database update flow when prompted. Adminer is available at `http://localhost:63001`; its database server name is `mysql`.
The MySQL data is stored in a named volume. `docker compose down` stops the stack without removing that volume; avoid `docker compose down -v` unless you intend to delete the database. Do not expose this development stack, its sample credentials, or Adminer as a production service.
## Production and credential safety
- Use HTTPS, production-strength unique credentials, and least-privilege database access. Keep `.env` out of version control and inaccessible over HTTP.
- Configure the production web server to deny access to dotfiles and to the `.env` file explicitly; do not rely on a local Docker or Apache default for this protection.
- The Compose stack and Adminer are development tools, not a production deployment recipe. Configure and harden production PHP, web server, database, backups, and monitoring separately.
- SMTP credentials were previously present in tracked configuration. Treat them as exposed and rotate them with the mail provider; removing them from the current files does not remove them from Git history.
## Troubleshooting
- **Missing `.env`:** Copy `.env.dist` to `.env` in the project root. The loader requires this file at startup.
- **Missing `config.php`:** Copy the tracked `config.dist.php` to `config.php` in the project root; the bootstrap requires the local config file.
- **Database connection refused:** Check that MySQL is running and `DATABASE_HOST` is correct. Use `mysql` inside Compose and the actual host/`localhost` for a manual deployment.
- **Access denied or unknown database:** Check the exact `DATABASE_*` names, database name, password, and grants. In Compose, the app and MySQL service must use the same database credentials.
- **Schema update repeats or fails:** Confirm the database user can create/alter tables, back up existing data, and retry the Website Manager update flow. The application schema source is `plugi-core/config/tables.php`.
- **Routes return 404 or the homepage is served incorrectly:** Confirm the project root is the document root, `.htaccess` overrides are allowed, and Apache's `mod_rewrite` and `mod_dir` modules are enabled.
- **A Docker port is already in use:** Change the host-side port mapping in `docker-compose.yml` (for example, map `63002:80` instead of `63000:80`) and update `BASE_URL` in `.env` to the matching local URL. Do the same for Adminer if port `63001` is occupied.
- **Uploads fail:** Confirm the web-server user can write to `uploads/` and that the configured storage path points to the project directory.
- **Mail does not send:** Check the `MAIL_*` settings, sender address, SMTP port/encryption, and whether the provider requires authentication. The app will not have usable SMTP settings until configured.