diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index e017cc0..0000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,126 +0,0 @@ -name: Docker CI - -on: - pull_request: - paths: - - 'docker/**' - - 'docker-compose*.yml' - - '.github/workflows/docker.yml' - push: - paths: - - 'docker/**' - - 'docker-compose*.yml' - - '.github/workflows/docker.yml' - -jobs: - test-apache: - runs-on: ubuntu-latest - - steps: - - name: Checkout. - uses: actions/checkout@v4 - - - name: Install docker compose. - run: | - sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose - sudo chmod +x /usr/local/bin/docker-compose - docker-compose --version - - - name: Build and start containers. - run: docker-compose up -d --build - - - name: Wait for container to be ready. - run: | - echo "Waiting 30 seconds for container initialization..." - sleep 30 - docker logs yii2-apache - - - name: Codeceptcion build. - run: docker exec yii2-apache vendor/bin/codecept build - - - name: Run codeception tests. - run: docker exec yii2-apache vendor/bin/codecept run --env dockerized - - test-caddy: - runs-on: ubuntu-latest - - steps: - - name: Checkout. - uses: actions/checkout@v4 - - - name: Install docker compose. - run: | - sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose - sudo chmod +x /usr/local/bin/docker-compose - docker-compose --version - - - name: Build and start containers. - run: docker-compose -f docker-compose.caddy.yml up -d --build - - - name: Wait for container to be ready. - run: | - echo "Waiting 30 seconds for container initialization..." - sleep 30 - docker logs yii2-caddy - - - name: Codeception build. - run: docker exec yii2-caddy vendor/bin/codecept build - - - name: Run codeception tests. - run: docker exec yii2-caddy vendor/bin/codecept run --env dockerized - - test-frankenphp: - runs-on: ubuntu-latest - - steps: - - name: Checkout. - uses: actions/checkout@v4 - - - name: Install docker compose. - run: | - sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose - sudo chmod +x /usr/local/bin/docker-compose - docker-compose --version - - - name: Build and start containers. - run: docker-compose -f docker-compose.frankenphp.yml up -d --build - - - name: Wait for container to be ready. - run: | - echo "Waiting 30 seconds for container initialization..." - sleep 30 - docker logs yii2-frankenphp - - - name: Codeception build. - run: docker exec yii2-frankenphp vendor/bin/codecept build - - - name: Run codeception tests. - run: docker exec yii2-frankenphp vendor/bin/codecept run --env dockerized - - test-nginx: - runs-on: ubuntu-latest - - steps: - - name: Checkout. - uses: actions/checkout@v4 - - - name: Install docker Compose. - run: | - sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose - sudo chmod +x /usr/local/bin/docker-compose - docker-compose --version - - - name: Build and start containers. - run: docker-compose -f docker-compose.nginx.yml up -d --build - - - name: Wait for container to be ready. - run: | - echo "Waiting 30 seconds for container initialization..." - sleep 30 - docker logs yii2-nginx - - - name: Codeception build. - run: docker exec yii2-nginx vendor/bin/codecept build - - - name: Run codeception tests. - run: docker exec yii2-nginx vendor/bin/codecept run --env dockerized diff --git a/README.md b/README.md index b36248b..a77995a 100644 --- a/README.md +++ b/README.md @@ -7,20 +7,20 @@

- php-version + PHP version - Yii2 2.0.53 + Yii 2.0.x - Yii2 22.0 + Yii 22.0.x - PHPUnit + PHPUnit - PHPStan - + PHPStan +

