diff --git a/.docker/nginx/app.laravel-optimus.80.conf b/.docker/nginx/app.laravel-optimus.80.conf deleted file mode 100644 index cc9f581..0000000 --- a/.docker/nginx/app.laravel-optimus.80.conf +++ /dev/null @@ -1,40 +0,0 @@ -server { - listen 80; - listen [::]:80; - server_name app.laravel-optimus.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.yml b/.github/workflows/tests.yml index 47b8eb1..a002540 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 5ec270d..21c0683 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to `cybercog/laravel-optimus` will be documented in this fil ## [Unreleased] +## [3.10.0] - 2024-03-09 + +### Added + +- ([#41]) Added Laravel 11 support + ## [3.9.0] - 2023-03-01 ### Added @@ -118,7 +124,8 @@ All notable changes to `cybercog/laravel-optimus` will be documented in this fil Initial release -[Unreleased]: https://github.com/cybercog/laravel-optimus/compare/3.9.0...master +[Unreleased]: https://github.com/cybercog/laravel-optimus/compare/3.10.0...master +[3.10.0]: https://github.com/cybercog/laravel-optimus/compare/3.9.0...3.10.0 [3.9.0]: https://github.com/cybercog/laravel-optimus/compare/3.8.0...3.9.0 [3.8.0]: https://github.com/cybercog/laravel-optimus/compare/3.7.0...3.8.0 [3.7.0]: https://github.com/cybercog/laravel-optimus/compare/3.6.0...3.7.0 @@ -134,6 +141,7 @@ Initial release [2.1.0]: https://github.com/cybercog/laravel-optimus/compare/2.0.0...2.1.0 [2.0.0]: https://github.com/cybercog/laravel-optimus/compare/1.0.0...2.0.0 +[#41]: https://github.com/cybercog/laravel-optimus/pull/41 [#35]: https://github.com/cybercog/laravel-optimus/pull/35 [#32]: https://github.com/cybercog/laravel-optimus/pull/32 [#31]: https://github.com/cybercog/laravel-optimus/pull/31 diff --git a/composer.json b/composer.json index ad83ae3..b8388a1 100644 --- a/composer.json +++ b/composer.json @@ -36,14 +36,14 @@ "require": { "php": "^7.4|^8.0", "graham-campbell/manager": "^5.0", - "illuminate/contracts": "^8.0|^9.0|^10.0", - "illuminate/support": "^8.0|^9.0|^10.0", + "illuminate/contracts": "^8.0|^9.0|^10.0|^11.0", + "illuminate/support": "^8.0|^9.0|^10.0|^11.0", "jenssegers/optimus": "^0.2.2" }, "require-dev": { "graham-campbell/testbench": "^6.0", "mockery/mockery": "^1.0", - "phpunit/phpunit": "^9.6" + "phpunit/phpunit": "^9.6|^10.5" }, "autoload": { "psr-4": { @@ -72,5 +72,5 @@ } }, "minimum-stability": "dev", - "prefer-stable" : true + "prefer-stable": true } diff --git a/docker-compose.yaml b/docker-compose.yaml index 03ea3d4..a2abb7b 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,35 +1,34 @@ version: "3.9" services: - app: - container_name: laravel-optimus-app - image: laravel-optimus-app + php81: + container_name: laravel-optimus-lib-81 + image: laravel-optimus-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-optimus - nginx: - container_name: laravel-optimus-nginx - image: nginx:1.21-alpine - restart: unless-stopped - depends_on: - - app - ports: - - "80:80" - environment: - VIRTUAL_HOST: app.laravel-optimus.localhost + php82: + container_name: laravel-optimus-lib-82 + image: laravel-optimus-lib-82 + build: + context: ./ + dockerfile: ./.docker/php/php82/Dockerfile + tty: true + working_dir: /app volumes: - - ./.docker/nginx/app.laravel-optimus.80.conf:/etc/nginx/conf.d/app.laravel-optimus.80.conf:ro - - ./public:/app/public:ro - networks: - - laravel-optimus + - ./:/app -networks: - laravel-optimus: - driver: bridge + php83: + container_name: laravel-optimus-lib-83 + image: laravel-optimus-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 f20e9e3..57755a4 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -12,8 +12,7 @@ > - tests/ - tests/database/factories/ + tests/Unit/ diff --git a/tests/Facades/OptimusTest.php b/tests/Unit/Facades/OptimusTest.php similarity index 94% rename from tests/Facades/OptimusTest.php rename to tests/Unit/Facades/OptimusTest.php index b088337..a3ddaba 100644 --- a/tests/Facades/OptimusTest.php +++ b/tests/Unit/Facades/OptimusTest.php @@ -11,7 +11,7 @@ declare(strict_types=1); -namespace Cog\Tests\Laravel\Optimus\Facades; +namespace Cog\Tests\Laravel\Optimus\Unit\Facades; use Cog\Laravel\Optimus\Facades\Optimus; use Cog\Laravel\Optimus\OptimusManager; diff --git a/tests/OptimusFactoryTest.php b/tests/Unit/OptimusFactoryTest.php similarity index 90% rename from tests/OptimusFactoryTest.php rename to tests/Unit/OptimusFactoryTest.php index 265dd1e..9a097d5 100644 --- a/tests/OptimusFactoryTest.php +++ b/tests/Unit/OptimusFactoryTest.php @@ -11,9 +11,10 @@ declare(strict_types=1); -namespace Cog\Tests\Laravel\Optimus; +namespace Cog\Tests\Laravel\Optimus\Unit; use Cog\Laravel\Optimus\OptimusFactory; +use Cog\Tests\Laravel\Optimus\AbstractTestCase; use Jenssegers\Optimus\Optimus; final class OptimusFactoryTest extends AbstractTestCase diff --git a/tests/OptimusManagerTest.php b/tests/Unit/OptimusManagerTest.php similarity index 97% rename from tests/OptimusManagerTest.php rename to tests/Unit/OptimusManagerTest.php index 994f51b..1a76d83 100644 --- a/tests/OptimusManagerTest.php +++ b/tests/Unit/OptimusManagerTest.php @@ -11,7 +11,7 @@ declare(strict_types=1); -namespace Cog\Tests\Laravel\Optimus; +namespace Cog\Tests\Laravel\Optimus\Unit; use Cog\Laravel\Optimus\OptimusFactory; use Cog\Laravel\Optimus\OptimusManager; diff --git a/tests/Providers/ServiceProviderTest.php b/tests/Unit/Providers/ServiceProviderTest.php similarity index 95% rename from tests/Providers/ServiceProviderTest.php rename to tests/Unit/Providers/ServiceProviderTest.php index 7597b45..9c60b63 100644 --- a/tests/Providers/ServiceProviderTest.php +++ b/tests/Unit/Providers/ServiceProviderTest.php @@ -11,7 +11,7 @@ declare(strict_types=1); -namespace Cog\Tests\Laravel\Optimus\Providers; +namespace Cog\Tests\Laravel\Optimus\Unit\Providers; use Cog\Laravel\Optimus\OptimusFactory; use Cog\Laravel\Optimus\OptimusManager; diff --git a/tests/Traits/OptimusEncodedRouteKeyTest.php b/tests/Unit/Traits/OptimusEncodedRouteKeyTest.php similarity index 98% rename from tests/Traits/OptimusEncodedRouteKeyTest.php rename to tests/Unit/Traits/OptimusEncodedRouteKeyTest.php index c12bb84..b3f8467 100644 --- a/tests/Traits/OptimusEncodedRouteKeyTest.php +++ b/tests/Unit/Traits/OptimusEncodedRouteKeyTest.php @@ -11,7 +11,7 @@ declare(strict_types=1); -namespace Cog\Tests\Laravel\Optimus\Traits; +namespace Cog\Tests\Laravel\Optimus\Unit\Traits; use Cog\Laravel\Optimus\Facades\Optimus; use Cog\Tests\Laravel\Optimus\AbstractTestCase; @@ -28,7 +28,7 @@ protected function setUp(): void parent::setUp(); $this->loadLaravelMigrations(config('database.default')); - $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); + $this->loadMigrationsFrom(__DIR__.'/../../database/migrations'); $this->configurePrimeNumbers(); }