Skip to content

Release v3.0.0 #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: true
matrix:
os: [ ubuntu-latest ]
php: [ 8.2 ]
php: [ 8.4 ]
dependency-version: [ prefer-stable ]

name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: true
matrix:
os: [ ubuntu-latest ]
php: [ 8.2 ]
php: [ 8.4 ]
dependency-version: [ prefer-stable ]

name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: true
matrix:
os: [ ubuntu-latest ]
php: [ 8.0, 8.1, 8.2 ]
php: [ 8.3, 8.4 ]
dependency-version: [ prefer-lowest, prefer-stable ]

name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ This changelog is initialized in release 1.0.0

## [Unreleased]

## [v3.0.0] - 2025-02-26

### Added
* Laravel 12 support

### Changed
* Update minimum required PHP version to 8.3

### Removed
* Laravel 9 and 10 support

## [v2.1.0] - 2024-05-06

### Added
Expand Down
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM php:8.4-cli-alpine

RUN apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
&& apk add --no-cache \
shadow \
&& pecl install \
pcov \
&& docker-php-ext-enable \
pcov \
&& apk del -f .build-deps \
&& rm -rf /tmp/pear

ARG PUID=1000
ENV PUID=${PUID}
ARG PGID=1000
ENV PGID=${PGID}

RUN groupmod -o -g ${PGID} nobody && \
usermod -o -u ${PUID} -g nobody nobody && \
apk del shadow

RUN curl -s https://getcomposer.org/installer | \
php -- --install-dir=/usr/local/bin/ --filename=composer \
&& mkdir /.composer \
&& chown -R nobody:nobody /.composer

USER nobody

WORKDIR /var/www/html
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
app:
@docker compose run --rm app sh

setup:
@docker compose run --rm app composer install

phpstan:
@docker compose run --rm app php ./vendor/phpstan/phpstan/phpstan analyse --memory-limit 1G

phpunit:
@docker compose run --rm app php ./vendor/phpunit/phpunit/phpunit --no-coverage

coverage:
@docker compose run --rm app php ./vendor/phpunit/phpunit/phpunit
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
],
"homepage": "https://github.com/wimski/laravel-psr-http",
"require": {
"php": "^8.0",
"illuminate/support": "^9.0 || ^10.0 || ^11.0",
"php-http/discovery": "^1.11",
"php": "^8.3",
"illuminate/support": "^11.0 || ^12.0",
"php-http/discovery": "^1.20",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.1 || ^2.0"
},
"require-dev": {
"nunomaduro/larastan": "^2.0",
"nyholm/psr7": "^1.0",
"orchestra/testbench": "^7.0 || ^8.0",
"larastan/larastan": "^3.0",
"nyholm/psr7": "^1.8",
"orchestra/testbench": "^10.0",
"php-http/guzzle7-adapter": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^9.0"
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^11.0"
},
"minimum-stability": "stable",
"autoload": {
Expand Down
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
app:
build:
context: .
dockerfile: Dockerfile
volumes:
- .:/var/www/html
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
includes:
- vendor/nunomaduro/larastan/extension.neon
- vendor/larastan/larastan/extension.neon
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon

Expand Down
4 changes: 3 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
<directory>./tests</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
<coverage>
<report>
<clover outputFile="build/logs/clover.xml"/>
</report>
Expand Down
49 changes: 28 additions & 21 deletions src/Providers/PsrHttpServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,50 +30,57 @@ public function register(): void

protected function registerClient(): void
{
$this->app->singleton(ClientInterface::class, function (): ClientInterface {
return Psr18ClientDiscovery::find();
});
$this->app->singleton(
ClientInterface::class,
fn (): ClientInterface => Psr18ClientDiscovery::find(),
);
}

protected function registerUriFactory(): void
{
$this->app->singleton(UriFactoryInterface::class, function (): UriFactoryInterface {
return Psr17FactoryDiscovery::findUriFactory();
});
$this->app->singleton(
UriFactoryInterface::class,
fn (): UriFactoryInterface => Psr17FactoryDiscovery::findUriFactory(),
);
}

protected function registerStreamFactory(): void
{
$this->app->singleton(StreamFactoryInterface::class, function (): StreamFactoryInterface {
return Psr17FactoryDiscovery::findStreamFactory();
});
$this->app->singleton(
StreamFactoryInterface::class,
fn (): StreamFactoryInterface => Psr17FactoryDiscovery::findStreamFactory(),
);
}

protected function registerUploadedFileFactory(): void
{
$this->app->singleton(UploadedFileFactoryInterface::class, function (): UploadedFileFactoryInterface {
return Psr17FactoryDiscovery::findUploadedFileFactory();
});
$this->app->singleton(
UploadedFileFactoryInterface::class,
fn (): UploadedFileFactoryInterface => Psr17FactoryDiscovery::findUploadedFileFactory(),
);
}

protected function registerRequestFactory(): void
{
$this->app->singleton(RequestFactoryInterface::class, function (): RequestFactoryInterface {
return Psr17FactoryDiscovery::findRequestFactory();
});
$this->app->singleton(
RequestFactoryInterface::class,
fn (): RequestFactoryInterface => Psr17FactoryDiscovery::findRequestFactory(),
);
}

protected function registerServerRequestFactory(): void
{
$this->app->singleton(ServerRequestFactoryInterface::class, function (): ServerRequestFactoryInterface {
return Psr17FactoryDiscovery::findServerRequestFactory();
});
$this->app->singleton(
ServerRequestFactoryInterface::class,
fn (): ServerRequestFactoryInterface => Psr17FactoryDiscovery::findServerRequestFactory(),
);
}

protected function registerResponseFactory(): void
{
$this->app->singleton(ResponseFactoryInterface::class, function (): ResponseFactoryInterface {
return Psr17FactoryDiscovery::findResponseFactory();
});
$this->app->singleton(
ResponseFactoryInterface::class,
fn (): ResponseFactoryInterface => Psr17FactoryDiscovery::findResponseFactory(),
);
}
}
5 changes: 2 additions & 3 deletions tests/PsrHttpServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Wimski\LaravelPsrHttp\Tests;

use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\Test;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\ResponseFactoryInterface;
Expand All @@ -23,9 +24,7 @@ protected function getPackageProviders($app): array
];
}

/**
* @test
*/
#[Test]
public function it_registers_http_psr_services(): void
{
$client = $this->app?->make(ClientInterface::class);
Expand Down
Loading