Skip to content

Commit

Permalink
🚀 Added support for Laravel 9
Browse files Browse the repository at this point in the history
  • Loading branch information
allysonsilva committed Apr 13, 2022
1 parent a2bf825 commit 30b2b56
Show file tree
Hide file tree
Showing 19 changed files with 60 additions and 81 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0']
laravel: ['^8.0']
php: ['8.0', '8.1']
laravel: ['^9.0']
stability: [prefer-lowest, prefer-stable]

name: "CI - PHP: ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.stability }}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
php: ['8.1', '8.0']
phpstan: [^1.0]
symplify-rules: ['10.1.2']
nunomaduro-larastan: [^1.0]
nunomaduro-larastan: [^2.0]
ergebnis-phpstan-rules: [^1.0]

name: "PHPStan | PHP: ${{ matrix.php }}"
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

All notable changes to `laravel-multienv` will be documented in this file.

## [Unreleased](https://github.com/allysonsilva/laravel-multienv/compare/v1.0.0...1.x)
## [Unreleased](https://github.com/allysonsilva/laravel-multienv/compare/v2.0.0...2.x)

## [v2.0.0 (2022-04-13)](https://github.com/allysonsilva/laravel-multienv/compare/1.x...v2.0.0)

### Changed

- **Added support for Laravel v9.x**

## [v1.0.0 (2022-04-10)](https://github.com/allysonsilva/laravel-multienv/releases/tag/v1.0.0)

Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@

The package has been developed and tested to work with the following minimum requirements:

- *PHP 7.4*
- *Laravel 8.0*
- *PHP 8.0*
- *Laravel 9.0*

### Laravel version Compatibility

| Laravel | PHP | Package |
|:-------:|:---:|:------------:|
| 9.x | 8.0 | **^2.0** |
| 8.x | 7.4 | **^1.0** |

### Install the Package

Expand Down Expand Up @@ -289,7 +296,7 @@ If you discover any security related issues, please email [email protected] ins
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

[ico-php]: https://img.shields.io/packagist/php-v/allysonsilva/laravel-multienv?color=%234F5B93&logo=php
[ico-laravel]: https://img.shields.io/static/v1?label=laravel&message=%E2%89%A58.0&color=ff2d20&logo=laravel
[ico-laravel]: https://img.shields.io/static/v1?label=laravel&message=%E2%89%A59.0&color=ff2d20&logo=laravel
[ico-actions]: https://github.com/allysonsilva/laravel-multienv/actions/workflows/ci.yml/badge.svg
[ico-codecov]: https://codecov.io/gh/allysonsilva/laravel-multienv/branch/main/graph/badge.svg?token=H546OKODQB
[ico-version]: https://img.shields.io/packagist/v/allysonsilva/laravel-multienv.svg?label=stable
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
],
"homepage": "https://github.com/allysonsilva/laravel-multienv",
"require": {
"php": ">=7.4",
"laravel/framework": "^8.0"
"php": ">=8.0",
"laravel/framework": "^9.0"
},
"require-dev": {
"orchestra/testbench": "^6.22",
"orchestra/testbench": "^7.0",
"phpunit/phpunit": "^9.5"
},
"minimum-stability": "dev",
Expand Down
10 changes: 0 additions & 10 deletions tests/Concerns/SetUpBefore.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ public static function applicationBasePath()
return realpath(__DIR__ . '/../LaravelApp');
}

/**
* Get base path.
*
* @return string
*/
protected function getBasePath()
{
return static::applicationBasePath();
}

/**
* Resolve application setUp.
*
Expand Down
2 changes: 1 addition & 1 deletion tests/LaravelApp/app/Http/HttpKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class HttpKernel extends LaravelHttpKernel
* @var array
*/
protected $middleware = [
// \Illuminate\Http\Middleware\TrustProxies::class,
\Illuminate\Http\Middleware\TrustProxies::class,
// \Illuminate\Http\Middleware\HandleCors::class,
\Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
Expand Down
48 changes: 5 additions & 43 deletions tests/LaravelApp/config/app.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Illuminate\Support\Facades\Facade;

return [

/*
Expand Down Expand Up @@ -188,48 +190,8 @@
|
*/

'aliases' => [

'App' => Illuminate\Support\Facades\App::class,
'Arr' => Illuminate\Support\Arr::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class,
'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
'Bus' => Illuminate\Support\Facades\Bus::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'Date' => Illuminate\Support\Facades\Date::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Http' => Illuminate\Support\Facades\Http::class,
'Js' => Illuminate\Support\Js::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Notification' => Illuminate\Support\Facades\Notification::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'RateLimiter' => Illuminate\Support\Facades\RateLimiter::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
// 'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'Str' => Illuminate\Support\Str::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,

],
'aliases' => Facade::defaultAliases()->merge([
// ...
])->toArray(),

];
3 changes: 3 additions & 0 deletions tests/LaravelApp/config/broadcasting.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
'cluster' => env('PUSHER_APP_CLUSTER'),
'useTLS' => true,
],
'client_options' => [
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
],
],

'ably' => [
Expand Down
2 changes: 1 addition & 1 deletion tests/LaravelApp/config/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,6 @@
|
*/

'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'),
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'),

];
6 changes: 3 additions & 3 deletions tests/LaravelApp/config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
'schema' => 'public',
'search_path' => 'public',
'sslmode' => 'prefer',
],

Expand Down Expand Up @@ -136,15 +136,15 @@
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
],

'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_CACHE_DB', '1'),
],
Expand Down
2 changes: 1 addition & 1 deletion tests/LaravelApp/config/filesystems.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
|
*/

'default' => env('FILESYSTEM_DRIVER', 'local'),
'default' => env('FILESYSTEM_DISK', 'local'),

