Skip to content

Commit

Permalink
Merge 0561cdd into 745912a
Browse files Browse the repository at this point in the history
  • Loading branch information
wimski committed May 9, 2023
2 parents 745912a + 0561cdd commit f259b8f
Show file tree
Hide file tree
Showing 14 changed files with 390 additions and 151 deletions.
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

# Ignore all test and documentation with "export-ignore".
/.coveralls.yml export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
50 changes: 50 additions & 0 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Code Coverage

on:
push:
branches:
- 'master'
pull_request:
branches:
- '*'

jobs:
coverage:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ ubuntu-latest ]
php: [ 8.2 ]
dependency-version: [ prefer-stable ]

name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: pcov

- name: Install dependencies
run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction

- name: Execute tests with coverage
run: composer coverage

- name: Upload coverage results to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
composer global require php-coveralls/php-coveralls
php-coveralls
42 changes: 42 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: PHPStan

on:
push:
branches:
- 'master'
pull_request:
branches:
- '*'

jobs:
static-analysis:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ ubuntu-latest ]
php: [ 8.2 ]
dependency-version: [ prefer-stable ]

name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}

- name: Install dependencies
run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction

- name: Execute static code analysis
run: composer analyze
42 changes: 42 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: PHPUnit

on:
push:
branches:
- 'master'
pull_request:
branches:
- '*'

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ ubuntu-latest ]
php: [ 8.0, 8.1, 8.2 ]
dependency-version: [ prefer-lowest, prefer-stable ]

name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}

- name: Install dependencies
run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction

- name: Execute tests
run: composer test
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
.phpunit.result.cache
build
composer.lock
vendor/
phpstan.neon
phpunit.xml
vendor
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

This changelog is initialized in release 1.0.0

## [Unreleased]

## [v2.0.0] - 2023-xx-xx

