Skip to content

Commit 4288ea7

Browse files
authored
Merge pull request #4 from melihovv/laravel-7-support
Laravel 7 support
2 parents 58e1dab + ad0c6cb commit 4288ea7

File tree

14 files changed

+108
-118
lines changed

14 files changed

+108
-118
lines changed

.coveralls.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/workflows/default.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Run tests
2+
3+
on:
4+
push:
5+
schedule:
6+
- cron: '0 0 * * *'
7+
8+
jobs:
9+
php-tests:
10+
runs-on: ${{ matrix.os }}
11+
12+
strategy:
13+
matrix:
14+
php: [7.4, 7.3, 7.2]
15+
laravel: [7.*, 6.*]
16+
dependency-version: [prefer-lowest, prefer-stable]
17+
os: [ubuntu-latest, windows-latest]
18+
include:
19+
- laravel: 7.*
20+
testbench: 5.*
21+
- laravel: 6.*
22+
testbench: 4.*
23+
24+
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
25+
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v1
29+
30+
- name: Setup PHP
31+
uses: shivammathur/setup-php@v1
32+
with:
33+
php-version: ${{ matrix.php }}
34+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
35+
coverage: none
36+
37+
- name: Install dependencies
38+
run: |
39+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
40+
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
41+
42+
- name: Execute tests
43+
run: composer run phpunit

.styleci.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1 @@
1-
preset: recommended
2-
enabled:
3-
- concat_with_spaces
4-
disabled:
5-
- align_double_arrow
6-
- phpdoc_to_comment
7-
- phpdoc_var_without_name
8-
- concat_without_spaces
9-
- no_multiline_whitespace_around_double_arrow
1+
preset: laravel

.travis.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
Laravel Env Validator
22
=====================
33