/*
|--------------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion tests/LaravelApp/config/logging.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@
'papertrail' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => SyslogUdpHandler::class,
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
'port' => env('PAPERTRAIL_PORT'),
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
],
],

Expand Down
1 change: 0 additions & 1 deletion tests/LaravelApp/config/mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'auth_mode' => null,
],

'ses' => [
Expand Down
6 changes: 3 additions & 3 deletions tests/LaravelApp/config/session.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
|
*/

'connection' => env('SESSION_CONNECTION', null),
'connection' => env('SESSION_CONNECTION'),

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -100,7 +100,7 @@
|
*/

'store' => env('SESSION_STORE', null),
'store' => env('SESSION_STORE'),

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -155,7 +155,7 @@
|
*/

'domain' => env('SESSION_DOMAIN', null),
'domain' => env('SESSION_DOMAIN'),

/*
|--------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion tests/Orchestra/Commander.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static function applicationBasePath()
public function laravel()
{
if (! $this->app) {
$this->app = Application::create($this->getBasePath(), null, [
$this->app = Application::create(basePath: $this->getBasePath(), options: [
'extra' => [
'providers' => $this->config['providers'] ?? [],
'dont-discover' => $this->config['dont-discover'] ?? [],
Expand Down
4 changes: 3 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ protected function setUp(): void
if (! is_file("{$this->getBasePath()}/config/envs.php")) {
$this->copyEnvsToRoot('.env.non-existent-domain');

$this->artisan('vendor:publish', ['--tag' => 'envs-config', '--force' => true, ])->run();
$this->artisan('vendor:publish', ['--tag' => 'envs-config', '--force' => true, ])
->assertSuccessful()
->run();

$this->app->make(LaravelLoadConfiguration::class)->bootstrap($this->app);
}
Expand Down
10 changes: 10 additions & 0 deletions tests/Unit/ArtisanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function using_APP_ROUTES_CACHE_key_to_cache_domain_routes(): void
$this->updateEnvsConfigFile();

$this->artisan('route:cache', ['--domain' => 'site1.test'])
->assertSuccessful()
->expectsOutput(Mockery::pattern('/^Route cache cleared/'))
->expectsOutput(Mockery::pattern('/^Routes cached successfully/'));

Expand All @@ -40,9 +41,11 @@ public function using_APP_ROUTES_CACHE_key_to_cache_domain_routes(): void
self::assertSame($this->app->getCachedRoutesPath(), $cachedRoutesFilename);

$this->get('http://site1.test')
->assertSuccessful()
->assertSeeText('site1.test/');

$this->get('http://site1.test/other')
->assertSuccessful()
->assertSeeText('site1.test/other');

$this->get('http://site2.test')
Expand Down Expand Up @@ -71,6 +74,7 @@ public function using_APP_ROUTES_CACHE_key_to_cache_domain_routes(): void
public function cache_all_routes_when_domain_does_not_exist(): void
{
$this->artisan('route:cache')
->assertSuccessful()
->expectsOutput(Mockery::pattern('/^Route cache cleared/'))
->expectsOutput(Mockery::pattern('/^Routes cached successfully/'));

Expand All @@ -87,12 +91,15 @@ public function cache_all_routes_when_domain_does_not_exist(): void
self::assertSame($this->app->getCachedRoutesPath(), $cachedRoutesFilename);

$this->get('http://site1.test')
->assertSuccessful()
->assertSeeText('site1.test/');

$this->get('http://site2.test/')
->assertSuccessful()
->assertSeeText('site2.test/');

$this->get('http://other-domain.test/')
->assertSuccessful()
->assertSeeText('other-domain.test/');
}

Expand All @@ -119,6 +126,7 @@ public function using_APP_CONFIG_CACHE_key_to_cache_domain_configs(): void
// $consoleOutput = $this->runArtisan('config:cache', '--domain=site-XYZ.test')->getOutput();

$this->artisan('config:cache', ['--domain' => 'site2.test'])
->assertSuccessful()
->expectsOutput(Mockery::pattern('/^Configuration cache cleared/'))
->expectsOutput(Mockery::pattern('/^Configuration cached successfully/'))
->run();
Expand All @@ -138,6 +146,7 @@ public function using_APP_CONFIG_CACHE_key_to_cache_domain_configs(): void
Env::getRepository()->clear('APP_CONFIG_CACHE');

$this->artisan('config:cache', ['--domain' => 'site1.test'])
->assertSuccessful()
->expectsOutput(Mockery::pattern('/^Configuration cache cleared/'))
->expectsOutput(Mockery::pattern('/^Configuration cached successfully/'))
->run();
Expand All @@ -162,6 +171,7 @@ public function using_APP_CONFIG_CACHE_key_to_cache_domain_configs(): void
public function cache_all_configs_when_domain_does_not_exist(): void
{
$this->artisan('config:cache')
->assertSuccessful()
->expectsOutput(Mockery::pattern('/^Configuration cache cleared/'))
->expectsOutput(Mockery::pattern('/^Configuration cached successfully/'));

Expand Down
9 changes: 4 additions & 5 deletions tests/Unit/HttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ protected function setUp(): void
{
parent::setUp();

Route::domain('site2.test')->group(function () {
Route::get('domain-route', function () {
return response()->json(config('domain'));
})->middleware(['api']);
});
Route::domain('site2.test')
->get('domain-route', fn () => response()->json(config('domain')))
->middleware(['api']);
}

/**
Expand All @@ -43,6 +41,7 @@ public function custom_domain_env_filename(): void
// $this->refreshConfiguration();

$this->getJson('http://site2.test/domain-route')
->assertSuccessful()
->assertJson($this->getFixture('env.site2')['domain']);
}
}

0 comments on commit 30b2b56

Please sign in to comment.