From d9fae25cec83c7d89b36ddee6da558edae77525f Mon Sep 17 00:00:00 2001
From: Anton Komarev <1849174+antonkomarev@users.noreply.github.com>
Date: Sat, 9 Mar 2024 15:36:16 +0300
Subject: [PATCH] Add Laravel 11 support (#258)
---
.docker/nginx/app.laravel-love.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.yml | 21 +++++--
CHANGELOG.md | 2 +
composer.json | 10 +--
docker-compose.yaml | 49 ++++++++-------
phpunit.xml.dist | 2 +-
10 files changed, 96 insertions(+), 162 deletions(-)
delete mode 100644 .docker/nginx/app.laravel-love.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-love.80.conf b/.docker/nginx/app.laravel-love.80.conf
deleted file mode 100644
index a4e046b5..00000000
--- a/.docker/nginx/app.laravel-love.80.conf
+++ /dev/null
@@ -1,40 +0,0 @@
-server {
- listen 80;
- listen [::]:80;
- server_name app.laravel-love.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 fa9f794f..886291b6 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 00000000..1067d5c3
--- /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 00000000..4d8d02e6
--- /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 39bef0c4..00000000
--- 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.yml b/.github/workflows/tests.yml
index 47b8eb11..a002540c 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -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 86ff2b6b..ad8cec7d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@ All notable changes to `laravel-love` will be documented in this file.
### Added
+- ([#258]) Added Laravel 11 support
- ([#240]) Added `getReactionsBy` method to Reacter Facade
- ([#240]) Added `getReactionsBy` method to Reacter Model
@@ -593,6 +594,7 @@ Follow [upgrade instructions](UPGRADING.md#from-v5-to-v6) to migrate database to
[1.1.1]: https://github.com/cybercog/laravel-love/compare/1.1.0...1.1.1
[1.1.0]: https://github.com/cybercog/laravel-love/compare/1.0.0...1.1.0
+[#258]: https://github.com/cybercog/laravel-love/pull/258
[#252]: https://github.com/cybercog/laravel-love/pull/252
[#248]: https://github.com/cybercog/laravel-love/pull/248
[#247]: https://github.com/cybercog/laravel-love/pull/247
diff --git a/composer.json b/composer.json
index cf40e3c6..5dda8732 100644
--- a/composer.json
+++ b/composer.json
@@ -47,14 +47,14 @@
},
"require": {
"php": "^8.0",
- "illuminate/database": "^9.0|^10.1.3",
- "illuminate/support": "^9.0|^10.1.3"
+ "illuminate/database": "^9.0|^10.1.3|^11.0",
+ "illuminate/support": "^9.0|^10.1.3|^11.0"
},
"require-dev": {
"mockery/mockery": "^1.0",
- "orchestra/testbench": "^7.0|^8.0",
+ "orchestra/testbench": "^7.0|^8.0|^9.0",
"phpstan/phpstan": "^1.9",
- "phpunit/phpunit": "^9.6"
+ "phpunit/phpunit": "^9.6|^10.5"
},
"autoload": {
"psr-4": {
@@ -84,5 +84,5 @@
}
},
"minimum-stability": "dev",
- "prefer-stable" : true
+ "prefer-stable": true
}
diff --git a/docker-compose.yaml b/docker-compose.yaml
index 83ec08be..8a980641 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -1,35 +1,34 @@
version: "3.9"
services:
- app:
- container_name: laravel-love-app
- image: laravel-love-app
+ php81:
+ container_name: laravel-love-lib-81
+ image: laravel-love-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-love
- nginx:
- container_name: laravel-love-nginx
- image: nginx:1.21-alpine
- restart: unless-stopped
- depends_on:
- - app
- ports:
- - "80:80"
- environment:
- VIRTUAL_HOST: app.laravel-love.localhost
+ php82:
+ container_name: laravel-love-lib-82
+ image: laravel-love-lib-82
+ build:
+ context: ./
+ dockerfile: ./.docker/php/php82/Dockerfile
+ tty: true
+ working_dir: /app
volumes:
- - ./.docker/nginx/app.laravel-love.80.conf:/etc/nginx/conf.d/app.laravel-love.80.conf:ro
- - ./public:/app/public:ro
- networks:
- - laravel-love
+ - ./:/app
-networks:
- laravel-love:
- driver: bridge
+ php83:
+ container_name: laravel-love-lib-83
+ image: laravel-love-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 f530d27f..fd6a6a3e 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -12,7 +12,7 @@
>
- tests/
+ tests/Unit/