Skip to content

Commit c654179

Browse files
authored
Add Laravel v10 support (#77)
* Add Laravel 10 support * Replace $dates with $casts usage * Remove orchestra/database dev dependency * Add docker compose for dev
1 parent bb7c306 commit c654179

21 files changed

+226
-58
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
server {
2+
listen 80;
3+
listen [::]:80;
4+
server_name app.laravel-eloquent-flag.localhost;
5+
6+
root /app/public;
7+
index index.php index.html;
8+
access_log /dev/stdout;
9+
error_log /dev/stderr info;
10+
11+
charset utf-8;
12+
13+
proxy_set_header Host $host;
14+
proxy_set_header X-Real-IP $remote_addr;
15+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
16+
proxy_set_header X-Forwarded-Host $server_name;
17+
18+
add_header Strict-Transport-Security "max-age=31536000" always;
19+
add_header X-Frame-Options "SAMEORIGIN" always;
20+
add_header X-Content-Type-Options "nosniff" always;
21+
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
22+
23+
server_tokens off;
24+
client_max_body_size 100M;
25+
26+
location ~ \.php$ {
27+
try_files $uri =404;
28+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
29+
fastcgi_pass app:9000;
30+
fastcgi_index index.php;
31+
include fastcgi_params;
32+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
33+
fastcgi_param PATH_INFO $fastcgi_path_info;
34+
}
35+
36+
location / {
37+
try_files $uri $uri/ /index.php?$query_string;
38+
gzip_static on;
39+
}
40+
}

.docker/php/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# ----------------------
2+
# The FPM base container
3+
# ----------------------
4+
FROM php:8.1-fpm-alpine AS dev
5+
6+
# Cleanup apk cache and temp files
7+
RUN rm -rf /var/cache/apk/* /tmp/*
8+
9+
# ----------------------
10+
# Composer install step
11+
# ----------------------
12+
13+
# Get latest Composer
14+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
15+
16+
# ----------------------
17+
# The FPM production container
18+
# ----------------------
19+
FROM dev

.docker/php/www.conf

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
; Start a new pool named 'www'.
2+
; the variable $pool can be used in any directive and will be replaced by the
3+
; pool name ('www' here)
4+
[www]
5+
6+
; Unix user/group of processes
7+
; Note: The user is mandatory. If the group is not set, the default user's group
8+
; will be used.
9+
user = www-data
10+
group = www-data
11+
12+
; The address on which to accept FastCGI requests.
13+
; Valid syntaxes are:
14+
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
15+
; a specific port;
16+
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
17+
; a specific port;
18+
; 'port' - to listen on a TCP socket to all addresses
19+
; (IPv6 and IPv4-mapped) on a specific port;
20+
; '/path/to/unix/socket' - to listen on a unix socket.
21+
; Note: This value is mandatory.
22+
listen = 9000
23+
24+
; Choose how the process manager will control the number of child processes.
25+
; Possible Values:
26+
; static - a fixed number (pm.max_children) of child processes;
27+
; dynamic - the number of child processes are set dynamically based on the
28+
; following directives. With this process management, there will be
29+
; always at least 1 children.
30+
; pm.max_children - the maximum number of children that can
31+
; be alive at the same time.
32+
; pm.start_servers - the number of children created on startup.
33+
; pm.min_spare_servers - the minimum number of children in 'idle'
34+
; state (waiting to process). If the number
35+
; of 'idle' processes is less than this
36+
; number then some children will be created.
37+
; pm.max_spare_servers - the maximum number of children in 'idle'
38+
; state (waiting to process). If the number
39+
; of 'idle' processes is greater than this
40+
; number then some children will be killed.
41+
; ondemand - no children are created at startup. Children will be forked when
42+
; new requests will connect. The following parameter are used:
43+
; pm.max_children - the maximum number of children that
44+
; can be alive at the same time.
45+
; pm.process_idle_timeout - The number of seconds after which
46+
; an idle process will be killed.
47+
; Note: This value is mandatory.
48+
pm = dynamic
49+
50+
; The number of child processes to be created when pm is set to 'static' and the
51+
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
52+
; This value sets the limit on the number of simultaneous requests that will be
53+
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
54+
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
55+
; CGI. The below defaults are based on a server without much resources. Don't
56+
; forget to tweak pm.* to fit your needs.
57+
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
58+
; Note: This value is mandatory.
59+
pm.max_children = 5
60+
61+
; The number of child processes created on startup.
62+
; Note: Used only when pm is set to 'dynamic'
63+
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
64+
pm.start_servers = 2
65+
66+
; The desired minimum number of idle server processes.
67+
; Note: Used only when pm is set to 'dynamic'
68+
; Note: Mandatory when pm is set to 'dynamic'
69+
pm.min_spare_servers = 1
70+
71+
; The desired maximum number of idle server processes.
72+
; Note: Used only when pm is set to 'dynamic'
73+
; Note: Mandatory when pm is set to 'dynamic'
74+
pm.max_spare_servers = 3
75+
76+
; The number of seconds after which an idle process will be killed.
77+
; Note: Used only when pm is set to 'ondemand'
78+
; Default Value: 10s
79+
;pm.process_idle_timeout = 10s;
80+
81+
; The number of requests each child process should execute before respawning.
82+
; This can be useful to work around memory leaks in 3rd party libraries. For
83+
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
84+
; Default Value: 0
85+
;pm.max_requests = 500

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
* text=auto
22

3+
/.docker export-ignore
34
/.github export-ignore
45
/tests export-ignore
56
/.gitattributes export-ignore
@@ -8,4 +9,5 @@
89
/.travis.yml export-ignore
910
/CODE_OF_CONDUCT.md export-ignore
1011
/CONTRIBUTING.md export-ignore
12+
/docker-compose.yaml export-ignore
1113
/phpunit.xml.dist export-ignore

.github/workflows/tests.yaml

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,19 @@ jobs:
99
fail-fast: true
1010
matrix:
1111
os: [ ubuntu-latest ]
12-
php: [ 7.2, 7.3, 7.4, 8.0, 8.1 ]
13-
laravel: [ 6.*, 7.*, 8.*, 9.* ]
12+
php: [ 8.0, 8.1, 8.2 ]
13+
laravel: [ 9.*, 10.* ]
1414
dependency-version: [ prefer-lowest, prefer-stable ]
1515
exclude:
16-
- laravel: 6.*
17-
dependency-version: prefer-lowest
18-
- laravel: 7.*
19-
dependency-version: prefer-lowest
20-
- laravel: 8.*
21-
dependency-version: prefer-lowest
2216
- laravel: 9.*
23-
dependency-version: prefer-lowest
24-
- laravel: 6.*
25-
php: 8.1
26-
- laravel: 7.*
27-
php: 8.1
28-
- laravel: 8.*
29-
php: 7.2
30-
- laravel: 9.*
31-
php: 7.2
32-
- laravel: 9.*
33-
php: 7.3
34-
- laravel: 9.*
35-
php: 7.4
17+
php: 8.2
18+
- laravel: 10.*
19+
php: 8.0
3620
include:
37-
- laravel: 6.*
38-
testbench: 4.*
39-
- laravel: 7.*
40-
testbench: 5.*
41-
- laravel: 8.*
42-
testbench: 6.*
43-
legacy-factories: 1.*
4421
- laravel: 9.*
4522
testbench: 7.*
46-
legacy-factories: 1.*
23+
- laravel: 10.*
24+
testbench: 8.*
4725

4826
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
4927

@@ -70,10 +48,5 @@ jobs:
7048
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
7149
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
7250
73-
- name: Install legacy factories dependency
74-
run: |
75-
composer require "laravel/legacy-factories:${{ matrix.legacy-factories }}" --no-interaction
76-
if: matrix.legacy-factories
77-
7851
- name: Execute tests
79-
run: vendor/bin/phpunit --verbose
52+
run: vendor/bin/phpunit --testdox

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@ All notable changes to `cybercog/laravel-eloquent-flag` will be documented in th
44

55
## [Unreleased]
66

7+
### Added
8+
9+
- ([#77]) Added Laravel 10 support
10+
11+
### Changed
12+
13+
- ([#77]) Timestamp flagged attributes using Eloquent Model `$casts` property
14+
15+
### Removed
16+
17+
- ([#77]) Dropped Laravel 5.8 support
18+
- ([#77]) Dropped Laravel 6 support
19+
- ([#77]) Dropped Laravel 7 support
20+
- ([#77]) Dropped Laravel 8 support
21+
722
## [5.4.0] - 2022-04-13
823

924
### Added
@@ -333,6 +348,7 @@ All notable changes to `cybercog/laravel-eloquent-flag` will be documented in th
333348
[1.2.0]: https://github.com/cybercog/laravel-eloquent-flag/compare/1.1.0...1.2.0
334349
[1.1.0]: https://github.com/cybercog/laravel-eloquent-flag/compare/1.0.0...1.1.0
335350

351+
[#77]: https://github.com/cybercog/laravel-eloquent-flag/pull/77
336352
[#74]: https://github.com/cybercog/laravel-eloquent-flag/pull/71
337353
[#71]: https://github.com/cybercog/laravel-eloquent-flag/pull/71
338354
[#69]: https://github.com/cybercog/laravel-eloquent-flag/pull/69

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ This project follows [PSR-12 coding style guide](https://www.php-fig.org/psr/psr
2525

2626
The phpunit script can be used to invoke the PHPUnit test runner:
2727

28-
```shell script
29-
$ vendor/bin/phpunit
28+
```shell
29+
vendor/bin/phpunit
3030
```
3131

3232
## Reporting issues

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ Helper traits will automatically cast flag attributes to a `DateTime` / `Carbon`
9999

100100
Pull in the package through Composer.
101101

102-
```shell script
103-
$ composer require cybercog/laravel-eloquent-flag
102+
```shell
103+
composer require cybercog/laravel-eloquent-flag
104104
```
105105

106106
## Usage
@@ -123,8 +123,8 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
123123

124124
Run the tests with:
125125

126-
```shell script
127-
$ vendor/bin/phpunit
126+
```shell
127+
vendor/bin/phpunit
128128
```
129129

130130
## Security

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@
5353
"docs": "https://github.com/cybercog/laravel-eloquent-flag/wiki"
5454
},
5555
"require": {
56-
"php": "^7.1.3|^8.0",
57-
"illuminate/database": "^5.8|^6.0|^7.0|^8.0|^9.0"
56+
"php": "^8.0",
57+
"illuminate/database": "^9.0|^10.0",
58+
"laravel/legacy-factories": "^1.3"
5859
},
5960
"require-dev": {
6061
"mockery/mockery": "^1.0",
61-
"orchestra/database": "~3.8.0|^4.0|^5.0|^6.0|^7.0",
62-
"orchestra/testbench": "~3.8.0|^4.0|^5.0|^6.0|^7.0",
63-
"phpunit/phpunit": "^7.0|^8.0|^9.0"
62+
"orchestra/testbench": "^7.0|^8.0",
63+
"phpunit/phpunit": "^9.6"
6464
},
6565
"autoload": {
6666
"psr-4": {

docker-compose.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: "3.9"
2+
services:
3+
app:
4+
container_name: laravel-eloquent-flag-app
5+
image: laravel-eloquent-flag-app
6+
build:
7+
context: ./
8+
dockerfile: ./.docker/php/Dockerfile
9+
restart: unless-stopped
10+
working_dir: /app
11+
volumes:
12+
- ./:/app
13+
- ./.docker/php/www.conf:/usr/local/etc/php-fpm.d/www.conf:ro
14+
networks:
15+
- laravel-eloquent-flag
16+
17+
nginx:
18+
container_name: laravel-eloquent-flag-nginx
19+
image: nginx:1.21-alpine
20+
restart: unless-stopped
21+
depends_on:
22+
- app
23+
ports:
24+
- "80:80"
25+
environment:
26+
VIRTUAL_HOST: app.laravel-eloquent-flag.localhost
27+
volumes:
28+
- ./.docker/nginx/app.laravel-eloquent-flag.80.conf:/etc/nginx/conf.d/app.laravel-eloquent-flag.80.conf:ro
29+
- ./public:/app/public:ro
30+
networks:
31+
- laravel-eloquent-flag
32+
33+
networks:
34+
laravel-eloquent-flag:
35+
driver: bridge

src/Traits/Classic/HasAcceptedAtHelpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ trait HasAcceptedAtHelpers
1919
{
2020
public function initializeHasAcceptedAtHelpers(): void
2121
{
22-
$this->dates[] = 'accepted_at';
22+
$this->casts['accepted_at'] = 'datetime';
2323
}
2424

2525
public function isAccepted(): bool

src/Traits/Classic/HasApprovedAtHelpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ trait HasApprovedAtHelpers
1919
{
2020
public function initializeHasApprovedAtHelpers(): void
2121
{
22-
$this->dates[] = 'approved_at';
22+
$this->casts['approved_at'] = 'datetime';
2323
}
2424

2525
public function isApproved(): bool

src/Traits/Classic/HasInvitedAtHelpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ trait HasInvitedAtHelpers
1919
{
2020
public function initializeHasInvitedAtHelpers(): void
2121
{
22-
$this->dates[] = 'invited_at';
22+
$this->casts['invited_at'] = 'datetime';
2323
}
2424

2525
public function isInvited(): bool

src/Traits/Classic/HasPublishedAtHelpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ trait HasPublishedAtHelpers
1919
{
2020
public function initializeHasPublishedAtHelpers(): void
2121
{
22-
$this->dates[] = 'published_at';
22+
$this->casts['published_at'] = 'datetime';
2323
}
2424

2525
public function isPublished(): bool

src/Traits/Classic/HasVerifiedAtHelpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ trait HasVerifiedAtHelpers
1919
{
2020
public function initializeHasVerifiedAtHelpers(): void
2121
{
22-
$this->dates[] = 'verified_at';
22+
$this->casts['verified_at'] = 'datetime';
2323
}
2424

2525
public function isVerified(): bool

src/Traits/Inverse/HasArchivedAtHelpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ trait HasArchivedAtHelpers
1919
{
2020
public function initializeHasArchivedAtHelpers(): void
2121
{
22-
$this->dates[] = 'archived_at';
22+
$this->casts['archived_at'] = 'datetime';
2323
}
2424

2525
public function isArchived(): bool

0 commit comments

Comments
 (0)