A modern, Bootstrap 5-powered Yii2 application template designed for rapid web-application development. Built with best practices, clean architecture, and developer-friendly configuration, it lets you create production-ready apps with minimal setup while maintaining code quality and extensibility. @@ -38,16 +38,8 @@ A modern, Bootstrap 5-powered Yii2 application template designed for rapid web-a - ✅ **Console Commands** - Example console commands for background tasks and maintenance. - ✅ **Developer Tools** - Debugging tools, logging, and development-friendly configurations. - ✅ **Modern Bootstrap 5 UI** - Responsive, mobile-first design with latest Bootstrap components. -- ✅ **SSL Support** - Configured for secure HTTPS connections with SSL (mkcert). - ✅ **Testing Ready** - Codeception test suite with examples for functional and unit testing. -## Supported web servers - -[![Apache](https://img.shields.io/badge/apache-%23D42029.svg?style=for-the-badge&label=docker&logo=apache&logoColor=white)](docker-compose.yml) -[![Caddy](https://img.shields.io/badge/caddy-%231F88C0.svg?style=for-the-badge&label=docker&logo=caddy&logoColor=white)](docker-compose.caddy.yml) -[![FrankenPHP](https://img.shields.io/badge/frankenphp-%23FF6B35.svg?style=for-the-badge&label=docker&logo=php&logoColor=white)](docker-compose.frankenphp.yml) -[![Nginx](https://img.shields.io/badge/nginx-%23009639.svg?style=for-the-badge&label=docker&logo=nginx&logoColor=white)](docker-compose.nginx.yml) - ## Quick start ### How it works @@ -73,8 +65,8 @@ The Yii2 Web Application Basic template provides a complete foundation for build **Quick start** ```bash -composer create-project --prefer-dist --stability=dev yii2-extensions/app-basic myapp -cd myapp +composer create-project --prefer-dist --stability=dev yii2-extensions/app-basic app-basic +cd app-basic ``` **Start development server** @@ -87,43 +79,6 @@ php -S localhost:8080 -t web ./yii serve ``` -**Start Apache or Nginx server** - -```bash -# For Apache -docker-compose up -d - -# For Caddy -docker-compose -f docker-compose.caddy.yml up -d - -# For FrankenPHP -docker-compose -f docker-compose.frankenphp.yml up -d - -# For Nginx -docker-compose -f docker-compose.nginx.yml up -d -``` - -### Access your application - -After starting the server, you can access your application in your web browser. - -```bash -# For built-in PHP server -http://localhost:8080/ - -# For Apache -https://localhost:8443/ - -# For Caddy -https://localhost:8444/ - -# For FrankenPHP -https://localhost:8445/ - -# For Nginx -https://localhost:8446/ -``` - ### Basic usage #### Directory structure @@ -135,18 +90,9 @@ root/ │ ├── console/ Console configuration │ ├── web/ Web configuration │ └── messages.php Translation config -├── docker/ Docker configuration files -│ ├── apache/ Apache configuration -│ ├── caddy/ Caddy configuration -│ ├── frankenphp/ FrankenPHP configuration -│ ├── nginx/ Nginx configuration -│ ├── php/ PHP configuration -│ ├── ssl/ SSL certificates -│ └── supervisor/ Supervisor configuration ├── src/ │ ├── framework/ Framework assets & resources │ │ ├── asset/ Asset bundles -│ │ ├── event/ Event handlers │ │ └── resource/ CSS, JS, layouts, messages │ └── usecase/ Application use cases │ ├── hello/ Console command example @@ -168,7 +114,7 @@ namespace app\usecase\site; use yii\web\Controller; -class SiteController extends Controller +final class SiteController extends Controller { public function actionIndex(): string { @@ -191,11 +137,11 @@ class SiteController extends Controller ``` ## Quality code -[![Latest Stable Version](https://poser.pugx.org/yii2-extensions/app-basic/v)](https://packagist.org/packages/yii2-extensions/app-basic) -[![Total Downloads](https://poser.pugx.org/yii2-extensions/app-basic/downloads)](https://packagist.org/packages/yii2-extensions/app-basic) -[![codecov](https://codecov.io/github/yii2-extensions/app-basic/graph/badge.svg?token=zcXbeTspxy)](https://codecov.io/github/yii2-extensions/app-basic) -[![phpstan-level](https://img.shields.io/badge/PHPStan%20level-max-blue)](https://github.com/yii2-extensions/app-basic/actions/workflows/static.yml) -[![StyleCI](https://github.styleci.io/repos/698621511/shield?branch=main)](https://github.styleci.io/repos/698621511?branch=main) +[![Latest Stable Version](https://img.shields.io/packagist/v/yii2-extensions/app-basic.svg?style=for-the-badge&logo=packagist&logoColor=white&label=Stable)](https://packagist.org/packages/yii2-extensions/app-basic) +[![Total Downloads](https://img.shields.io/packagist/dt/yii2-extensions/app-basic.svg?style=for-the-badge&logo=packagist&logoColor=white&label=Downloads)](https://packagist.org/packages/yii2-extensions/app-basic) +[![Codecov](https://img.shields.io/codecov/c/github/yii2-extensions/app-basic.svg?branch=main&style=for-the-badge&logo=codecov&logoColor=white&label=Coverage)](https://codecov.io/github/yii2-extensions/app-basic) +[![PHPStan Level Max](https://img.shields.io/badge/PHPStan-Level%20Max-4F5D95.svg?style=for-the-badge&logo=php&logoColor=white)](https://github.com/yii2-extensions/app-basic/actions/workflows/static.yml) +[![StyleCI](https://img.shields.io/badge/StyleCI-Passed-44CC11.svg?style=for-the-badge&logo=styleci&logoColor=white)](https://github.styleci.io/repos/165419144?branch=main) ## Documentation @@ -204,18 +150,12 @@ For detailed configuration options and advanced usage: - 📚 [Installation Guide](docs/installation.md) - ⚙️ [Configuration Reference](docs/configuration.md) - 🧪 [Testing Guide](docs/testing.md) - -## Screenshots - -The web application includes these ready-to-use pages: - -- **[404 Error Page](docs/images/404.png)** - Custom error handling -- **[404 Error Page Dark](docs/images/404-dark.png)** - Custom error handling +- 📸 [Screenshots](docs/screenshots.md) ## Our social networks -[![X](https://img.shields.io/badge/follow-@terabytesoftw-1DA1F2?logo=x&logoColor=1DA1F2&labelColor=555555&style=flat)](https://x.com/Terabytesoftw) +[![Follow on X](https://img.shields.io/badge/-Follow%20on%20X-1DA1F2.svg?style=for-the-badge&logo=x&logoColor=white&labelColor=000000)](https://x.com/Terabytesoftw) ## License -[![License](https://img.shields.io/github/license/yii2-extensions/app-basic)](LICENSE.md) +[![License](https://img.shields.io/github/license/yii2-extensions/app-basic?style=for-the-badge&logo=opensourceinitiative&logoColor=white&labelColor=333333)](LICENSE.md) diff --git a/docker-compose.caddy.yml b/docker-compose.caddy.yml deleted file mode 100644 index 5b6c32a..0000000 --- a/docker-compose.caddy.yml +++ /dev/null @@ -1,34 +0,0 @@ -services: - yii2-caddy: - build: - args: - USER_ID: ${USER_ID:-1000} - GROUP_ID: ${GROUP_ID:-1000} - USER_NAME: ${USER_NAME:-www-data} - GROUP_NAME: ${GROUP_NAME:-www-data} - context: . - dockerfile: docker/caddy/Dockerfile - container_name: yii2-caddy - env_file: - - .env - environment: - TZ: "UTC" - YII_DEBUG: "${YII_DEBUG:-false}" - YII_ENV: "${YII_ENV:-prod}" - ports: - - '8081:80' - - '8444:443' - - '8444:443/udp' - restart: always - tty: true - volumes: - - ./:/app - - caddy_config:/config - - caddy_data:/data - - composer_cache:/var/www/.composer/cache - working_dir: /app - -volumes: - caddy_data: - caddy_config: - composer_cache: diff --git a/docker-compose.frankenphp.yml b/docker-compose.frankenphp.yml deleted file mode 100644 index bfda61b..0000000 --- a/docker-compose.frankenphp.yml +++ /dev/null @@ -1,35 +0,0 @@ -services: - yii2-frankenphp: - build: - args: - USER_ID: ${USER_ID:-1000} - GROUP_ID: ${GROUP_ID:-1000} - USER_NAME: ${USER_NAME:-www-data} - GROUP_NAME: ${GROUP_NAME:-www-data} - context: . - dockerfile: docker/frankenphp/Dockerfile - container_name: yii2-frankenphp - entrypoint: ["/usr/local/bin/entrypoint.sh"] - env_file: - - .env - environment: - TZ: "UTC" - YII_DEBUG: "${YII_DEBUG:-false}" - YII_ENV: "${YII_ENV:-prod}" - ports: - - '8082:80' - - '8445:443' - - '8445:443/udp' - restart: always - tty: true - volumes: - - ./:/app - - caddy_config:/config - - caddy_data:/data - - composer_cache:/var/www/.composer/cache - working_dir: /app - -volumes: - caddy_data: - caddy_config: - composer_cache: diff --git a/docker-compose.nginx.yml b/docker-compose.nginx.yml deleted file mode 100644 index 375858a..0000000 --- a/docker-compose.nginx.yml +++ /dev/null @@ -1,30 +0,0 @@ -services: - yii2-nginx: - build: - args: - USER_ID: ${USER_ID:-1000} - GROUP_ID: ${GROUP_ID:-1000} - USER_NAME: ${USER_NAME:-www-data} - GROUP_NAME: ${GROUP_NAME:-www-data} - context: . - dockerfile: docker/nginx/Dockerfile - container_name: yii2-nginx - entrypoint: ["/usr/local/bin/entrypoint.sh"] - env_file: - - .env - environment: - TZ: "UTC" - YII_DEBUG: "${YII_DEBUG:-false}" - YII_ENV: "${YII_ENV:-prod}" - ports: - - '8083:80' - - '8446:443' - restart: always - tty: true - volumes: - - ./:/app - - composer_cache:/var/www/.composer/cache - working_dir: /app - -volumes: - composer_cache: diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index dbd5a19..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,30 +0,0 @@ -services: - yii2-apache: - build: - args: - USER_ID: ${USER_ID:-1000} - GROUP_ID: ${GROUP_ID:-1000} - USER_NAME: ${USER_NAME:-www-data} - GROUP_NAME: ${GROUP_NAME:-www-data} - context: . - dockerfile: docker/apache/Dockerfile - container_name: yii2-apache - entrypoint: ["/usr/local/bin/entrypoint.sh"] - env_file: - - .env - environment: - TZ: "UTC" - YII_DEBUG: "${YII_DEBUG:-false}" - YII_ENV: "${YII_ENV:-prod}" - ports: - - '8080:80' - - '8443:443' - restart: always - tty: true - volumes: - - ./:/app - - composer_cache:/var/www/.composer/cache - working_dir: /app - -volumes: - composer_cache: diff --git a/docker/apache/Dockerfile b/docker/apache/Dockerfile deleted file mode 100644 index dcef247..0000000 --- a/docker/apache/Dockerfile +++ /dev/null @@ -1,64 +0,0 @@ -FROM yiisoftware/yii2-php:8.4-apache - -# Build arguments for user/group -ARG USER_ID=1000 -ARG GROUP_ID=1000 -ARG USER_NAME=www-data -ARG GROUP_NAME=www-data - -# Enable SSL modules and configure ports before copying config -RUN a2enmod ssl rewrite headers mime \ - && echo "Listen 80" > /etc/apache2/ports.conf \ - && echo "Listen 443 ssl" >> /etc/apache2/ports.conf - -# Change web server config -COPY docker/apache/apache.conf /etc/apache2/apache2.conf -COPY docker/apache/vhost.conf /etc/apache2/sites-available/000-default.conf - -# Change PHP config -COPY docker/php/php.ini /usr/local/etc/php/conf.d/base.ini - -# Set document root to /app/public (Yii2 structure) -WORKDIR /app - -# Set composer environment -ENV COMPOSER_ALLOW_SUPERUSER=1 - -# Install supervisor, gosu, and Node.js (version simple) -RUN apt-get update && apt-get install -y --no-install-recommends \ - supervisor \ - curl \ - gosu \ - && curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \ - && apt-get install -y nodejs \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -# Apply the user/group IDs to www-data -RUN usermod -u ${USER_ID} www-data && groupmod -g ${GROUP_ID} www-data - -# Create composer and npm cache directories with proper ownership -RUN mkdir -p /var/www/.composer/cache /var/www/.npm && \ - chown -R www-data:www-data /var/www/.composer /var/www/.npm - -# Copy supervisor program configs -COPY docker/supervisor/conf.d/apache2.conf /etc/supervisor/conf.d/apache2.conf - -# Copy queue worker config uncommented for use with yii2-queue -#COPY docker/supervisor/conf.d/queue.conf /etc/supervisor/conf.d/queue.conf - -# Copy scripts -COPY docker/init.sh /usr/local/bin/init.sh -COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh - -# Make scripts executable and validate -RUN chmod +x /usr/local/bin/init.sh /usr/local/bin/entrypoint.sh && \ - # Convert any Windows line endings - sed -i 's/\r$//' /usr/local/bin/init.sh /usr/local/bin/entrypoint.sh && \ - # Test that scripts have valid syntax - bash -n /usr/local/bin/init.sh && \ - bash -n /usr/local/bin/entrypoint.sh && \ - echo "✓ Scripts validated successfully..." - -# Use ENTRYPOINT to guarantee execution -ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/docker/apache/apache.conf b/docker/apache/apache.conf deleted file mode 100644 index 413858f..0000000 --- a/docker/apache/apache.conf +++ /dev/null @@ -1,234 +0,0 @@ -# This is the main Apache server configuration file. It contains the -# configuration directives that give the server its instructions. -# See http://httpd.apache.org/docs/2.4/ for detailed information about -# the directives and /usr/share/doc/apache2/README.Debian about Debian specific -# hints. -# -# -# Summary of how the Apache 2 configuration works in Debian: -# The Apache 2 web server configuration in Debian is quite different to -# upstream's suggested way to configure the web server. This is because Debian's -# default Apache2 installation attempts to make adding and removing modules, -# virtual hosts, and extra configuration directives as flexible as possible, in -# order to make automating the changes and administering the server as easy as -# possible. - -# It is split into several files forming the configuration hierarchy outlined -# below, all located in the /etc/apache2/ directory: -# -# /etc/apache2/ -# |-- apache2.conf -# | `-- ports.conf -# |-- mods-enabled -# | |-- *.load -# | `-- *.conf -# |-- conf-enabled -# | `-- *.conf -# `-- sites-enabled -# `-- *.conf -# -# -# * apache2.conf is the main configuration file (this file). It puts the pieces -# together by including all remaining configuration files when starting up the -# web server. -# -# * ports.conf is always included from the main configuration file. It is -# supposed to determine listening ports for incoming connections which can be -# customized anytime. -# -# * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/ -# directories contain particular configuration snippets which manage modules, -# global configuration fragments, or virtual host configurations, -# respectively. -# -# They are activated by symlinking available configuration files from their -# respective *-available/ counterparts. These should be managed by using our -# helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See -# their respective man pages for detailed information. -# -# * The binary is called apache2. Due to the use of environment variables, in -# the default configuration, apache2 needs to be started/stopped with -# /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not -# work with the default configuration. - - -# Global configuration -# - -# -# ServerRoot: The top of the directory tree under which the server's -# configuration, error, and log files are kept. -# -# NOTE! If you intend to place this on an NFS (or otherwise network) -# mounted filesystem then please read the Mutex documentation (available -# at ); -# you will save yourself a lot of trouble. -# -# Do NOT add a slash at the end of the directory path. -# -#ServerRoot "/etc/apache2" - -# -# The accept serialization lock file MUST BE STORED ON A LOCAL DISK. -# -#Mutex file:${APACHE_LOCK_DIR} default - -# -# The directory where shm and other runtime files will be stored. -# - -DefaultRuntimeDir ${APACHE_RUN_DIR} - -# -# PidFile: The file in which the server should record its process -# identification number when it starts. -# This needs to be set in /etc/apache2/envvars -# -PidFile ${APACHE_PID_FILE} - -# -# Timeout: The number of seconds before receives and sends time out. -# -Timeout 500 - -# -# KeepAlive: Whether or not to allow persistent connections (more than -# one request per connection). Set to "Off" to deactivate. -# -KeepAlive On - -# -# MaxKeepAliveRequests: The maximum number of requests to allow -# during a persistent connection. Set to 0 to allow an unlimited amount. -# We recommend you leave this number high, for maximum performance. -# -MaxKeepAliveRequests 100 - -# -# KeepAliveTimeout: Number of seconds to wait for the next request from the -# same client on the same connection. -# -KeepAliveTimeout 5 - - -# These need to be set in /etc/apache2/envvars -User ${APACHE_RUN_USER} -Group ${APACHE_RUN_GROUP} - -# -# HostnameLookups: Log the names of clients or just their IP addresses -# e.g., www.apache.org (on) or 204.62.129.132 (off). -# The default is off because it'd be overall better for the net if people -# had to knowingly turn this feature on, since enabling it means that -# each client request will result in AT LEAST one lookup request to the -# nameserver. -# -HostnameLookups Off - -# ErrorLog: The location of the error log file. -# If you do not specify an ErrorLog directive within a -# container, error messages relating to that virtual host will be -# logged here. If you *do* define an error logfile for a -# container, that host's errors will be logged there and not here. -# -ErrorLog ${APACHE_LOG_DIR}/error.log - -# -# LogLevel: Control the severity of messages logged to the error_log. -# Available values: trace8, ..., trace1, debug, info, notice, warn, -# error, crit, alert, emerg. -# It is also possible to configure the log level for particular modules, e.g. -# "LogLevel info ssl:warn" -# -LogLevel warn - -# Include module configuration: -IncludeOptional mods-enabled/*.load -IncludeOptional mods-enabled/*.conf - -# Include list of ports to listen on -Include ports.conf - - -# Sets the default security model of the Apache2 HTTPD server. It does -# not allow access to the root filesystem outside of /usr/share and /var/www. -# The former is used by web applications packaged in Debian, -# the latter may be used for local directories served by the web server. If -# your system is serving content from a sub-directory in /srv you must allow -# access here, or in any related virtual host. - - Options FollowSymLinks - AllowOverride None - Require all denied - - - - AllowOverride None - Require all granted - - - - Options Indexes FollowSymLinks - AllowOverride None - Require all granted - - -# -# Options Indexes FollowSymLinks -# AllowOverride None -# Require all granted -# - - -# AccessFileName: The name of the file to look for in each directory -# for additional configuration directives. See also the AllowOverride -# directive. -# -AccessFileName .htaccess - -# -# The following lines prevent .htaccess and .htpasswd files from being -# viewed by Web clients. -# - - Require all denied - - - -# -# The following directives define some format nicknames for use with -# a CustomLog directive. -# -# These deviate from the Common Log Format definitions in that they use %O -# (the actual bytes sent including headers) instead of %b (the size of the -# requested file), because the latter makes it impossible to detect partial -# requests. -# -# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended. -# Use mod_remoteip instead. -# -LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined -LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined -LogFormat "%h %l %u %t \"%r\" %>s %O" common -LogFormat "%{Referer}i -> %U" referer -LogFormat "%{User-agent}i" agent - -# Include of directories ignores editors' and dpkg's backup files, -# see README.Debian for details. - -# Include generic snippets of statements -IncludeOptional conf-enabled/*.conf - -# Include the virtual host configurations: -IncludeOptional sites-enabled/*.conf - -# vim: syntax=apache ts=4 sw=4 sts=4 sr noet - -ServerTokens ProductOnly -ServerSignature Off - -TraceEnable Off - - - Require all denied - \ No newline at end of file diff --git a/docker/apache/vhost.conf b/docker/apache/vhost.conf deleted file mode 100644 index 943a9f9..0000000 --- a/docker/apache/vhost.conf +++ /dev/null @@ -1,71 +0,0 @@ -# Global configuration for the public directory - - Options FollowSymLinks - AllowOverride All - Require all granted - - # Ensure Apache serves static files directly - - Header unset ETag - FileETag None - - # Completely disable PHP processing for these files - RemoveHandler .php - SetHandler default-handler - - - -# HTTP Virtual Host - Redirect to HTTPS - - ServerAdmin webmaster@localhost - DocumentRoot /app/public - - # Redirect all HTTP to HTTPS - RewriteEngine On - RewriteCond %{HTTPS} off - RewriteRule ^(.*)$ https://localhost:8443%{REQUEST_URI} [R=301,L] - - # Logging configuration - ErrorLog ${APACHE_LOG_DIR}/error.log - CustomLog ${APACHE_LOG_DIR}/access.log combined - - -# HTTPS Virtual Host - - # ServerName directive, which sets the request scheme, hostname and port that - ServerName localhost - ServerAdmin webmaster@localhost - DocumentRoot /app/public - - # SSL Configuration - SSLEngine on - SSLCertificateFile /app/docker/ssl/localhost.pem - SSLCertificateKeyFile /app/docker/ssl/localhost-key.pem - - # Enable rewrite logging for debugging (remove in production) - LogLevel warn rewrite:trace6 - - # Yii2 URL Rewriting Configuration - RewriteEngine On - - # Step 1: Exclude static files by extension completely - RewriteRule \.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|map)$ - [L,QSA] - - # Step 2: Exclude specific asset directories by path - RewriteRule ^(assets|image|images|css|js|fonts|media)/ - [L,QSA] - - # Step 3: If it's an existing file, serve it directly - RewriteCond %{REQUEST_FILENAME} -f - RewriteRule ^ - [L] - - # Step 4: If it's an existing directory, serve it directly - RewriteCond %{REQUEST_FILENAME} -d - RewriteRule ^ - [L] - - # Step 5: Only if none of the above apply, send to index.php - RewriteRule ^(.*)$ index.php [L,QSA] - - # Logging configuration for SSL - ErrorLog ${APACHE_LOG_DIR}/ssl_error.log - CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined - diff --git a/docker/caddy/Caddyfile b/docker/caddy/Caddyfile deleted file mode 100644 index 508997c..0000000 --- a/docker/caddy/Caddyfile +++ /dev/null @@ -1,65 +0,0 @@ -{ - # Global options - auto_https off -} - -# HTTPS server block using mkcert certificates -https://localhost:443 { - # Specify mkcert certificates - tls /app/docker/ssl/localhost.pem /app/docker/ssl/localhost-key.pem - - # Document root - root * /app/public - - # Using TCP socket for improved compatibility across environments - php_fastcgi 127.0.0.1:9000 { - index index.php - try_files {path} {path}/index.php =404 - } - - # Security headers - header { - X-Frame-Options "SAMEORIGIN" - X-XSS-Protection "1; mode=block" - X-Content-Type-Options "nosniff" - Strict-Transport-Security "max-age=31536000; includeSubDomains" - -Server - } - - # Logging - log { - output stdout - format console - } - - # Handle static files - @static { - file - path *.css *.js *.png *.jpg *.jpeg *.gif *.ico *.svg *.woff *.woff2 *.ttf *.eot - } - handle @static { - header Cache-Control "public, max-age=31536000" - file_server - } - - # Block access to sensitive directories - @forbidden { - path /.git/* /vendor/* /runtime/* /.env* - } - respond @forbidden 404 - - # Deny PHP execution in assets directory (Yii2 security) - @assets_php { - path /assets/*.php - } - respond @assets_php 403 - - # Try files for Yii2 URL rewriting - try_files {path} {path}/ /index.php?{query} -} - -# HTTP server block - redirect to HTTPS -http://localhost:80 { - # Redirect all HTTP traffic to HTTPS - redir https://localhost:8444{uri} permanent -} diff --git a/docker/caddy/Dockerfile b/docker/caddy/Dockerfile deleted file mode 100644 index 57f376c..0000000 --- a/docker/caddy/Dockerfile +++ /dev/null @@ -1,85 +0,0 @@ -FROM php:8.4-fpm - -# Build arguments for user/group -ARG USER_ID=1000 -ARG GROUP_ID=1000 -ARG USER_NAME=www-data -ARG GROUP_NAME=www-data - -# Set document root to /app/public (Yii2 structure) -WORKDIR /app - -# Install required system packages for PHP extensions for Yii 2.0 Framework -COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/ -RUN install-php-extensions \ - bcmath \ - @composer \ - exif \ - gd \ - imagick \ - intl \ - opcache \ - pdo_mysql \ - pdo_pgsql \ - soap \ - xdebug \ - zip - -# Set composer environment -ENV COMPOSER_ALLOW_SUPERUSER=1 - -# Change PHP config -COPY docker/php/php.ini /usr/local/etc/php/conf.d/base.ini - -# Install supervisor, gosu, and Node.js (version simple) -RUN apt-get update && apt-get install -y --no-install-recommends \ - supervisor \ - curl \ - gosu \ - debian-keyring \ - debian-archive-keyring \ - apt-transport-https \ - && curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \ - && apt-get install -y nodejs \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -# Install Caddy (standalone) -RUN curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg \ - && curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list \ - && apt-get update \ - && apt-get install -y caddy \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -# Change web server config -COPY docker/caddy/Caddyfile /etc/caddy/Caddyfile - -# Apply the user/group IDs to www-data -RUN usermod -u ${USER_ID} www-data && groupmod -g ${GROUP_ID} www-data - -# Create composer and npm cache directories with proper ownership -RUN mkdir -p /var/www/.composer/cache /var/www/.npm && \ - chown -R www-data:www-data /var/www/.composer /var/www/.npm - -# Copy supervisor program configs -COPY docker/supervisor/conf.d/caddy-php-fpm.conf /etc/supervisor/conf.d/caddy-php-fpm.conf - -# Copy queue worker config uncommented for use with yii2-queue -#COPY docker/supervisor/config.d/queue.conf /etc/supervisor/available/queue.conf - -# Copy scripts -COPY docker/init.sh /usr/local/bin/init.sh -COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh - -# Make scripts executable and validate -RUN chmod +x /usr/local/bin/init.sh /usr/local/bin/entrypoint.sh && \ - # Convert any Windows line endings - sed -i 's/\r$//' /usr/local/bin/init.sh /usr/local/bin/entrypoint.sh && \ - # Test that scripts have valid syntax - bash -n /usr/local/bin/init.sh && \ - bash -n /usr/local/bin/entrypoint.sh && \ - echo "✓ Scripts validated successfully..." - -# Use ENTRYPOINT to guarantee execution -ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh deleted file mode 100644 index 7ce7385..0000000 --- a/docker/entrypoint.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -set -euo pipefail - -echo "=== Container Starting ===" -echo "Running initialization script..." - -# Ensure init script is executable -chmod +x /usr/local/bin/init.sh - -# Execute init script; replace the PID 1 shell -exec /usr/local/bin/init.sh - -# If we get here, everything went well -echo "=== Container ready ===" diff --git a/docker/frankenphp/Caddyfile b/docker/frankenphp/Caddyfile deleted file mode 100644 index 9f83f5f..0000000 --- a/docker/frankenphp/Caddyfile +++ /dev/null @@ -1,62 +0,0 @@ -{ - # Global options - auto_https off -} - -# HTTPS server block using mkcert certificates -https://localhost:443 { - # Specify mkcert certificates - tls /app/docker/ssl/localhost.pem /app/docker/ssl/localhost-key.pem - - # Document root - root * /app/public - - # Enable PHP processing with FrankenPHP - php_server - - # Security headers - header { - X-Frame-Options "SAMEORIGIN" - X-XSS-Protection "1; mode=block" - X-Content-Type-Options "nosniff" - Strict-Transport-Security "max-age=31536000; includeSubDomains" - -Server - } - - # Logging - log { - output stdout - format console - } - - # Handle static files - @static { - file - path *.css *.js *.png *.jpg *.jpeg *.gif *.ico *.svg *.woff *.woff2 *.ttf *.eot - } - handle @static { - header Cache-Control "public, max-age=31536000" - file_server - } - - # Block access to sensitive directories - @forbidden { - path /.git/* /vendor/* /runtime/* /.env* - } - respond @forbidden 404 - - # Deny PHP execution in assets directory (Yii2 security) - @assets_php { - path /assets/*.php - } - respond @assets_php 403 - - # Try files for Yii2 URL rewriting - try_files {path} {path}/ /index.php?{query} -} - -# HTTP server block - redirect to HTTPS -http://localhost:80 { - # Redirect all HTTP traffic to HTTPS - redir https://localhost:8444{uri} permanent -} diff --git a/docker/frankenphp/Dockerfile b/docker/frankenphp/Dockerfile deleted file mode 100644 index 95efe2a..0000000 --- a/docker/frankenphp/Dockerfile +++ /dev/null @@ -1,74 +0,0 @@ -FROM dunglas/frankenphp:1.8-php8.4 - -# Build arguments for user/group -ARG USER_ID=1000 -ARG GROUP_ID=1000 -ARG USER_NAME=www-data -ARG GROUP_NAME=www-data - -# Change web server config -COPY docker/frankenphp/Caddyfile /etc/caddy/Caddyfile - -# Set document root to /app/public (Yii2 structure) -WORKDIR /app - -# Install required system packages for PHP extensions for Yii 2.0 Framework -COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/ -RUN install-php-extensions \ - bcmath \ - @composer \ - exif \ - gd \ - imagick \ - intl \ - opcache \ - pdo_mysql \ - pdo_pgsql \ - soap \ - xdebug \ - zip - -# Set composer environment -ENV COMPOSER_ALLOW_SUPERUSER=1 - -# Change PHP config -COPY docker/php/php.ini /usr/local/etc/php/conf.d/base.ini - -# Install supervisor, gosu, and Node.js (version simple) -RUN apt-get update && apt-get install -y --no-install-recommends \ - supervisor \ - curl \ - gosu \ - && curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \ - && apt-get install -y nodejs \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -# Apply the user/group IDs to www-data -RUN usermod -u ${USER_ID} www-data && groupmod -g ${GROUP_ID} www-data - -# Create composer and npm cache directories with proper ownership -RUN mkdir -p /var/www/.composer/cache /var/www/.npm && \ - chown -R www-data:www-data /var/www/.composer /var/www/.npm - -# Copy supervisor program configs -COPY docker/supervisor/conf.d/frankenphp.conf /etc/supervisor/conf.d/frankenphp.conf - -# Copy queue worker config uncommented for use with yii2-queue -#COPY docker/supervisor/conf.d/queue.conf /etc/supervisor/conf.d/queue.conf - -# Copy scripts -COPY docker/init.sh /usr/local/bin/init.sh -COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh - -# Make scripts executable and validate -RUN chmod +x /usr/local/bin/init.sh /usr/local/bin/entrypoint.sh && \ - # Convert any Windows line endings - sed -i 's/\r$//' /usr/local/bin/init.sh /usr/local/bin/entrypoint.sh && \ - # Test that scripts have valid syntax - bash -n /usr/local/bin/init.sh && \ - bash -n /usr/local/bin/entrypoint.sh && \ - echo "✓ Scripts validated successfully..." - -# Use ENTRYPOINT to guarantee execution -ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/docker/init.sh b/docker/init.sh deleted file mode 100644 index 2d00904..0000000 --- a/docker/init.sh +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/bash - -# Colors for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -NC='\033[0m' - -echo -e "${GREEN}Starting container setup...${NC}" - -# Create necessary Caddy directories with proper permissions -echo -e "${YELLOW}Creating Caddy directories...${NC}" -mkdir -p /data/caddy/locks /config/caddy -chown -R www-data:www-data /data /config -chmod -R 755 /data /config - -# Create PHP-FPM socket directory with proper permissions -echo -e "${YELLOW}Creating PHP-FPM socket directory...${NC}" -mkdir -p /var/run/php -chown www-data:www-data /var/run/php -chmod 755 /var/run/php - -# Create necessary Yii2 directories if they don't exist -echo -e "${YELLOW}Creating Yii2 directories...${NC}" -mkdir -p /app/runtime/cache -mkdir -p /app/runtime/logs -mkdir -p /app/public/assets - -# Configure permissions for Yii2 directories -echo -e "${YELLOW}Setting up permissions...${NC}" - -# Try to set permissions and ownership - handle both mounted volumes and container-only scenarios -if chown -R www-data:www-data /app/runtime 2>/dev/null; then - chmod -R 775 /app/runtime - echo -e "${GREEN}✓ Runtime directory configured correctly${NC}" -else - # If chown fails (mounted volume), try chmod only - if chmod -R 777 /app/runtime 2>/dev/null; then - echo -e "${YELLOW}⚠ Runtime directory permissions set to 777 (mounted volume)${NC}" - else - echo -e "${RED}✗ Error: Could not configure runtime directory${NC}" - fi -fi - -if chown -R www-data:www-data /app/public/assets 2>/dev/null; then - chmod -R 775 /app/public/assets - echo -e "${GREEN}✓ Assets directory configured correctly${NC}" -else - # If chown fails (mounted volume), try chmod only - if chmod -R 777 /app/public/assets 2>/dev/null; then - echo -e "${YELLOW}⚠ Assets directory permissions set to 777 (mounted volume)${NC}" - else - echo -e "${RED}✗ Error: Could not configure assets directory${NC}" - fi -fi - -echo -e "${GREEN}Setup completed.${NC}" - -# Check if composer.json exists and vendor directory doesn't exist -if [ -f "/app/composer.json" ] && [ ! -d "/app/vendor" ]; then - echo -e "${YELLOW}Installing Composer dependencies...${NC}" - - # Give www-data write access without exposing the tree to everyone - chown -R www-data:www-data /app && \ - chmod -R u+rwX,g+rwX /app - - # Create and configure npm cache directory for www-data - mkdir -p /var/www/.npm - chown -R www-data:www-data /var/www/.npm - - # Install dependencies with proper environment variables - if [ "$YII_ENV" = "prod" ]; then - # Production: exclude dev dependencies and optimize autoloader - gosu www-data env \ - HOME=/var/www \ - COMPOSER_HOME=/var/www/.composer \ - COMPOSER_CACHE_DIR=/var/www/.composer/cache \ - npm_config_cache=/var/www/.npm \ - composer install --no-dev --optimize-autoloader --no-interaction - else - # Development: include dev dependencies - gosu www-data env \ - HOME=/var/www \ - COMPOSER_HOME=/var/www/.composer \ - COMPOSER_CACHE_DIR=/var/www/.composer/cache \ - npm_config_cache=/var/www/.npm \ - composer install --optimize-autoloader --no-interaction - fi - - echo -e "${GREEN}✓ Composer dependencies installed successfully${NC}" -fi - -# Copy supervisor configuration -echo -e "${YELLOW}Configuring supervisor...${NC}" - -if [ -f "/app/docker/supervisor/supervisord.conf" ]; then - cp /app/docker/supervisor/supervisord.conf /etc/supervisor/supervisord.conf - echo -e "${GREEN}✓ Supervisor configuration copied successfully${NC}" -else - echo -e "${RED}✗ Error: Supervisor configuration file not found${NC}" - exit 1 -fi - -echo -e "${GREEN}Starting supervisor daemon...${NC}" - -# Start supervisor daemon -exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf diff --git a/docker/nginx/Dockerfile b/docker/nginx/Dockerfile deleted file mode 100644 index 71c426b..0000000 --- a/docker/nginx/Dockerfile +++ /dev/null @@ -1,60 +0,0 @@ -FROM yiisoftware/yii2-php:8.4-fpm-nginx - -# Build arguments for user/group -ARG USER_ID=1000 -ARG GROUP_ID=1000 -ARG USER_NAME=www-data -ARG GROUP_NAME=www-data - -# Change nginx config -COPY docker/nginx/nginx.conf /etc/nginx/nginx.conf -COPY docker/nginx/default.conf /etc/nginx/conf.d/default.conf - -# Change PHP config -COPY docker/php/php.ini /usr/local/etc/php/conf.d/base.ini - -# Set document root to /app/public (Yii2 structure) -WORKDIR /app - -# Set composer environment -ENV COMPOSER_ALLOW_SUPERUSER=1 - -# Install supervisor, gosu, and Node.js (version simple) -RUN apt-get update && apt-get install -y --no-install-recommends \ - supervisor \ - curl \ - gosu \ - && curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \ - && apt-get install -y nodejs \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -# Apply the user/group IDs to www-data -RUN usermod -u ${USER_ID} www-data && groupmod -g ${GROUP_ID} www-data - -# Create composer and npm cache directories with proper ownership -RUN mkdir -p /var/www/.composer/cache /var/www/.npm && \ - chown -R www-data:www-data /var/www/.composer /var/www/.npm - -# Copy supervisor program configs -COPY docker/supervisor/conf.d/nginx.conf /etc/supervisor/conf.d/nginx.conf -COPY docker/supervisor/conf.d/php-fpm.conf /etc/supervisor/conf.d/php-fpm.conf - -# Copy queue worker config uncommented for use with yii2-queue -#COPY docker/supervisor/conf.d/queue.conf /etc/supervisor/conf.d/queue.conf - -# Copy scripts -COPY docker/init.sh /usr/local/bin/init.sh -COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh - -# Make scripts executable and validate -RUN chmod +x /usr/local/bin/init.sh /usr/local/bin/entrypoint.sh && \ - # Convert any Windows line endings - sed -i 's/\r$//' /usr/local/bin/init.sh /usr/local/bin/entrypoint.sh && \ - # Test that scripts have valid syntax - bash -n /usr/local/bin/init.sh && \ - bash -n /usr/local/bin/entrypoint.sh && \ - echo "✓ Scripts validated successfully..." - -# Use ENTRYPOINT to guarantee execution -ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/docker/nginx/default.conf b/docker/nginx/default.conf deleted file mode 100644 index 995d710..0000000 --- a/docker/nginx/default.conf +++ /dev/null @@ -1,94 +0,0 @@ -# HTTP server - Redirect to HTTPS -server { - listen 80; - server_name localhost; - - # Redirect all HTTP to HTTPS - return 301 https://localhost:8445$request_uri; -} - -# HTTPS server -server { - charset utf-8; - client_max_body_size 128M; - listen 443 ssl http2; - server_name localhost; - - # SSL Configuration - ssl_certificate /app/docker/ssl/localhost.pem; - ssl_certificate_key /app/docker/ssl/localhost-key.pem; - - # SSL Security Settings - ssl_protocols TLSv1.2 TLSv1.3; - ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384; - ssl_prefer_server_ciphers off; - ssl_session_cache shared:SSL:10m; - ssl_session_timeout 10m; - - # Document root and index file - root /app/public; - index index.php; - - # Security headers - add_header X-Frame-Options "SAMEORIGIN" always; - add_header X-XSS-Protection "1; mode=block" always; - add_header X-Content-Type-Options "nosniff" always; - add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; - - # Logging - access_log /var/log/nginx/ssl_access.log; - error_log /var/log/nginx/ssl_error.log; - - # Yii URL rewriting (CRITICAL for Yii2) - location / { - try_files $uri $uri/ /index.php$is_args$args; - } - - # Deny PHP execution in /assets before the generic handler (Yii2 security) - location ~ ^/assets/.*\.php$ { - deny all; - return 403; - } - - # PHP handling via PHP-FPM - location ~ \.php$ { - include fastcgi_params; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param HTTPS on; - fastcgi_pass 127.0.0.1:9000; - try_files $uri =404; - - # PHP execution settings - fastcgi_read_timeout 300; - fastcgi_buffer_size 128k; - fastcgi_buffers 4 256k; - fastcgi_busy_buffers_size 256k; - } - - # Block access to sensitive files - location ~ /\.git { - deny all; - } - - location ~ /\.ht { - deny all; - } - - # Block access to hidden files/directories - location ~* /\. { - deny all; - } - - # Static files handling with caching - location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { - expires 1y; - add_header Cache-Control "public, immutable"; - try_files $uri =404; - } - - # Deny access to PHP files in specific directories - location ~ ^/(vendor|runtime)/.+\.php$ { - deny all; - return 404; - } -} diff --git a/docker/nginx/nginx.conf b/docker/nginx/nginx.conf deleted file mode 100644 index 8a6b419..0000000 --- a/docker/nginx/nginx.conf +++ /dev/null @@ -1,58 +0,0 @@ -user www-data; -worker_processes auto; -pid /run/nginx.pid; -include /etc/nginx/modules-enabled/*.conf; - -events { - worker_connections 768; - multi_accept on; - use epoll; -} - -http { - # Basic Settings - sendfile on; - tcp_nopush on; - tcp_nodelay on; - keepalive_timeout 65; - types_hash_max_size 2048; - - # Security headers - server_tokens off; - - include /etc/nginx/mime.types; - default_type application/octet-stream; - - # SSL Settings - ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM'; - ssl_ecdh_curve X25519:P-256; - ssl_prefer_server_ciphers on; - - # Logging Settings - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - - access_log /var/log/nginx/access.log main; - error_log /var/log/nginx/error.log warn; - - # Gzip Settings - gzip on; - gzip_vary on; - gzip_proxied any; - gzip_comp_level 6; - gzip_types - text/plain - text/css - text/xml - text/javascript - application/json - application/javascript - application/xml+rss - application/atom+xml - image/svg+xml; - - # Virtual Host Configs - include /etc/nginx/conf.d/*.conf; - include /etc/nginx/sites-enabled/*; -} diff --git a/docker/php/php.ini b/docker/php/php.ini deleted file mode 100644 index 92fe1f7..0000000 --- a/docker/php/php.ini +++ /dev/null @@ -1,23 +0,0 @@ -# Global PHP configuration for the Docker container -date.timezone = UTC -display_errors = Off -expose_php = Off -memory_limit = 512M -post_max_size = 150M -session.auto_start = Off -short_open_tag = Off -upload_max_filesize = 15M - -# https://symfony.com/doc/current/performance.html -# OPcache optimizations -opcache.enable = 1 -opcache.enable_cli = 1 -opcache.interned_strings_buffer = 16 -opcache.jit = tracing -opcache.jit_buffer_size = 64M -opcache.max_accelerated_files = 20000 -opcache.memory_consumption = 256 -opcache.revalidate_freq = 2 -opcache.validate_timestamps = 1 -realpath_cache_size = 4096K -realpath_cache_ttl = 120 diff --git a/docker/ssl/localhost-key.pem b/docker/ssl/localhost-key.pem deleted file mode 100644 index 4677e62..0000000 --- a/docker/ssl/localhost-key.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDJXRl0fj4a5Myo -WpAN8jevuPIlvS19Yk2243GIXf9rNt7/th4ujMYa7DyGmFE4UiXz/gj5y9vq6/3d -JNrVPqfcBHKgDdGt4V+c6bauzxhs+QilYzft/9/y/Mglt6Z9ibsvIGnRn6R8gc6W -dV2KPRUNDTdb83R0Y7CFRydTkTEYl1/mldAz5MNrlIYrr55PbQTG2fZlMXcfmJOh -TzGvux3skPRD4igTV8rxd0x5RDvcVdSCOx3vpI2ZJ3Vh28Bp934mTNo4Ihsmkn4A -nzUJsyRNAcXp//8xz9upvmy4FfqXhhR5/oOit4INMjFxkEA2CrX7CYz/EiRhyxWt -jGmxKXSVAgMBAAECggEARIxC7BtFvRYCbZVW0MiSGGnXVO2PnM1oM0g+D/QfzTnC -tD4lDCe0ENo2yIL1szyT2vmxyIeTd+eaZjvzmwBXWFjTRJUvuges6tfM7rllUUN9 -o/+gvI6MiEVxRRW9waKvbB2WqFu2PQRbdXDCxRqCHg1PuSepjy2Ym+ZbBuG4Wuwh -q9vbbqe0isp0YZr8oCeNTbR2Mi2q2DPUTP+WdA0TXulx+IwlIlYnIk0a2IGcdGpX -io9Mt3/aspZhx7uQf3yBoVMiOWRx/04t4Yc0oxuwLP4atGd7jhKZ2dfgCo6jPPet -ojIpJgN7vW3o4xRnrv0UuTq9vm2W0ZtV5Zfx4sp/gQKBgQDMBGV5s5itMXSdqoXg -4xtELye0oMYEd1ih8+ql+VP08nUeflV7vD6+Ci8/x++Azqpr9SU1KBG/9Cj2jK8k -uLdeKcEuac8DjU1eELGmDnIk4m0supEP3JyrTQCVQYw9Pwvv+jGNz2zi0xppIzoP -eObU/ftoV3Ue32c9tjMMvzlpBQKBgQD8q57knuAqTVJiIqo1LsRj+j5XQ3IpCYY7 -bVHHi607JywBE8JyerkycYCs6BU4AyZNe8Wp6YJM6qINHgvD13j7CjzSg/YEQVla -O196Ka08Latvu6D3BqR9oKy+5vto/QNxD0hGToWySZCVjbsc5QRxCbq77GZ05EpI -owj0Wz9yUQKBgEpFJ3Pgj6otINjs5QPzaU+vIvM8vBmQIPIES93UIF5BjaVmNFRx -OR4RsxWzAVuQ4LWgbsUlKyEID4mBuZjSrd5XsP3mgvg2Dn458ZIUHDWVQE1SNdDi -bR5nT9kGHbmGJCBeon+PjYIde7XenxpW1yGevFFF1VtB1OHAXGE9k/bJAoGBAJDa -wylGfDVERurD/NioiybWHE9i91vXfgEr1yqTRSkYd/3WGjAPc4Ub1S1LkH6gL6FU -SCn1GSKHkYf7pbsNGOqzH9OAm9YssNEuILqkkhBiDlrsMofsYvky2FZJjfDOvN5g -aIsGEVf5HM7ghlk2Yql7bna2PLbe+kdSUJvmhCVBAoGBAMY9+yNm9zpHYDLfgmeG -mUjUrw73G7j+ucRQI6/owgaqJWKlfULG2CQ18XhcpjJcI7R1gADwNwlJN7AjGDtg -gskDn8yoAGBvaBgkkkv3Z8rKTCGR8mh4bY6G89agY9NphigsaUJrn+4iX59K2/eK -DNFgybL+X7Mh7P8tmBt1Adua ------END PRIVATE KEY----- diff --git a/docker/ssl/localhost.pem b/docker/ssl/localhost.pem deleted file mode 100644 index 7338a1f..0000000 --- a/docker/ssl/localhost.pem +++ /dev/null @@ -1,26 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIEYjCCAsqgAwIBAgIRAMJ3dsZ62GwPUcMuKwB/pBQwDQYJKoZIhvcNAQELBQAw -gYcxHjAcBgNVBAoTFW1rY2VydCBkZXZlbG9wbWVudCBDQTEuMCwGA1UECwwlVGVy -YWJ5dGVzb2Z0d1xkZXZlbG9wZXJAVGVyYWJ5dGVzb2Z0dzE1MDMGA1UEAwwsbWtj -ZXJ0IFRlcmFieXRlc29mdHdcZGV2ZWxvcGVyQFRlcmFieXRlc29mdHcwHhcNMjUw -NzEwMjIxNjI2WhcNMjcxMDEwMjExNjI2WjBZMScwJQYDVQQKEx5ta2NlcnQgZGV2 -ZWxvcG1lbnQgY2VydGlmaWNhdGUxLjAsBgNVBAsMJVRlcmFieXRlc29mdHdcZGV2 -ZWxvcGVyQFRlcmFieXRlc29mdHcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK -AoIBAQDJXRl0fj4a5MyoWpAN8jevuPIlvS19Yk2243GIXf9rNt7/th4ujMYa7DyG -mFE4UiXz/gj5y9vq6/3dJNrVPqfcBHKgDdGt4V+c6bauzxhs+QilYzft/9/y/Mgl -t6Z9ibsvIGnRn6R8gc6WdV2KPRUNDTdb83R0Y7CFRydTkTEYl1/mldAz5MNrlIYr -r55PbQTG2fZlMXcfmJOhTzGvux3skPRD4igTV8rxd0x5RDvcVdSCOx3vpI2ZJ3Vh -28Bp934mTNo4Ihsmkn4AnzUJsyRNAcXp//8xz9upvmy4FfqXhhR5/oOit4INMjFx -kEA2CrX7CYz/EiRhyxWtjGmxKXSVAgMBAAGjdjB0MA4GA1UdDwEB/wQEAwIFoDAT -BgNVHSUEDDAKBggrBgEFBQcDATAfBgNVHSMEGDAWgBRlhRQpnl7nIy6O/r3UOcaY -LgXBSzAsBgNVHREEJTAjgglsb2NhbGhvc3SHBH8AAAGHEAAAAAAAAAAAAAAAAAAA -AAEwDQYJKoZIhvcNAQELBQADggGBAIR0dkwyUST+W8TATCZbYThwiYuTSLYyQvyX -7ieIYWW31nAfcL/WvMt5d80p67mLPvGoGLZSayId7uf6j0LVY2Y94G1z7HOdRd7s -D7InIrLI0G7pKSXI8mSCczgpx2FD2yIkHaDCdZIYXpkkAhJ6I4hghSG2KZoJ0vhA -JPTd9VW8ydYykfE619wjZ68RUlve4wtNkmQCrJAWOZMWCNl8O/iz5cWafTr0p4kD -6qdE/gKvfyWQdc1XgPpZJkpYNw+CGVcpfE7i/++FfspTTY+XyYZClbQjMD1hNGq/ -ATsl8DR4xH5ztUaAkLBRDXpXGal7VyNoBpBot9scDR71YMsTTKf/1NdIt8gPLF4P -ULwW7UvaHQAj3klPcanEaTv/bgQxor6b8tSwMLqHcU+SdQBjYnWLuAzKTCvL9m73 -MQRRt/N+Z9McSApps0F82eSR3a1HaU5lyH6Es6dLkVnY/ksmzqwi5FADsORSH95M -GvP9WbrnCQvIW/n3T3pvmuV/BeRkVg== ------END CERTIFICATE----- diff --git a/docker/supervisor/conf.d/apache2.conf b/docker/supervisor/conf.d/apache2.conf deleted file mode 100644 index 780bf67..0000000 --- a/docker/supervisor/conf.d/apache2.conf +++ /dev/null @@ -1,8 +0,0 @@ -[program:apache2] -command=/bin/bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND" -autorestart=true -autostart=true -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 diff --git a/docker/supervisor/conf.d/caddy-php-fpm.conf b/docker/supervisor/conf.d/caddy-php-fpm.conf deleted file mode 100644 index eaea1f5..0000000 --- a/docker/supervisor/conf.d/caddy-php-fpm.conf +++ /dev/null @@ -1,21 +0,0 @@ -[program:php-fpm] -command=/usr/local/sbin/php-fpm --nodaemonize -autorestart=true -autostart=true -priority=5 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -user=root - -[program:caddy] -command=/usr/bin/caddy run --config /etc/caddy/Caddyfile -autorestart=true -autostart=true -priority=10 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -user=www-data diff --git a/docker/supervisor/conf.d/frankenphp.conf b/docker/supervisor/conf.d/frankenphp.conf deleted file mode 100644 index d7958ce..0000000 --- a/docker/supervisor/conf.d/frankenphp.conf +++ /dev/null @@ -1,13 +0,0 @@ -[program:frankenphp] -command=/usr/local/bin/frankenphp run --config /etc/caddy/Caddyfile -autorestart=true -autostart=true -killasgroup=true -priority=10 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stopasgroup=true -stopsignal=QUIT -user=www-data diff --git a/docker/supervisor/conf.d/nginx.conf b/docker/supervisor/conf.d/nginx.conf deleted file mode 100644 index 3df5802..0000000 --- a/docker/supervisor/conf.d/nginx.conf +++ /dev/null @@ -1,12 +0,0 @@ -[program:nginx] -command=/usr/sbin/nginx -g "daemon off;" -autostart=true -autorestart=true -priority=10 -killasgroup=true -stopasgroup=true -stopsignal=QUIT -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/supervisor/conf.d/php-fpm.conf b/docker/supervisor/conf.d/php-fpm.conf deleted file mode 100644 index 39399ab..0000000 --- a/docker/supervisor/conf.d/php-fpm.conf +++ /dev/null @@ -1,13 +0,0 @@ - -[program:php-fpm] -command=/usr/local/sbin/php-fpm --nodaemonize -autorestart=true -autostart=true -killasgroup=true -priority=5 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stopasgroup=true -stopsignal=QUIT diff --git a/docker/supervisor/conf.d/queue.conf b/docker/supervisor/conf.d/queue.conf deleted file mode 100644 index b8eba53..0000000 --- a/docker/supervisor/conf.d/queue.conf +++ /dev/null @@ -1,11 +0,0 @@ -[program:yii-queue-worker] -process_name=%(program_name)s_%(process_num)02d -command=/usr/local/bin/php /app/yii queue/listen --verbose=1 --color=0 -autorestart=true -autostart=true -numprocs=4 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -user=www-data diff --git a/docker/supervisor/supervisord.conf b/docker/supervisor/supervisord.conf deleted file mode 100644 index d209121..0000000 --- a/docker/supervisor/supervisord.conf +++ /dev/null @@ -1,14 +0,0 @@ -[supervisord] -logfile = /proc/self/fd/1 -logfile_maxbytes = 0 -loglevel = info -nodaemon = true -pidfile = /var/run/supervisord.pid -silent = true -user = root - -[include] -files = /etc/supervisor/conf.d/*.conf - -[supervisorctl] -serverurl = unix:///var/run/supervisor.sock diff --git a/docs/images/404-dark.png b/docs/images/404-dark.png index 3cf66f4..bd66113 100644 Binary files a/docs/images/404-dark.png and b/docs/images/404-dark.png differ diff --git a/docs/images/404.png b/docs/images/404.png index 45ec140..b148fa1 100644 Binary files a/docs/images/404.png and b/docs/images/404.png differ diff --git a/docs/images/home-dark.png b/docs/images/home-dark.png index 4b32472..efa2e4d 100644 Binary files a/docs/images/home-dark.png and b/docs/images/home-dark.png differ diff --git a/docs/images/home.png b/docs/images/home.png index f98b701..3102caa 100644 Binary files a/docs/images/home.png and b/docs/images/home.png differ diff --git a/docs/installation.md b/docs/installation.md index 97b82d2..01b2e85 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -6,12 +6,10 @@ - [`Composer`](https://getcomposer.org/download/) for dependency management. - [`npm`](https://nodejs.org/en/download/) for frontend dependency management. - [`Yii2`](https://github.com/yiisoft/yii2) 2.0.53+ or 22.x. -- Web server (Apache, Nginx, or built-in PHP server). ### Optional requirements - **Node.js**: For advanced asset compilation (optional) -- **Docker**: For containerized development ## Installation methods @@ -20,16 +18,16 @@ Create a new project using the Yii App Basic template. ```bash -composer create-project --prefer-dist --stability=dev yii2-extensions/app-basic myapp -cd myapp +composer create-project --prefer-dist --stability=dev yii2-extensions/app-basic app-basic +cd app-basic ``` ### Method 2: Manual installation 1. **Download the template**: ```bash -git clone https://github.com/yii2-extensions/app-basic.git myapp -cd myapp +git clone https://github.com/yii2-extensions/app-basic.git app-basic +cd app-basic ``` 2. **Install dependencies** @@ -42,8 +40,8 @@ composer install Clone the repository and set up your project. ```bash -git clone https://github.com/yii2-extensions/app-basic.git myapp -cd myapp +git clone https://github.com/yii2-extensions/app-basic.git app-basic +cd app-basic rm -rf .git git init composer install @@ -59,47 +57,6 @@ Ensure the following directories are writable by the web server. chmod 775 web/assets runtime tests/_output ``` -### Web server configuration - -#### Apache - -Create `web/.htaccess`. - -```apache -RewriteEngine on -RewriteCond %{REQUEST_FILENAME} !-f -RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule . index.php -``` - -#### Nginx - -Add to your Nginx configuration. - -```nginx -server { - listen 80; - server_name myapp.local; - root /path/to/myapp/web; - index index.php; - - location / { - try_files $uri $uri/ /index.php?$query_string; - } - - location ~ \.php$ { - fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; - fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - include fastcgi_params; - } - - location ~ /\.(ht|svn|git) { - deny all; - } -} -``` - #### Built-in PHP server For development purposes. @@ -121,7 +78,7 @@ php -S localhost:8080 -t web 1. **Create database** ```sql -CREATE DATABASE myapp CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +CREATE DATABASE app_basic CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ``` 2. **Run migrations** (if available) @@ -149,58 +106,6 @@ npm run build npm run watch ``` -## Docker setup - -### Using docker compose - -Create `docker-compose.yml`. - -```yaml -version: '3.8' - -services: - web: - image: yiisoftware/yii2-php:8.1-apache - ports: - - "8080:80" - volumes: - - .:/app - depends_on: - - db - environment: - - DB_HOST=db - - DB_NAME=myapp - - DB_USER=root - - DB_PASSWORD=secret - - db: - image: mysql:8.0 - environment: - - MYSQL_ROOT_PASSWORD=secret - - MYSQL_DATABASE=myapp - volumes: - - mysql_data:/var/lib/mysql - -volumes: - mysql_data: -``` - -Run the application. - -```bash -docker-compose up -d -``` - -### Using Docker directly - -```bash -# Build custom image -docker build -t myapp . - -# Run container -docker run -p 8080:80 myapp -``` - ### Performance optimization #### Enable OPcache diff --git a/docs/screenshots.md b/docs/screenshots.md new file mode 100644 index 0000000..6ee927f --- /dev/null +++ b/docs/screenshots.md @@ -0,0 +1,17 @@ +# Screenshots + +## Home page + + + + + Home page + + +## Error page + + + + + Error page + diff --git a/src/usecase/Controller.php b/src/usecase/Controller.php index 7362515..35061eb 100644 --- a/src/usecase/Controller.php +++ b/src/usecase/Controller.php @@ -26,9 +26,7 @@ public function behaviors(): array 'verbs' => [ 'class' => VerbFilter::class, 'actions' => [ - 'logout' => [ - 'post', - ], + 'logout' => ['post'], ], ], ]; diff --git a/src/usecase/site/SiteController.php b/src/usecase/site/SiteController.php index f63c45d..2436e5a 100644 --- a/src/usecase/site/SiteController.php +++ b/src/usecase/site/SiteController.php @@ -5,7 +5,6 @@ namespace app\usecase\site; use app\usecase\Controller; -use yii\helpers\ArrayHelper; use yii\web\ErrorAction; final class SiteController extends Controller @@ -17,12 +16,9 @@ public function actionIndex(): string public function actions(): array { - return ArrayHelper::merge( - [ - '404' => ['class' => ErrorAction::class], - ], - parent::actions(), - ); + return [ + '404' => ['class' => ErrorAction::class], + ] + parent::actions(); } public function getViewPath(): string