Skip to content

Commit c68c345

Browse files
authored
Prepare Laravel v9 release (#27)
1 parent b694d37 commit c68c345

File tree

11 files changed

+285
-26
lines changed

11 files changed

+285
-26
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-ownership.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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
* text=auto
22

3+
/.docker export-ignore
4+
/.github export-ignore
35
/tests export-ignore
46
/.gitattributes export-ignore
57
/.gitignore export-ignore
68
/.styleci.yml export-ignore
79
/.travis.yml export-ignore
810
/CODE_OF_CONDUCT.md export-ignore
911
/CONTRIBUTING.md export-ignore
12+
/docker-compose.yaml export-ignore
1013
/phpunit.xml.dist export-ignore

.github/workflows/tests.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: tests
2+
3+
on: [ push, pull_request ]
4+
5+
jobs:
6+
test:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
fail-fast: true
10+
matrix:
11+
os: [ ubuntu-latest ]
12+
php: [ 8.0, 8.1, 8.2 ]
13+
laravel: [ 9.* ]
14+
dependency-version: [ prefer-lowest, prefer-stable ]
15+
exclude:
16+
- laravel: 9.*
17+
php: 8.2
18+
include:
19+
- laravel: 9.*
20+
testbench: 7.*
21+
legacy-factories: 1.*
22+
23+
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
24+
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v2
28+
29+
- name: Cache dependencies
30+
uses: actions/cache@v2
31+
with:
32+
path: ~/.composer/cache/files
33+
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
34+
35+
- name: Setup PHP
36+
uses: shivammathur/setup-php@v2
37+
with:
38+
php-version: ${{ matrix.php }}
39+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, redis, memcached
40+
tools: composer:v2
41+
coverage: none
42+
43+
- name: Install dependencies
44+
run: |
45+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
46+
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
47+
48+
- name: Install legacy factories dependency
49+
run: |
50+
composer require "laravel/legacy-factories:${{ matrix.legacy-factories }}" --no-interaction
51+
if: matrix.legacy-factories
52+
53+
- name: Execute tests
54+
run: vendor/bin/phpunit --verbose

.styleci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ disabled:
44
- concat_without_spaces
55
- phpdoc_no_package
66
- logical_not_operators_with_successor_space
7+
- laravel_phpdoc_alignment

CHANGELOG.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,26 @@ All notable changes to `cybercog/laravel-ownership` will be documented in this f
44

55
## [Unreleased]
66

7+
## [5.4.0] - 2023-02-22
8+
9+
### Added
10+
11+
- ([#25]) Added Laravel 9 support
12+
13+
### Removed
14+
15+
- ([#26]) Dropped PHP 7.x support
16+
- ([#26]) Dropped Laravel 5.2 support
17+
- ([#26]) Dropped Laravel 5.3 support
18+
- ([#26]) Dropped Laravel 5.4 support
19+
- ([#26]) Dropped Laravel 5.5 support
20+
- ([#26]) Dropped Laravel 5.6 support
21+
- ([#26]) Dropped Laravel 5.7 support
22+
- ([#26]) Dropped Laravel 5.8 support
23+
- ([#26]) Dropped Laravel 6 support
24+
- ([#26]) Dropped Laravel 7 support
25+
- ([#26]) Dropped Laravel 8 support
26+
727
## [5.3.0] - 2020-12-31
828

929
### Added
@@ -103,7 +123,8 @@ All notable changes to `cybercog/laravel-ownership` will be documented in this f
103123

104124
- Initial release
105125

106-
[Unreleased]: https://github.com/cybercog/laravel-ownership/compare/5.2.0...master
126+
[Unreleased]: https://github.com/cybercog/laravel-ownership/compare/5.3.0...master
127+
[5.3.0]: https://github.com/cybercog/laravel-ownership/compare/5.2.0...5.3.0
107128
[5.2.0]: https://github.com/cybercog/laravel-ownership/compare/5.1.0...5.2.0
108129
[5.1.0]: https://github.com/cybercog/laravel-ownership/compare/5.0.0...5.1.0
109130
[5.0.0]: https://github.com/cybercog/laravel-ownership/compare/4.0.0...5.0.0
@@ -115,6 +136,7 @@ All notable changes to `cybercog/laravel-ownership` will be documented in this f
115136
[2.0.0]: https://github.com/cybercog/laravel-ownership/compare/1.0.0...2.0.0
116137
[Upgrade instructions]: UPGRADING.md
117138

139+
[#25]: https://github.com/cybercog/laravel-ownership/pull/25
118140
[#23]: https://github.com/cybercog/laravel-ownership/pull/23
119141
[#22]: https://github.com/cybercog/laravel-ownership/pull/22
120142
[#19]: https://github.com/cybercog/laravel-ownership/pull/19

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: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ Laravel Ownership simplify management of eloquent model's owner. Group can be an
5454

5555
First, pull in the package through Composer.
5656

57-
```shell script
58-
$ composer require cybercog/laravel-ownership
57+
```shell
58+
composer require cybercog/laravel-ownership
5959
```
6060

6161
And then include the service provider within `app/config/app.php`.
@@ -95,11 +95,11 @@ class User extends Authenticatable implements CanBeOwner
9595
Use `Ownable` contract in model which will get ownership behavior and implement it or just use `HasOwner` trait.
9696

9797
```php
98-
use Cog\Contracts\Ownership\Ownable as OwnableContract;
98+
use Cog\Contracts\Ownership\Ownable as OwnableInterface;
9999
use Cog\Laravel\Ownership\Traits\HasOwner;
100100
use Illuminate\Database\Eloquent\Model;
101101

102-
class Article extends Model implements OwnableContract
102+
class Article extends Model implements OwnableInterface
103103
{
104104
use HasOwner;
105105
}
@@ -122,11 +122,11 @@ By default owner model will be the same as `config('auth.providers.users.model')
122122
To override default owner model in strict ownership, it's primary key or foreign key extend your ownable model with additional attributes:
123123

124124
```php
125-
use Cog\Contracts\Ownership\Ownable as OwnableContract;
125+
use Cog\Contracts\Ownership\Ownable as OwnableInterface;
126126
use Cog\Laravel\Ownership\Traits\HasOwner;
127127
use Illuminate\Database\Eloquent\Model;
128128

129-
class Article extends Model implements OwnableContract
129+
class Article extends Model implements OwnableInterface
130130
{
131131
use HasOwner;
132132

@@ -141,11 +141,11 @@ class Article extends Model implements OwnableContract
141141
Use `Ownable` contract in model which will get polymorphic ownership behavior and implement it or just use `HasMorphOwner` trait.
142142

143143
```php
144-
use Cog\Contracts\Ownership\Ownable as OwnableContract;
144+
use Cog\Contracts\Ownership\Ownable as OwnableInterface;
145145
use Cog\Laravel\Ownership\Traits\HasMorphOwner;
146146
use Illuminate\Database\Eloquent\Model;
147147

148-
class Article extends Model implements OwnableContract
148+
class Article extends Model implements OwnableInterface
149149
{
150150
use HasMorphOwner;
151151
}
@@ -265,11 +265,11 @@ Article::whereNotOwnedBy($owner)->get();
265265
To set currently authenticated user as owner for ownable model create - extend it with attribute `withDefaultOwnerOnCreate`. It works for both strict and polymorphic ownership behavior.
266266

267267
```php
268-
use Cog\Contracts\Ownership\Ownable as OwnableContract;
268+
use Cog\Contracts\Ownership\Ownable as OwnableInterface;
269269
use Cog\Laravel\Ownership\Traits\HasOwner;
270270
use Illuminate\Database\Eloquent\Model;
271271

272-
class Article extends Model implements OwnableContract
272+
class Article extends Model implements OwnableInterface
273273
{
274274
use HasOwner;
275275

@@ -280,11 +280,11 @@ class Article extends Model implements OwnableContract
280280
To override strategy of getting default owner extend ownable model with `resolveDefaultOwner` method:
281281

282282
```php
283-
use Cog\Contracts\Ownership\Ownable as OwnableContract;
283+
use Cog\Contracts\Ownership\Ownable as OwnableInterface;
284284
use Cog\Laravel\Ownership\Traits\HasOwner;
285285
use Illuminate\Database\Eloquent\Model;
286286

287-
class Article extends Model implements OwnableContract
287+
class Article extends Model implements OwnableInterface
288288
{
289289
use HasOwner;
290290

@@ -293,7 +293,7 @@ class Article extends Model implements OwnableContract
293293
/**
294294
* Resolve entity default owner.
295295
*
296-
* @return null|\Cog\Contracts\Ownership\CanBeOwner
296+
* @return \Cog\Contracts\Ownership\CanBeOwner|null
297297
*/
298298
public function resolveDefaultOwner()
299299
{
@@ -318,8 +318,8 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
318318

319319
Run the tests with:
320320

321-
```shell script
322-
$ vendor/bin/phpunit
321+
```shell
322+
vendor/bin/phpunit
323323
```
324324

325325
## Security
@@ -328,8 +328,8 @@ If you discover any security related issues, please email open@cybercog.su inste
328328

329329
## Credits
330330

331-
| <a href="https://github.com/antonkomarev">![@antonkomarev](https://avatars.githubusercontent.com/u/1849174?s=110)<br />Anton Komarev</a> |
332-
| :---: |
331+
| <a href="https://github.com/antonkomarev">![@antonkomarev](https://avatars.githubusercontent.com/u/1849174?s=110)<br />Anton Komarev</a> | <a href="https://github.com/soap">![@soap](https://avatars.githubusercontent.com/u/1073690?s=110)<br />Prasit Gebsaap</a> |
332+
| :---: |:---------------------------------------------------------------------------------------------------------------------------------:|
333333

334334
[Laravel Ownership contributors list](../../contributors)
335335

0 commit comments

Comments
 (0)