From 1e481b03753db57595f5a9fa16c364d9e10944a0 Mon Sep 17 00:00:00 2001
From: Anton Komarev <1849174+antonkomarev@users.noreply.github.com>
Date: Sat, 9 Mar 2024 17:41:05 +0300
Subject: [PATCH] Add Laravel 11 support (#81)
---
.../nginx/app.laravel-eloquent-flag.80.conf | 40 ---------
.docker/php/{ => php81}/Dockerfile | 5 +-
.docker/php/php82/Dockerfile | 22 +++++
.docker/php/php83/Dockerfile | 22 +++++
.docker/php/www.conf | 85 -------------------
.github/workflows/tests.yaml | 21 +++--
CHANGELOG.md | 10 ++-
composer.json | 8 +-
docker-compose.yaml | 49 ++++++-----
phpunit.xml.dist | 2 +-
10 files changed, 102 insertions(+), 162 deletions(-)
delete mode 100644 .docker/nginx/app.laravel-eloquent-flag.80.conf
rename .docker/php/{ => php81}/Dockerfile (80%)
create mode 100644 .docker/php/php82/Dockerfile
create mode 100644 .docker/php/php83/Dockerfile
delete mode 100644 .docker/php/www.conf
diff --git a/.docker/nginx/app.laravel-eloquent-flag.80.conf b/.docker/nginx/app.laravel-eloquent-flag.80.conf
deleted file mode 100644
index dc9a002..0000000
--- a/.docker/nginx/app.laravel-eloquent-flag.80.conf
+++ /dev/null
@@ -1,40 +0,0 @@
-server {
- listen 80;
- listen [::]:80;
- server_name app.laravel-eloquent-flag.localhost;
-
- root /app/public;
- index index.php index.html;
- access_log /dev/stdout;
- error_log /dev/stderr info;
-
- charset utf-8;
-
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header X-Forwarded-Host $server_name;
-
- add_header Strict-Transport-Security "max-age=31536000" always;
- add_header X-Frame-Options "SAMEORIGIN" always;
- add_header X-Content-Type-Options "nosniff" always;
- add_header Referrer-Policy "strict-origin-when-cross-origin" always;
-
- server_tokens off;
- client_max_body_size 100M;
-
- location ~ \.php$ {
- try_files $uri =404;
- fastcgi_split_path_info ^(.+\.php)(/.+)$;
- fastcgi_pass app:9000;
- fastcgi_index index.php;
- include fastcgi_params;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- fastcgi_param PATH_INFO $fastcgi_path_info;
- }
-
- location / {
- try_files $uri $uri/ /index.php?$query_string;
- gzip_static on;
- }
-}
diff --git a/.docker/php/Dockerfile b/.docker/php/php81/Dockerfile
similarity index 80%
rename from .docker/php/Dockerfile
rename to .docker/php/php81/Dockerfile
index fa9f794..886291b 100644
--- a/.docker/php/Dockerfile
+++ b/.docker/php/php81/Dockerfile
@@ -1,7 +1,10 @@
# ----------------------
# The FPM base container
# ----------------------
-FROM php:8.1-fpm-alpine AS dev
+FROM php:8.1-cli-alpine AS dev
+
+RUN apk add --no-cache --virtual .build-deps \
+ $PHPIZE_DEPS
# Cleanup apk cache and temp files
RUN rm -rf /var/cache/apk/* /tmp/*
diff --git a/.docker/php/php82/Dockerfile b/.docker/php/php82/Dockerfile
new file mode 100644
index 0000000..1067d5c
--- /dev/null
+++ b/.docker/php/php82/Dockerfile
@@ -0,0 +1,22 @@
+# ----------------------
+# The FPM base container
+# ----------------------
+FROM php:8.2-cli-alpine AS dev
+
+RUN apk add --no-cache --virtual .build-deps \
+ $PHPIZE_DEPS
+
+# Cleanup apk cache and temp files
+RUN rm -rf /var/cache/apk/* /tmp/*
+
+# ----------------------
+# Composer install step
+# ----------------------
+
+# Get latest Composer
+COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
+
+# ----------------------
+# The FPM production container
+# ----------------------
+FROM dev
diff --git a/.docker/php/php83/Dockerfile b/.docker/php/php83/Dockerfile
new file mode 100644
index 0000000..4d8d02e
--- /dev/null
+++ b/.docker/php/php83/Dockerfile
@@ -0,0 +1,22 @@
+# ----------------------
+# The FPM base container
+# ----------------------
+FROM php:8.3-cli-alpine AS dev
+
+RUN apk add --no-cache --virtual .build-deps \
+ $PHPIZE_DEPS
+
+# Cleanup apk cache and temp files
+RUN rm -rf /var/cache/apk/* /tmp/*
+
+# ----------------------
+# Composer install step
+# ----------------------
+
+# Get latest Composer
+COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
+
+# ----------------------
+# The FPM production container
+# ----------------------
+FROM dev
diff --git a/.docker/php/www.conf b/.docker/php/www.conf
deleted file mode 100644
index 39bef0c..0000000
--- a/.docker/php/www.conf
+++ /dev/null
@@ -1,85 +0,0 @@
-; Start a new pool named 'www'.
-; the variable $pool can be used in any directive and will be replaced by the
-; pool name ('www' here)
-[www]
-
-; Unix user/group of processes
-; Note: The user is mandatory. If the group is not set, the default user's group
-; will be used.
-user = www-data
-group = www-data
-
-; The address on which to accept FastCGI requests.
-; Valid syntaxes are:
-; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
-; a specific port;
-; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
-; a specific port;
-; 'port' - to listen on a TCP socket to all addresses
-; (IPv6 and IPv4-mapped) on a specific port;
-; '/path/to/unix/socket' - to listen on a unix socket.
-; Note: This value is mandatory.
-listen = 9000
-
-; Choose how the process manager will control the number of child processes.
-; Possible Values:
-; static - a fixed number (pm.max_children) of child processes;
-; dynamic - the number of child processes are set dynamically based on the
-; following directives. With this process management, there will be
-; always at least 1 children.
-; pm.max_children - the maximum number of children that can
-; be alive at the same time.
-; pm.start_servers - the number of children created on startup.
-; pm.min_spare_servers - the minimum number of children in 'idle'
-; state (waiting to process). If the number
-; of 'idle' processes is less than this
-; number then some children will be created.
-; pm.max_spare_servers - the maximum number of children in 'idle'
-; state (waiting to process). If the number
-; of 'idle' processes is greater than this
-; number then some children will be killed.
-; ondemand - no children are created at startup. Children will be forked when
-; new requests will connect. The following parameter are used:
-; pm.max_children - the maximum number of children that
-; can be alive at the same time.
-; pm.process_idle_timeout - The number of seconds after which
-; an idle process will be killed.
-; Note: This value is mandatory.
-pm = dynamic
-
-; The number of child processes to be created when pm is set to 'static' and the
-; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
-; This value sets the limit on the number of simultaneous requests that will be
-; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
-; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
-; CGI. The below defaults are based on a server without much resources. Don't
-; forget to tweak pm.* to fit your needs.
-; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
-; Note: This value is mandatory.
-pm.max_children = 5
-
-; The number of child processes created on startup.
-; Note: Used only when pm is set to 'dynamic'
-; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
-pm.start_servers = 2
-
-; The desired minimum number of idle server processes.
-; Note: Used only when pm is set to 'dynamic'
-; Note: Mandatory when pm is set to 'dynamic'
-pm.min_spare_servers = 1
-
-; The desired maximum number of idle server processes.
-; Note: Used only when pm is set to 'dynamic'
-; Note: Mandatory when pm is set to 'dynamic'
-pm.max_spare_servers = 3
-
-; The number of seconds after which an idle process will be killed.
-; Note: Used only when pm is set to 'ondemand'
-; Default Value: 10s
-;pm.process_idle_timeout = 10s;
-
-; The number of requests each child process should execute before respawning.
-; This can be useful to work around memory leaks in 3rd party libraries. For
-; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
-; Default Value: 0
-;pm.max_requests = 500
diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml
index 47b8eb1..a002540 100644
--- a/.github/workflows/tests.yaml
+++ b/.github/workflows/tests.yaml
@@ -1,27 +1,38 @@
name: tests
-on: [ push, pull_request ]
+on:
+ - push
+ - pull_request
jobs:
test:
runs-on: ${{ matrix.os }}
+
strategy:
fail-fast: true
matrix:
- os: [ ubuntu-latest ]
- php: [ 8.0, 8.1, 8.2 ]
- laravel: [ 9.*, 10.* ]
- dependency-version: [ prefer-lowest, prefer-stable ]
+ os: [ubuntu-latest]
+ php: [8.0, 8.1, 8.2, 8.3]
+ laravel: ['9.*', '10.*', '11.*']
+ dependency-version: [prefer-lowest, prefer-stable]
exclude:
- laravel: 9.*
php: 8.2
+ - laravel: 9.*
+ php: 8.3
- laravel: 10.*
php: 8.0
+ - laravel: 11.*
+ php: 8.0
+ - laravel: 11.*
+ php: 8.1
include:
- laravel: 9.*
testbench: 7.*
- laravel: 10.*
testbench: 8.*
+ - laravel: 11.*
+ testbench: 9.*
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6db22dc..d0d551e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,12 @@ All notable changes to `cybercog/laravel-eloquent-flag` will be documented in th
## [Unreleased]
+## [6.1.0] - 2024-03-09
+
+### Added
+
+- ([#81]) Added Laravel 11 support
+
## [6.0.0] - 2023-02-24
### Added
@@ -319,7 +325,8 @@ All notable changes to `cybercog/laravel-eloquent-flag` will be documented in th
- `is_active` boolean flag added.
-[Unreleased]: https://github.com/cybercog/laravel-eloquent-flag/compare/6.0.0...master
+[Unreleased]: https://github.com/cybercog/laravel-eloquent-flag/compare/6.1.0...master
+[6.1.0]: https://github.com/cybercog/laravel-eloquent-flag/compare/6.0.0...6.1.0
[6.0.0]: https://github.com/cybercog/laravel-eloquent-flag/compare/5.4.0...6.0.0
[5.4.0]: https://github.com/cybercog/laravel-eloquent-flag/compare/5.3.0...5.4.0
[5.3.0]: https://github.com/cybercog/laravel-eloquent-flag/compare/5.2.0...5.3.0
@@ -351,6 +358,7 @@ All notable changes to `cybercog/laravel-eloquent-flag` will be documented in th
[1.2.0]: https://github.com/cybercog/laravel-eloquent-flag/compare/1.1.0...1.2.0
[1.1.0]: https://github.com/cybercog/laravel-eloquent-flag/compare/1.0.0...1.1.0
+[#81]: https://github.com/cybercog/laravel-eloquent-flag/pull/81
[#77]: https://github.com/cybercog/laravel-eloquent-flag/pull/77
[#74]: https://github.com/cybercog/laravel-eloquent-flag/pull/71
[#71]: https://github.com/cybercog/laravel-eloquent-flag/pull/71
diff --git a/composer.json b/composer.json
index 38d0f70..74a7d14 100644
--- a/composer.json
+++ b/composer.json
@@ -54,12 +54,12 @@
},
"require": {
"php": "^8.0",
- "illuminate/database": "^9.0|^10.0"
+ "illuminate/database": "^9.0|^10.0|^11.0"
},
"require-dev": {
"mockery/mockery": "^1.0",
- "orchestra/testbench": "^7.0|^8.0",
- "phpunit/phpunit": "^9.6"
+ "orchestra/testbench": "^7.0|^8.0|^9.0",
+ "phpunit/phpunit": "^9.6|^10.5"
},
"autoload": {
"psr-4": {
@@ -79,5 +79,5 @@
"sort-packages": true
},
"minimum-stability": "dev",
- "prefer-stable" : true
+ "prefer-stable": true
}
diff --git a/docker-compose.yaml b/docker-compose.yaml
index 5ceb032..1dd4066 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -1,35 +1,34 @@
version: "3.9"
services:
- app:
- container_name: laravel-eloquent-flag-app
- image: laravel-eloquent-flag-app
+ php81:
+ container_name: laravel-eloquent-flag-lib-81
+ image: laravel-eloquent-flag-lib-81
build:
context: ./
- dockerfile: ./.docker/php/Dockerfile
- restart: unless-stopped
+ dockerfile: ./.docker/php/php81/Dockerfile
+ tty: true
working_dir: /app
volumes:
- ./:/app
- - ./.docker/php/www.conf:/usr/local/etc/php-fpm.d/www.conf:ro
- networks:
- - laravel-eloquent-flag
- nginx:
- container_name: laravel-eloquent-flag-nginx
- image: nginx:1.21-alpine
- restart: unless-stopped
- depends_on:
- - app
- ports:
- - "80:80"
- environment:
- VIRTUAL_HOST: app.laravel-eloquent-flag.localhost
+ php82:
+ container_name: laravel-eloquent-flag-lib-82
+ image: laravel-eloquent-flag-lib-82
+ build:
+ context: ./
+ dockerfile: ./.docker/php/php82/Dockerfile
+ tty: true
+ working_dir: /app
volumes:
- - ./.docker/nginx/app.laravel-eloquent-flag.80.conf:/etc/nginx/conf.d/app.laravel-eloquent-flag.80.conf:ro
- - ./public:/app/public:ro
- networks:
- - laravel-eloquent-flag
+ - ./:/app
-networks:
- laravel-eloquent-flag:
- driver: bridge
+ php83:
+ container_name: laravel-eloquent-flag-lib-83
+ image: laravel-eloquent-flag-lib-83
+ build:
+ context: ./
+ dockerfile: ./.docker/php/php83/Dockerfile
+ tty: true
+ working_dir: /app
+ volumes:
+ - ./:/app
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 51f1008..57755a4 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -12,7 +12,7 @@
>
- tests/
+ tests/Unit/