4-
[![Build Status](https://travis-ci.org/melihovv/laravel-env-validator.svg?branch=master)](https://travis-ci.org/melihovv/laravel-env-validator)
4+
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/melihovv/laravel-env-validator/run-php-tests?label=Tests)
55
[![styleci](https://styleci.io/repos/78041678/shield)](https://styleci.io/repos/78041678)
6-
[![Coverage Status](https://coveralls.io/repos/github/melihovv/laravel-env-validator/badge.svg?branch=master)](https://coveralls.io/github/melihovv/laravel-env-validator?branch=master)
76

87
[![Packagist](https://img.shields.io/packagist/v/melihovv/laravel-env-validator.svg)](https://packagist.org/packages/melihovv/laravel-env-validator)
98
[![Packagist](https://poser.pugx.org/melihovv/laravel-env-validator/d/total.svg)](https://packagist.org/packages/melihovv/laravel-env-validator)
109
[![Packagist](https://img.shields.io/packagist/l/melihovv/laravel-env-validator.svg)](https://packagist.org/packages/melihovv/laravel-env-validator)
1110

1211
Laravel Env Validator is meant to validate your .env file in order to avoid any
13-
unexpected behaviour for not having properly defined some variable or value.
12+
unexpected behaviour for not having properly defined some variable or value.
1413

1514
### Highlights
1615

@@ -33,13 +32,13 @@ php artisan vendor:publish --provider="Melihovv\LaravelEnvValidator\ServiceProvi
3332

3433
## Example configuration file
3534
```php
36-
// config/laravel-env-validator.php
35+
// config/env-validator.php
3736
<?php
3837

3938
return [
4039
'rules' => [
41-
'SOME_IMPORTANT_VARIABLE' => 'required',
42-
'ANOTHER_IMPORTANT_ONE' => 'required|in:TYPE_A,TYPE_B,TYPE_C',
40+
'APP_NAME' => 'required|string',
41+
'APP_ENV' => 'in:local,production',
4342
],
4443
];
4544
```

composer.json

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,29 @@
1515
"email": "[email protected]"
1616
}
1717
],
18+
"require": {
19+
"php": ">=7.2",
20+
"illuminate/config": "^6.0|^7.0",
21+
"illuminate/console": "^6.0|^7.0",
22+
"illuminate/support": "^6.0|^7.0",
23+
"illuminate/validation": "^6.0|^7.0"
24+
},
25+
"require-dev": {
26+
"orchestra/testbench": "^4.0|^5.0",
27+
"phpunit/phpunit": "^8.4|^9.0"
28+
},
1829
"autoload": {
1930
"psr-4": {
20-
"Melihovv\\LaravelEnvValidator\\": "src/LaravelEnvValidator"
31+
"Melihovv\\LaravelEnvValidator\\": "src"
2132
}
2233
},
2334
"autoload-dev": {
2435
"psr-4": {
2536
"Melihovv\\LaravelEnvValidator\\Tests\\": "tests/"
2637
}
2738
},
28-
"require": {
29-
"php": ">=7.2",
30-
"illuminate/support": "^6.0",
31-
"illuminate/validation": "^6.0"
32-
},
33-
"require-dev": {
34-
"orchestra/testbench": "^4.0",
35-
"phpunit/phpunit": "^8.0"
36-
},
3739
"scripts": {
38-
"phpunit": "phpunit --dont-report-useless-tests"
40+
"phpunit": "phpunit"
3941
},
4042
"extra": {
4143
"laravel": {

src/config/laravel-env-validator.php renamed to config/env-validator.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
return [
44
'rules' => [
5+
'APP_NAME' => 'required|string',
56
'APP_ENV' => 'in:local,production',
6-
'APP_KEY' => 'required',
7+
'APP_KEY' => 'required|string',
78
'APP_DEBUG' => 'boolean',
9+
'APP_URL' => 'required|url',
810

911
'DB_CONNECTION' => 'required',
1012
'DB_HOST' => 'required',
@@ -22,10 +24,10 @@
2224
'MAIL_FROM_NAME' => 'required',
2325

2426
'BROADCAST_DRIVER' => 'nullable|in:pusher,redis,log,null',
25-
'CACHE_DRIVER' => 'in:apc,array,database,file,memcached,redis',
26-
'SESSION_DRIVER' => 'in:file,cookie,database,apc,memcached,redis,array',
27-
'QUEUE_DRIVER' => 'in:sync,database,beanstalkd,sqs,redis,null',
28-
'MAIL_DRIVER' => 'in:smtp,sendmail,mailgun,mandrill,ses,' .
29-
'sparkpost,log,array',
27+
'CACHE_DRIVER' => 'in:apc,array,database,file,memcached,redis,dynamodb',
28+
'SESSION_DRIVER' => 'in:file,cookie,database,apc,memcached,redis,dynamodb,array',
29+
'QUEUE_CONNECTION' => 'in:sync,database,beanstalkd,sqs,redis,null',
30+
'LOG_CHANNEL' => 'in:single,daily,slack,syslog,errorlog,custom,stack,null,stderr,stdout',
31+
'MAIL_DRIVER' => 'in:smtp,sendmail,mailgun,ses,postmark,log,array',
3032
],
3133
];

src/EnvValidationFailed.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Melihovv\LaravelEnvValidator;
4+
5+
use Exception;
6+
7+
class EnvValidationFailed extends Exception
8+
{
9+
public static function fromMessages(array $messages): self
10+
{
11+
$message = sprintf(
12+
'The .env file has some problems. Please check config/env-validator.php%s%s',
13+
PHP_EOL,
14+
implode(PHP_EOL, $messages)
15+
);
16+
17+
return new self($message);
18+
}
19+
}

src/LaravelEnvValidator/EnvValidator.php renamed to src/EnvValidator.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,9 @@ public function __construct(Validator $validator)
1919
public function validate()
2020
{
2121
if ($this->validator->fails()) {
22-
$messages = array_values(
23-
$this->validator->messages()->all()
24-
);
22+
$messages = array_values($this->validator->messages()->all());
2523

26-
$message = 'The .env file has some problems.'
27-
. ' Please check config/laravel-env-validator.php'
28-
. PHP_EOL
29-
. implode(PHP_EOL, $messages);
30-
31-
throw new Exception($message);
24+
throw EnvValidationFailed::fromMessages($messages);
3225
}
3326
}
3427
}

src/LaravelEnvValidator/Console/EnvValidatorCommand.php renamed to src/EnvValidatorCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<?php
22

3-
namespace Melihovv\LaravelEnvValidator\Console;
3+
namespace Melihovv\LaravelEnvValidator;
44

55
use Illuminate\Console\Command;
6-
use Melihovv\LaravelEnvValidator\EnvValidatorFactory;
76

87
class EnvValidatorCommand extends Command
98
{

0 commit comments

Comments
 (0)