### Changed
* Complete refactor using [discovery](https://github.com/php-http/discovery)

## [v1.1.0] - 2022-02-23

### Added
* Laravel 9 support

## [v1.0.2] - 2021-05-28

### Changed
* Update minimum stability

## [v1.0.1] - 2021-05-28

### Changed
* Update config publish tag

[Unreleased]: https://github.com/wimski/laravel-psr-http/compare/v2.0.0...master
[v2.0.0]: https://github.com/wimski/laravel-psr-http/compare/v1.1.0...v2.0.0
[v1.1.0]: https://github.com/wimski/laravel-psr-http/compare/v1.0.2...v1.1.0
[v1.0.2]: https://github.com/wimski/laravel-psr-http/compare/v1.0.1...v1.0.2
[v1.0.1]: https://github.com/wimski/laravel-psr-http/compare/v1.0.0...v1.0.1
32 changes: 9 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
# Laravel PSR HTTP
[![Latest Stable Version](http://poser.pugx.org/wimski/laravel-psr-http/v)](https://packagist.org/packages/wimski/laravel-psr-http)
[![Coverage Status](https://coveralls.io/repos/github/wimski/laravel-psr-http/badge.svg?branch=master)](https://coveralls.io/github/wimski/laravel-psr-http?branch=master)
[![PHPUnit](https://github.com/wimski/laravel-psr-http/actions/workflows/phpunit.yml/badge.svg)](https://github.com/wimski/laravel-psr-http/actions/workflows/phpunit.yml)
[![PHPStan](https://github.com/wimski/laravel-psr-http/actions/workflows/phpstan.yml/badge.svg)](https://github.com/wimski/laravel-psr-http/actions/workflows/phpstan.yml)

[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Latest Version on Packagist](https://img.shields.io/packagist/v/wimski/laravel-psr-http.svg?style=flat-square)](https://packagist.org/packages/wimski/laravel-psr-http)
[![Total Downloads](https://img.shields.io/packagist/dt/wimski/laravel-psr-http.svg?style=flat-square)](https://packagist.org/packages/wimski/laravel-psr-http)
# Laravel PSR HTTP

This package provides Laravel bindings to make PSR HTTP requests using the [Symfony HTTP Client](https://symfony.com/doc/current/http_client.html) for the PSR-18 client
and [Nyholm's PSR-7](https://github.com/Nyholm/psr7) package for the PSR-17 factories.
This package provides Laravel bindings to make PSR HTTP requests using [discovery](https://github.com/php-http/discovery).

## Install

```bash
composer require wimski/laravel-psr-http
```

Optionally publish the config file to adjust the default options for the [Symfony HTTP Client](https://github.com/symfony/contracts/blob/main/HttpClient/HttpClientInterface.php).
```bash
php artisan vendor:publish --tag=symfony-http-client
```

## Usage example

```php
Expand All @@ -36,22 +31,13 @@ use Psr\Http\Message\StreamFactoryInterface;
class TestCommand extends Command
{
protected $signature = 'http:test';

protected $description = 'Test the HTTP client';

protected ClientInterface $httpClient;
protected RequestFactoryInterface $requestFactory;
protected StreamFactoryInterface $streamFactory;

public function __construct(
ClientInterface $httpClient,
RequestFactoryInterface $requestFactory,
StreamFactoryInterface $streamFactory
protected ClientInterface $httpClient,
protected RequestFactoryInterface $requestFactory,
protected StreamFactoryInterface $streamFactory,
) {
$this->httpClient = $httpClient;
$this->requestFactory = $requestFactory;
$this->streamFactory = $streamFactory;

parent::__construct();
}

Expand Down
47 changes: 34 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,64 @@
{
"name": "wimski/laravel-psr-http",
"type": "library",
"description": "PSR HTTP setup for Laravel",
"license": "MIT",
"type": "library",
"keywords": [
"wimski",
"laravel",
"psr",
"http"
],
"homepage": "https://github.com/wimski/laravel-psr-http",
"license": "MIT",
"authors": [
{
"name": "Wimski",
"email": "thatonedudewimski@gmail.com",
"name": "Wim Reckman",
"role": "Developer"
}
],
"homepage": "https://github.com/wimski/laravel-psr-http",
"require": {
"php": "^7.4 || ^8.0",
"laravel/framework": "^8.0 || ^9.0",
"nyholm/psr7": "^1.4",
"php": "^8.0",
"illuminate/support": "^9.0 || ^10.0",
"php-http/discovery": "^1.11",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",
"symfony/http-client": "^5.2 || ^6.0"
"psr/http-message": "^1.1 || ^2.0"
},
"config": {
"sort-packages": true
"require-dev": {
"nunomaduro/larastan": "^2.0",
"nyholm/psr7": "^1.0",
"orchestra/testbench": "^7.0 || ^8.0",
"php-http/guzzle7-adapter": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^9.0"
},
"minimum-stability": "stable",
"autoload": {
"psr-4": {
"Wimski\\LaravelPsrHttp\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Wimski\\LaravelPsrHttp\\Tests\\": "tests/"
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"php-http/discovery": false
}
},
"extra": {
"laravel": {
"providers": [
"Wimski\\LaravelPsrHttp\\Providers\\LaravelPsrHttpServiceProvider"
"Wimski\\LaravelPsrHttp\\Providers\\PsrHttpServiceProvider"
]
}
},
"minimum-stability": "stable"
"scripts": {
"analyze": "@php vendor/phpstan/phpstan/phpstan analyse --memory-limit 1G",
"coverage": "@php vendor/phpunit/phpunit/phpunit",
"test": "@php vendor/phpunit/phpunit/phpunit --no-coverage"
}
}
40 changes: 0 additions & 40 deletions config/symfony-http-client.php

This file was deleted.

10 changes: 10 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
includes:
- vendor/nunomaduro/larastan/extension.neon
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon

parameters:
level: max
paths:
- src
- tests

0 comments on commit f259b8f

Please sign in to comment.