Skip to content

Commit 3c473a5

Browse files
Add support for Laravel 9 and PHP 8.1 (#30)
* Add support for Laravel 9 & PHP 8.1 * Apply fixes from StyleCI Co-authored-by: StyleCI Bot <bot@styleci.io>
1 parent e4ad0e9 commit 3c473a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2423
-2357
lines changed

.github/workflows/main.yml

Lines changed: 73 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,36 @@ name: Build
22

33
on:
44
push:
5-
branches:
6-
- master
7-
- release/*
8-
- issue-*
5+
paths-ignore: ['*.md']
96
pull_request:
10-
branches:
11-
- master
12-
schedule:
13-
- cron: 0 7 * * 1
7+
paths-ignore: ['*.md']
8+
branches: [ master ]
149

1510
jobs:
1611
analysis:
1712
runs-on: ubuntu-latest
1813
strategy:
1914
matrix:
20-
php: [7.4]
15+
php: [8.0]
2116
steps:
2217
- uses: actions/checkout@v1
23-
- name: Cache composer dependencies
24-
uses: actions/cache@v2
25-
env:
26-
cache-name: cache-i18n-laravel-latest
27-
with:
28-
path: ~/.composer
29-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.json') }}
30-
restore-keys: |
31-
${{ runner.os }}-build-${{ env.cache-name }}-
32-
${{ runner.os }}-build-
33-
${{ runner.os }}-
3418
- name: Setup PHP
3519
uses: shivammathur/setup-php@v2
3620
with:
3721
php-version: ${{ matrix.php }}
3822
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
3923
coverage: none
24+
- name: Cache composer dependencies
25+
uses: actions/cache@v2
26+
env:
27+
cache-name: laravel-i18n-analysis
28+
with:
29+
path: ~/.composer
30+
key: php-${{ matrix.php }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.json') }}
31+
restore-keys: |
32+
php-${{ matrix.php }}-build-${{ env.cache-name }}-
33+
php-${{ matrix.php }}-build-
34+
php-${{ matrix.php }}-
4035
- name: Install composer dependencies
4136
run: composer install --prefer-dist
4237
- name: Run phpstan analysis
@@ -50,7 +45,7 @@ jobs:
5045
runs-on: ubuntu-latest
5146
strategy:
5247
matrix:
53-
php: [8.0]
48+
php: [7.4, 8.0, 8.1]
5449
steps:
5550
- uses: actions/checkout@v1
5651
- name: Setup PHP
@@ -59,37 +54,87 @@ jobs:
5954
php-version: ${{ matrix.php }}
6055
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
6156
coverage: none
57+
- name: Cache composer dependencies
58+
uses: actions/cache@v2
59+
env:
60+
cache-name: laravel-i18n-laravel8
61+
with:
62+
path: ~/.composer
63+
key: php-${{ matrix.php }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.json') }}
64+
restore-keys: |
65+
php-${{ matrix.php }}-build-${{ env.cache-name }}-
66+
php-${{ matrix.php }}-build-
67+
php-${{ matrix.php }}-
68+
- name: Force update laravel version
69+
run: composer require "laravel/framework:^8.0" "orchestra/testbench:^6.0" --no-update
6270
- name: Remove some dev dependencies
6371
run: composer remove "ekino/phpstan-banned-code" "nunomaduro/larastan" "phpmd/phpmd" "phpstan/phpstan-deprecation-rules" "sebastian/phpcpd" --dev --no-update
6472
- name: Install composer dependencies
6573
run: composer install --prefer-dist
6674
- name: Run the test suite
6775
run: phpdbg -qrr -dmemory_limit=3G vendor/bin/phpunit
68-
laravel8-cov:
76+
laravel9:
6977
needs: [ analysis ]
7078
runs-on: ubuntu-latest
7179
strategy:
7280
matrix:
73-
php: [ 7.4 ]
81+
php: [ 8.1 ]
7482
steps:
7583
- uses: actions/checkout@v1
84+
- name: Setup PHP
85+
uses: shivammathur/setup-php@v2
86+
with:
87+
php-version: ${{ matrix.php }}
88+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
89+
coverage: none
7690
- name: Cache composer dependencies
7791
uses: actions/cache@v2
7892
env:
79-
cache-name: cache-i18n-laravel-latest
93+
cache-name: laravel-i18n-laravel9
8094
with:
8195
path: ~/.composer
82-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.json') }}
96+
key: php-${{ matrix.php }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.json') }}
8397
restore-keys: |
84-
${{ runner.os }}-build-${{ env.cache-name }}-
85-
${{ runner.os }}-build-
86-
${{ runner.os }}-
98+
php-${{ matrix.php }}-build-${{ env.cache-name }}-
99+
php-${{ matrix.php }}-build-
100+
php-${{ matrix.php }}-
101+
- name: Force update laravel version
102+
run: composer require "laravel/framework:^9.0" "orchestra/testbench:^7.0" --no-update
103+
- name: Remove some dev dependencies
104+
run: composer remove "ekino/phpstan-banned-code" "nunomaduro/larastan" "phpmd/phpmd" "phpstan/phpstan-deprecation-rules" "sebastian/phpcpd" --dev --no-update
105+
- name: Install composer dependencies
106+
run: composer install --prefer-dist
107+
- name: Run the test suite
108+
run: phpdbg -qrr -dmemory_limit=3G vendor/bin/phpunit
109+
laravel9-cov:
110+
needs: [ analysis ]
111+
runs-on: ubuntu-latest
112+
strategy:
113+
matrix:
114+
php: [ 8.0 ]
115+
steps:
116+
- uses: actions/checkout@v1
87117
- name: Setup PHP
88118
uses: shivammathur/setup-php@v2
89119
with:
90120
php-version: ${{ matrix.php }}
91121
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
92122
coverage: none
123+
- name: Cache composer dependencies
124+
uses: actions/cache@v2
125+
env:
126+
cache-name: laravel-i18n-laravel9
127+
with:
128+
path: ~/.composer
129+
key: php-${{ matrix.php }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.json') }}
130+
restore-keys: |
131+
php-${{ matrix.php }}-build-${{ env.cache-name }}-
132+
php-${{ matrix.php }}-build-
133+
php-${{ matrix.php }}-
134+
- name: Force update laravel version
135+
run: composer require "laravel/framework:^9.0" "orchestra/testbench:^7.0" --no-update
136+
- name: Remove some dev dependencies
137+
run: composer remove "ekino/phpstan-banned-code" "nunomaduro/larastan" "phpmd/phpmd" "phpstan/phpstan-deprecation-rules" "sebastian/phpcpd" --dev --no-update
93138
- name: Install composer dependencies
94139
run: composer install --prefer-dist
95140
- name: Run the Coverage test suite

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Vagrantfile
3232

3333
composer.phar
3434
composer.lock
35+
/coverage
3536
/vendor
3637

3738

composer.json

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,20 @@
2828
},
2929
"require": {
3030
"php": "^7.4|^8.0",
31-
"illuminate/database": "^8.0",
32-
"illuminate/support": "^8.0",
31+
"illuminate/database": "^8.0|^9.0",
32+
"illuminate/support": "^8.0|^9.0",
3333
"nesbot/carbon": "^2.16"
3434
},
3535
"require-dev": {
36-
"ekino/phpstan-banned-code": "^0.4",
37-
"fakerphp/faker": "^1.14",
38-
"mockery/mockery": "^1.4",
39-
"nunomaduro/larastan": "^0.7",
40-
"orchestra/database": "^6.0",
41-
"orchestra/testbench": "^6.0",
42-
"phpmd/phpmd": "^2.10",
43-
"phpstan/phpstan-deprecation-rules": "^0.12",
36+
"ekino/phpstan-banned-code": "^1.0",
37+
"fakerphp/faker": "^1.19",
38+
"mockery/mockery": "^1.5",
39+
"nunomaduro/larastan": "^1.0|^2.0",
40+
"orchestra/database": "^6.0|dev-master",
41+
"orchestra/testbench": "^6.0|^7.0",
42+
"phpmd/phpmd": "^2.11",
43+
"phpstan/phpstan-deprecation-rules": "^1.0",
44+
"phpstan/phpstan-strict-rules": "^1.0",
4445
"phpunit/phpunit": "^9.5",
4546
"sebastian/phpcpd": "^6.0"
4647
},
@@ -64,7 +65,7 @@
6465
"RichanFongdasen\\I18n\\ServiceProvider"
6566
],
6667
"aliases": {
67-
"I18n": "RichanFongdasen\\I18n\\Facade"
68+
"I18n": "RichanFongdasen\\I18n\\Facade\\I18n"
6869
}
6970
}
7071
},

config/i18n.php

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
*/
2727

2828
'language_datasource' => storage_path('i18n/languages.json'),
29+
// 'language_datasource' => 'languages',
2930

3031
/*
3132
|--------------------------------------------------------------------------
@@ -36,22 +37,35 @@
3637
|
3738
*/
3839

39-
'cache_duration' => 86400,
40+
'cache_duration' => 60 * 60 * 24,
4041

4142
/*
4243
|--------------------------------------------------------------------------
4344
| Language key
4445
|--------------------------------------------------------------------------
4546
|
4647
| Define which language key in datasource that we should use.
47-
| Available options:
48+
| Available options are:
4849
| - language, ie: en, es, de, etc.
4950
| - ietfCode, ie: en-US, en-UK, de-DE, etc.
5051
|
5152
*/
5253

5354
'language_key' => 'language',
5455

56+
/*
57+
|--------------------------------------------------------------------------
58+
| API query key
59+
|--------------------------------------------------------------------------
60+
|
61+
| Define the query parameter name which will be used as language selector
62+
| in every API request.
63+
| e.g: http://localhost:8000/api/articles?lang=en
64+
|
65+
*/
66+
67+
'api_query_key' => 'lang',
68+
5569
/*
5670
|--------------------------------------------------------------------------
5771
| Language negotiator class
@@ -71,23 +85,12 @@
7185
|
7286
| Define which url segment number that will be used to put the current
7387
| locale information. URL segment is started with '1'.
88+
| e.g: http://my-application.app/en/home
7489
|
7590
*/
7691

7792
'locale_url_segment' => 1,
7893

79-
/*
80-
|--------------------------------------------------------------------------
81-
| Fallback language
82-
|--------------------------------------------------------------------------
83-
|
84-
| Define your preferred fallback language, which will be used when
85-
| Language Negotiator failed to recommend any supported language.
86-
|
87-
*/
88-
89-
'fallback_language' => 'en',
90-
9194
/*
9295
|--------------------------------------------------------------------------
9396
| Translation table suffix
@@ -97,6 +100,7 @@
97100
| translation table name.
98101
|
99102
*/
103+
100104
'translation_table_suffix' => 'translations',
101105

102106
/*
@@ -107,5 +111,7 @@
107111
| Toggle store locale to the cache
108112
|
109113
*/
114+
110115
'enable_cache' => env('I18N_ENABLE_CACHE', true),
116+
111117
];

database/migrations/0000_00_00_000000_create_languages_table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class CreateLanguagesTable extends Migration
1313
public function up()
1414
{
1515
Schema::create('languages', function (Blueprint $table) {
16-
$table->increments('id');
16+
$table->increments('id')->unsigned();
1717
$table->string('name');
1818
$table->string('language', 2);
1919
$table->string('country', 2);

phpstan.neon

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
includes:
22
- vendor/nunomaduro/larastan/extension.neon
3+
- vendor/phpstan/phpstan-strict-rules/rules.neon
34
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
45
- vendor/ekino/phpstan-banned-code/extension.neon
56

67
parameters:
7-
level: max
8+
level: 8
89
checkMissingIterableValueType: false
10+
checkGenericClassInNonGenericObjectType: false
911
paths:
1012
- src
1113
ignoreErrors:

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</coverage>
88
<testsuites>
99
<testsuite name="Laravel I18n Test Suite">
10-
<directory suffix="Tests.php">./tests/</directory>
10+
<directory suffix="Test.php">./tests/</directory>
1111
</testsuite>
1212
</testsuites>
1313
</phpunit>

0 commit comments

Comments
 (0)