diff --git a/.env.dist b/.env.dist index dbc3273..1ada944 100644 --- a/.env.dist +++ b/.env.dist @@ -1,12 +1,24 @@ -STAGE = production -BASE_URL = http://localhost:63000 -database_driver = mysql -database_host = mysql -database_database = plugi -database_username = plugi -database_password = plugi -database_charset = utf8 -database_collation = utf8_unicode_ci -database_prefix = -USERNAME = admin -PASSWORD = admin +STAGE=production +BASE_URL=http://localhost:63000 + +DATABASE_DRIVER=mysql +DATABASE_HOST=mysql +DATABASE_DATABASE=plugi +DATABASE_USERNAME=plugi +DATABASE_PASSWORD=change-me +DATABASE_CHARSET=utf8mb4 +DATABASE_PREFIX= +MYSQL_ROOT_PASSWORD=change-me-root + +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 diff --git a/.gitignore b/.gitignore index 6a3b344..7495b29 100644 --- a/.gitignore +++ b/.gitignore @@ -12,11 +12,12 @@ dist-ssr *.local .env +/config.php +/docs cache uploads extensions/dev_* -docs .agents skills-lock.json @@ -31,3 +32,5 @@ skills-lock.json *.njsproj *.sln *.sw? + +.DS_Store diff --git a/Dockerfile b/Dockerfile index ae25c31..b62a518 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,8 @@ FROM php:8.4-apache-bookworm WORKDIR "/var/www/html" RUN apt-get update; \ - docker-php-ext-install pdo pdo_mysql; \ + docker-php-ext-install pdo_mysql; \ apt-get -y --no-install-recommends install \ - git \ - php8.4-mysql; \ + git; \ apt-get clean; \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* diff --git a/README.md b/README.md index 62baab7..ca5bcc3 100644 --- a/README.md +++ b/README.md @@ -2,24 +2,23 @@ > A fork of [PHPagebuilder](https://github.com/HansSchouten/PHPagebuilder) by [Hans Schouten](https://github.com/HansSchouten). -> Still a work-in-progress +Plugi is a website boilerplate with a drag-and-drop page builder. -This boilerplate defines the project structure for quickly creating a website that can be managed with a drag and drop -pagebuilder. +## Quick installation -## Installation +1. Use PHP 8.4 with the PDO MySQL extension and a MySQL 8 database. The supplied Docker image is based on PHP 8.4. +2. Copy `.env.dist` to `.env` and `config.dist.php` to `config.php`; set the database connection, public `BASE_URL`, and a unique admin username and password hash in `.env`. +3. Create the database and a database user, deploy the project at the web root, and make `uploads/` writable by the web server. +4. Open the site, sign in at `/admin/auth`, and follow the Website Manager database update prompt to create/update the schema. -To setup your website download the latest version of Plugi and upload it to the webroot directory of your website. +See the [Plugi documentation](https://plugi.paulspenke.com/) for the full installation guide, including manual deployment, Docker development, security, and troubleshooting. -### Edit the config file -The file `config.php` holds all the basic configuration for your project. Edit as needed. Be sure to update the -login-credentials. +## Local Docker development -### Login -Now you should be able to log in to the admin panel by going to the `/admin` URL of your website using `admin` and -`admin` (you can change these in the config file). If you are able to login you can start building your website. +The supplied Compose stack uses PHP 8.4 and MySQL 8.0 and is for local development only. Copy `.env.dist` to `.env` and `config.dist.php` to `config.php`, replace the sample database and MySQL root passwords, then run: -Note: make sure to disable error reporting in `index.php` once your website goes into production! +```sh +docker compose up --build -d +``` -## Docker -Simply run `docker-compose up -d` using the supplied `docker-compose.yml`. The image uses PHP 8.2 +The app is available at `http://localhost:63000`; Adminer is bound to localhost at `http://localhost:63001`. diff --git a/config.dist.php b/config.dist.php index 05b625a..9e1e14f 100644 --- a/config.dist.php +++ b/config.dist.php @@ -20,7 +20,7 @@ return [ | Storage settings |-------------------------------------------------------------------------- | - | Database and file storage settings. + | File storage settings. | */ 'storage' => [ @@ -161,14 +161,14 @@ return [ 'mail' => [ 'class' => Plugi\Core\Mailer::class, 'transport' => 'smtp', - 'host' => '', - 'port' => 587, - 'encryption' => 'tls', - 'username' => '', - 'password' => '', - 'from_address' => '', - 'from_name' => '', - 'timeout' => 10, + 'host' => $_ENV['MAIL_HOST'] ?? '', + 'port' => (int) ($_ENV['MAIL_PORT'] ?? 587), + 'encryption' => $_ENV['MAIL_ENCRYPTION'] ?? 'tls', + 'username' => $_ENV['MAIL_USERNAME'] ?? '', + 'password' => $_ENV['MAIL_PASSWORD'] ?? '', + 'from_address' => $_ENV['MAIL_FROM_ADDRESS'] ?? '', + 'from_name' => $_ENV['MAIL_FROM_NAME'] ?? '', + 'timeout' => (int) ($_ENV['MAIL_TIMEOUT'] ?? 10), ], /* diff --git a/docker-compose.yml b/docker-compose.yml index 3453802..5fe0442 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,4 @@ +# Development only. Do not use this Compose stack for production deployments. services: web: build: . @@ -7,7 +8,28 @@ services: depends_on: - mysql ports: - - '63000:80' + - '127.0.0.1:63000:80' + environment: + STAGE: ${STAGE:-production} + BASE_URL: ${BASE_URL:-http://localhost:63000} + DATABASE_DRIVER: ${DATABASE_DRIVER:-mysql} + DATABASE_HOST: ${DATABASE_HOST:-mysql} + DATABASE_DATABASE: ${DATABASE_DATABASE:-plugi} + DATABASE_USERNAME: ${DATABASE_USERNAME:-plugi} + DATABASE_PASSWORD: ${DATABASE_PASSWORD:-change-me} + DATABASE_CHARSET: ${DATABASE_CHARSET:-utf8mb4} + DATABASE_PREFIX: ${DATABASE_PREFIX:-} + USERNAME: ${USERNAME:-admin} + PASSWORD: ${PASSWORD:-} + PASSWORD_HASH: ${PASSWORD_HASH:-} + MAIL_HOST: ${MAIL_HOST:-} + MAIL_PORT: ${MAIL_PORT:-587} + MAIL_ENCRYPTION: ${MAIL_ENCRYPTION:-tls} + MAIL_USERNAME: ${MAIL_USERNAME:-} + MAIL_PASSWORD: ${MAIL_PASSWORD:-} + MAIL_FROM_ADDRESS: ${MAIL_FROM_ADDRESS:-} + MAIL_FROM_NAME: ${MAIL_FROM_NAME:-} + MAIL_TIMEOUT: ${MAIL_TIMEOUT:-10} links: - mysql networks: @@ -15,7 +37,7 @@ services: adminer: image: adminer ports: - - 63001:8080 + - '127.0.0.1:63001:8080' links: - mysql networks: @@ -24,13 +46,12 @@ services: image: "mysql:8.0" restart: 'always' volumes: - - '.:/application' - db:/var/lib/mysql:cached environment: - - MYSQL_ROOT_PASSWORD=root - - MYSQL_DATABASE=plugi - - MYSQL_USER=plugi - - MYSQL_PASSWORD=plugi + MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-change-me-root} + MYSQL_DATABASE: ${DATABASE_DATABASE:-plugi} + MYSQL_USER: ${DATABASE_USERNAME:-plugi} + MYSQL_PASSWORD: ${DATABASE_PASSWORD:-change-me} # ports: # - '63002:3306' networks: diff --git a/index.php b/index.php index f3a9ea6..aaac47f 100644 --- a/index.php +++ b/index.php @@ -1,7 +1,7 @@ load(); +(new Plugi\Core\EnvLoader(__DIR__ . '/.env'))->load(); if ($_ENV['STAGE'] !== 'production') { ini_set('display_errors', 1);