### Complete Plugin Directory Structure Example Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/plugins.md This structure illustrates a comprehensive plugin setup including CSS, JavaScript, and translation files, demonstrating a full integration of plugin features. ```text /content/plugins/EnhancedExample/ ├── EnhancedExamplePlugin.php ├── assets/ │ ├── style.css │ ├── admin-style.css │ ├── script.js │ └── admin-script.js └── translations/ ├── language_en.php ├── language_de.php └── language_fr.php ``` -------------------------------- ### Install phpMyFAQ Locally from GitHub Source: https://github.com/thorsten/phpmyfaq/blob/main/README.md Clone the repository, checkout the main branch, install Composer and pnpm dependencies, build the project, and access the setup page in your browser. ```bash $ git clone git://github.com/thorsten/phpMyFAQ.git $ cd phpMyFAQ $ git checkout main $ curl -s https://getcomposer.org/installer | php $ php composer.phar install $ curl -fsSL https://get.pnpm.io/install.sh | sh - $ pnpm install $ pnpm build ``` -------------------------------- ### Start FrankenPHP Service with Docker Compose Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/installation.md Use this command to start the FrankenPHP service when using Docker Compose for installation. Access phpMyFAQ via https://localhost after it starts. ```bash # Start FrankenPHP service docker-compose up frankenphp # Access phpMyFAQ at https://localhost ``` -------------------------------- ### Install phpMyFAQ using Git and Composer Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/installation.md Clone the repository, install Composer dependencies, and build the project. Ensure you have Git, Composer, and pnpm installed. ```bash $ git clone git@github.com:thorsten/phpMyFAQ.git 4.2 $ cd phpMyFAQ $ curl -s https://getcomposer.org/installer | php $ php composer.phar install $ curl -fsSL https://get.pnpm.io/install.sh | sh - $ pnpm install $ pnpm build ``` -------------------------------- ### Copying Environment Example File Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/development.md Create a local .env file for your project by copying the provided example configuration. This sets up your initial environment variables. ```bash cp .env.example .env ``` -------------------------------- ### Start Docker Compose Services Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/docker-cheatsheet.md Use these commands to start all services, a specific service, or rebuild and start services. ```bash # Start all services docker-compose -f docker-compose.prod.yml up -d ``` ```bash # Start specific service docker-compose -f docker-compose.prod.yml up -d apache ``` ```bash # Start with build docker-compose -f docker-compose.prod.yml up -d --build ``` -------------------------------- ### Start FrankenPHP Server Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/installation.md Run the FrankenPHP server using the specified configuration file. This command starts the application server. ```bash sudo frankenphp run --config /path/to/your/Caddyfile ``` -------------------------------- ### Start Docker Compose for Development Source: https://github.com/thorsten/phpmyfaq/blob/main/README.md Use this command to start a full stack for multi-database development with your local phpMyFAQ source code. ```bash docker-compose up ``` -------------------------------- ### Install PHP Dependencies with Composer Source: https://github.com/thorsten/phpmyfaq/blob/main/AGENTS.md Download Composer and install PHP dependencies for the project. Ensure you have PHP installed. ```bash curl -s https://getcomposer.org/installer | php php composer.phar install ``` -------------------------------- ### Install and Run LibreTranslate with Docker Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/ai-translation.md Use this command to install and run LibreTranslate as a Docker container. Ensure Docker is installed on your server. ```bash docker run -d -p 5000:5000 libretranslate/libretranslate ``` -------------------------------- ### Install Dependencies and Build phpMyFAQ Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/development.md Fetch third-party libraries using Composer and PNPM, then build the project. This is a prerequisite for local development. ```bash $ cd phpMyFAQ $ curl -s https://getcomposer.org/installer | php $ php composer.phar install $ pnpm install $ pnpm build ``` -------------------------------- ### Enable and Start FrankenPHP Systemd Service Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/installation.md Reload the systemd daemon, enable the FrankenPHP service to start on boot, and then start the service immediately. This activates FrankenPHP as a system service. ```bash sudo systemctl daemon-reload sudo systemctl enable frankenphp sudo systemctl start frankenphp ``` -------------------------------- ### Create and Configure Environment File Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/deployment.md Copy the example production environment file and edit it to configure your specific deployment settings, including database credentials and timezone. ```bash cp .env.production.example .env nano .env # or use your preferred editor ``` -------------------------------- ### Starting the MCP Server Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/mcp-server.md Commands to show server information and start the MCP server. The server runs over STDIO and is intended for use by MCP-capable clients or the MCP Inspector. ```APIDOC ## Starting the MCP Server ### Description Commands to show server information and start the MCP server. The server runs over STDIO and is intended for use by MCP-capable clients or the MCP Inspector. ### Commands * **Show server information:** ```bash php bin/console phpmyfaq:mcp:server --info ``` * **Start the MCP server:** ```bash php bin/console phpmyfaq:mcp:server ``` ``` -------------------------------- ### Install TypeScript Dependencies with PNPM Source: https://github.com/thorsten/phpmyfaq/blob/main/AGENTS.md Install PNPM and then install TypeScript dependencies and build the project. This is required for frontend development. ```bash curl -fsSL https://get.pnpm.io/install.sh | sh - pnpm install pnpm build ``` -------------------------------- ### Plugin Configuration Class Example Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/plugins.md Defines configuration options for a plugin using Constructor Property Promotion. Properties are automatically recognized as configuration settings. ```php class MyPluginConfiguration implements PluginConfigurationInterface { public function __construct( public int $hooraysPerMinute = 200, public bool $showIcon = true, ) { } } ``` -------------------------------- ### Start phpMyFAQ MCP Server Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/mcp-server.md Use these commands to manage the phpMyFAQ MCP server. The `--info` flag shows server details, while the default command starts the STDIO MCP server, intended for client or Inspector launch. ```bash php bin/console phpmyfaq:mcp:server --info ``` ```bash php bin/console phpmyfaq:mcp:server ``` -------------------------------- ### Start Docker Compose Development Stack Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/development.md Start the full Docker Compose stack for multi-database development, including web servers, databases, and helper tools. ```bash $ docker-compose up ``` -------------------------------- ### Download and Install FrankenPHP Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/installation.md Download the FrankenPHP binary for Linux x86_64, make it executable, and move it to your system's PATH. This prepares the server for use. ```bash # Download FrankenPHP curl -L https://github.com/dunglas/frankenphp/releases/latest/download/frankenphp-linux-x86_64 -o frankenphp chmod +x frankenphp sudo mv frankenphp /usr/local/bin/ ``` -------------------------------- ### Install LibreTranslate with Python Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/ai-translation.md Install LibreTranslate using pip and run it directly. This method requires a Python environment. ```bash pip install libretranslate libretranslate ``` -------------------------------- ### Run TypeScript Tests via Vitest Source: https://github.com/thorsten/phpmyfaq/blob/main/README.md Install pnpm, install project dependencies, and run the TypeScript tests using Vitest. ```bash $ curl -fsSL https://get.pnpm.io/install.sh | sh - $ pnpm install $ pnpm test ``` -------------------------------- ### Run PHP Unit Tests via PHPUnit Source: https://github.com/thorsten/phpmyfaq/blob/main/README.md Install Composer dependencies and then execute the PHPUnit tests. Ensure phpMyFAQ is installed via Composer. ```bash $ curl -s https://getcomposer.org/installer | php $ php composer.phar install $ ./phpmyfaq/src/libs/bin/phpunit ``` -------------------------------- ### Run MariaDB Container for phpMyFAQ Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/installation.md Start a MariaDB container to serve as the database for phpMyFAQ. This command creates a detached container named 'phpmyfaq-db'. ```bash $ docker run -ti -n phpmyfaq-db mariadb ``` -------------------------------- ### Example Frontend JavaScript for a Plugin Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/plugins.md This example demonstrates a basic IIFE structure for plugin JavaScript, including DOM readiness checks and a simple console log. Always use strict mode and wrap code to avoid global scope pollution. ```javascript (function() { 'use strict'; // Wait for DOM to be ready if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } function init() { console.log('My Plugin: Loaded'); // Your plugin functionality here } })(); ``` -------------------------------- ### List Available CLI Commands Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/administration.md Use this command to see all available commands for managing your phpMyFAQ installation via the command line. ```bash # Show available commands php bin/console list ``` -------------------------------- ### Redis DSN Examples Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/installation.md Examples of Data Source Names (DSN) for connecting to Redis, covering Docker Compose, local host, and Unix socket configurations. Ensure the database number is correctly specified. ```text tcp://redis:6379?database=1 ``` ```text tcp://127.0.0.1:6379?database=1 ``` ```text unix:///var/run/redis/redis.sock?database=1 ``` -------------------------------- ### Create New SSL Certificate with mkcert Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/development.md Command to generate a new SSL certificate for local development. Ensure mkcert is installed. ```bash $ mkcert -install -cert-file .docker/cert.pem -key-file .docker/cert-key.pem localhost ``` -------------------------------- ### Build and Run phpMyFAQ Tests with Docker Source: https://github.com/thorsten/phpmyfaq/blob/main/README.md Build a Docker image for testing and then run the tests within a container. This requires Composer development dependencies to be installed. ```bash docker build -t phpmyfaq-test . docker run --rm -it docker.io/library/phpmyfaq-test:latest ``` -------------------------------- ### Manage Systemd Docker Service Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/docker-cheatsheet.md Enables and starts the Docker service using systemd for production servers. ```bash sudo systemctl enable docker sudo systemctl start docker ``` -------------------------------- ### Configure FrankenPHP as a Systemd Service Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/installation.md Create a systemd service file to manage FrankenPHP as a background service. This ensures it starts automatically on boot and can be controlled with systemctl commands. ```ini [Unit] Description=FrankenPHP Server After=network.target [Service] Type=simple User=www-data Group=www-data WorkingDirectory=/var/www/html ExecStart=/usr/local/bin/frankenphp run --config /path/to/your/Caddyfile Restart=always RestartSec=3 [Install] WantedBy=multi-user.target ``` -------------------------------- ### Run phpMyFAQ Docker Container Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/installation.md Start the phpMyFAQ web application container, linking it to the 'phpmyfaq-db' container and exposing port 8080. This assumes a MariaDB container named 'phpmyfaq-db' is already running. ```bash $ docker run -ti --link phpmyfaq-db:db -p 8080:80 phpmyfaq/phpmyfaq ``` -------------------------------- ### Sign Release Artifacts with GPG Variables Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/release.md Sign release artifacts while specifying GPG key ID and passphrase using environment variables. This is an example of how to provide credentials for the signing process. ```bash GPG_KEY_ID=0123456789ABCDEF \ GPG_PASSPHRASE='secret' \ ./scripts/sign-release-artifacts.sh 4.2.0 ``` -------------------------------- ### Prepare Custom SSL Certificates Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/deployment.md Prepare your custom SSL certificates by creating an 'ssl' directory and copying your certificate and key files. Ensure correct file permissions are set. ```bash mkdir -p ssl # Copy your certificate files cp your-cert.pem ssl/cert.pem cp your-key.pem ssl/cert-key.pem chmod 644 ssl/cert.pem chmod 600 ssl/cert-key.pem ``` -------------------------------- ### Troubleshoot Container Startup Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/deployment.md Check container logs for startup issues and common problems like port conflicts or permission errors. ```bash # Check logs docker-compose -f docker-compose.prod.yml logs service-name # Common issues: # - Port already in use: Change ports in .env # - Permission issues: Check volume permissions # - Out of memory: Increase Docker memory limit ``` -------------------------------- ### Manual Docker Compose Deployment Steps Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/deployment.md A sequence of commands for preparing the environment, editing the compose file, deploying, and managing the phpMyFAQ services using Docker Compose. ```bash # 1. Prepare environment cp .env.production.example .env nano .env # Configure all variables # 2. Edit docker-compose.prod.yml nano docker-compose.prod.yml # - Choose your database service # - Choose your web server # - Comment out unused services # 3. Deploy docker-compose -f docker-compose.prod.yml up -d # 4. Check status docker-compose -f docker-compose.prod.yml ps docker-compose -f docker-compose.prod.yml logs -f # 5. Stop/Update docker-compose -f docker-compose.prod.yml down docker-compose -f docker-compose.prod.yml pull docker-compose -f docker-compose.prod.yml up -d ``` -------------------------------- ### Deploy phpMyFAQ with Docker Compose Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/deployment.md Use Docker Compose to bring up the production environment. Ensure you have configured the .env file and potentially edited the docker-compose.prod.yml. ```bash docker-compose -f docker-compose.prod.yml up -d ``` -------------------------------- ### Translation Twig Extension Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/development.md Use this extension to get the translation of a given string. ```twig {{ 'string' | translate }} ``` -------------------------------- ### Permission Translation Twig Extension Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/development.md Use this extension to get the permission name from its string representation. ```twig {{ permissionString | permission }} ``` -------------------------------- ### Recommended PHP Configuration Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/installation.md Essential PHP settings for optimal performance and functionality. Ensure memory_limit is sufficient and file uploads are enabled. ```ini memory_limit = 128M file_upload = on ``` -------------------------------- ### Create .htpasswd file Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/installation.md Use this command to create a .htpasswd file for Basic Authentication if you are not using SSO. ```bash sudo htpasswd -c /etc/apache2/.htpasswd username ``` -------------------------------- ### Category Name Twig Extension Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/development.md Get the name of a category using its ID within Twig templates. ```twig {{ categoryId | categoryName }} ``` -------------------------------- ### Prepare Release Artifacts Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/release.md Use the release helper script to prepare the canonical package layout from the current git index. This script generates archives and SBOM files. ```bash ./scripts/prepare-release-artifacts.sh 4.2.0 ``` -------------------------------- ### Troubleshoot Database Connection Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/deployment.md Verify the database service is running, test the connection, and ensure credentials in the .env file are correct. ```bash # Check database is running docker-compose -f docker-compose.prod.yml ps mariadb # Test connection docker exec phpmyfaq-mariadb mysql -u phpmyfaq -p$MYSQL_PASSWORD -e "SELECT 1" # Verify credentials in .env match database ``` -------------------------------- ### Run Docker Compose in Production Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/docker-cheatsheet.md Starts Docker services defined in a production compose file in detached mode without dependencies. ```bash docker-compose -f docker-compose.prod.yml up -d --no-deps apache ``` -------------------------------- ### Create and Connect to Custom Docker Networks Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/docker-cheatsheet.md Create a new Docker network and connect an existing container to it. ```bash # Create network docker network create --driver bridge phpmyfaq-custom ``` ```bash # Connect container to network docker network connect phpmyfaq-custom phpmyfaq-apache ``` -------------------------------- ### Production Build Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/development.md Generate an optimized build of the project for production deployment. ```bash $ pnpm build:prod ``` -------------------------------- ### Get Language Name from Code Twig Extension Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/development.md Retrieve the full language name corresponding to a given language code within Twig templates. ```twig {{ languageCode | getFromLanguageCode }} ``` -------------------------------- ### Build TypeScript and CSS for Production Source: https://github.com/thorsten/phpmyfaq/blob/main/AGENTS.md Compile TypeScript and SCSS files for production deployment using PNPM. This typically includes optimizations. ```bash pnpm build:prod ``` -------------------------------- ### Get Release Version Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/release.md This PHP script is used to resolve the release version, typically for use in filenames and metadata. It can be overridden by the VERSION environment variable. ```php scripts/get-version.php ``` -------------------------------- ### Build TypeScript and CSS Source: https://github.com/thorsten/phpmyfaq/blob/main/AGENTS.md Compile TypeScript and SCSS files for the frontend using PNPM. ```bash pnpm build ``` -------------------------------- ### Get Plugin Translations in Twig Templates Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/plugins.md Utilize the 'translate' Twig filter with a namespaced key to display translated strings directly within your Twig templates. ```twig {{ 'plugin.YourPlugin.greeting' | translate }} {{ 'plugin.YourPlugin.message' | translate }} ``` -------------------------------- ### Check PHP Version with phpinfo() Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/installation.md Create an info.php file to check your server's PHP version and configuration. Upload this file to your webspace and access it via your browser. ```php backup.sql ``` ```bash # PostgreSQL backup docker exec phpmyfaq-postgres pg_dump \ -U phpmyfaq phpmyfaq > backup.sql ``` ```bash # Compressed backup docker exec phpmyfaq-mariadb mysqldump \ -u phpmyfaq -p[PASSWORD] phpmyfaq | gzip > backup.sql.gz ``` -------------------------------- ### Deploy and Manage Stacks with Portainer Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/docker-cheatsheet.md Commands for deploying, listing, and removing Docker stacks using the Portainer CLI. ```bash # Deploy via Portainer CLI portainer stack deploy phpmyfaq \ --compose-file docker-compose.prod.yml \ --env-file .env ``` ```bash # List stacks portainer stack ls ``` ```bash # Remove stack portainer stack rm phpmyfaq ``` -------------------------------- ### Upload and Activate Theme with ThemeManager Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/development.md Use ThemeManager to upload and activate custom themes. Ensure the configuration and storage are correctly set up. The theme must be in a ZIP archive with an index.twig file. ```php use phpMyFAQ\Template\ThemeManager; $themeManager = new ThemeManager($configuration, $storage, 'themes'); $themeManager->uploadTheme('tenant-theme', '/tmp/tenant-theme.zip'); $themeManager->activateTheme('tenant-theme'); ``` -------------------------------- ### Run PHP Linting Source: https://github.com/thorsten/phpmyfaq/blob/main/AGENTS.md Check PHP code for linting errors using Composer. ```bash composer lint ``` -------------------------------- ### List and Inspect Docker Networks Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/docker-cheatsheet.md Commands to list all available Docker networks and to inspect the details of a specific network. ```bash # List all networks docker network ls ``` ```bash # Inspect network docker network inspect phpmyfaq_phpmyfaq-network ``` -------------------------------- ### Enable proxy_fcgi and restart Apache Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/installation.md Enable the mod_proxy_fcgi module in Apache and restart the service. This is required for PHP-FPM integration. ```bash sudo a2enmod proxy_fcgi sudo systemctl restart apache2 ``` -------------------------------- ### Database Restore with Docker Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/docker-cheatsheet.md Restore databases for MariaDB and PostgreSQL from SQL files, including compressed backups. ```bash # MariaDB restore cat backup.sql | docker exec -i phpmyfaq-mariadb \ mysql -u phpmyfaq -p[PASSWORD] phpmyfaq ``` ```bash # PostgreSQL restore cat backup.sql | docker exec -i phpmyfaq-postgres \ psql -U phpmyfaq -d phpmyfaq ``` ```bash # From compressed backup gunzip < backup.sql.gz | docker exec -i phpmyfaq-mariadb \ mysql -u phpmyfaq -p[PASSWORD] phpmyfaq ``` -------------------------------- ### Run PHP Unit Tests Source: https://github.com/thorsten/phpmyfaq/blob/main/AGENTS.md Execute PHP unit tests using Composer. This command verifies the backend code. ```bash composer test ``` -------------------------------- ### Import Release GPG Key Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/release.md Import the release public key into your GPG keyring to enable signature verification. This is a necessary step before verifying signatures. ```bash gpg --import phpmyfaq-release-public-key.asc ``` -------------------------------- ### Composer Scripts for Testing Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/development.md Run various PHPUnit and PHPBench test configurations using Composer scripts. Includes options for coverage reports. ```bash composer test ``` ```bash composer test:coverage ``` ```bash composer test:coverage-html ``` ```bash composer bench ``` -------------------------------- ### Run PHP Unit Tests with Coverage Source: https://github.com/thorsten/phpmyfaq/blob/main/AGENTS.md Execute PHP unit tests and generate a code coverage report using Composer. ```bash composer test:coverage ``` -------------------------------- ### Configure Git User Information Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/development.md Set your global Git configuration for username and email. This is essential for tracking contributions. ```bash $ git config --global user.name "Your Name" ``` ```bash $ git config --global user.email you@example.com ``` ```bash $ git config core.autocrlf # if you're on Windows ``` -------------------------------- ### Run PHPUnit Tests Source: https://github.com/thorsten/phpmyfaq/blob/main/docs/development.md Execute the PHPUnit-based test suite for the project. ```bash $ composer test ```