Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 11 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: mbstring, xml

- name: Install dependencies
run: composer update --no-interaction

Expand All @@ -45,13 +51,15 @@ jobs:
fail-fast: false
max-parallel: 1 # Avoid rate-limit issue on Slack API
matrix:
php-version: [ '8.1', '8.2', '8.3', '8.4', '8.5' ]
php-version: [ '8.4', '8.5' ]
composer-flags: [ '' ]
name: [ '' ]
deprecations-helper: [ '' ]
include:
- php-version: 8.1
- php-version: 8.4
composer-flags: '--prefer-lowest'
name: '(prefer lowest dependencies)'
deprecations-helper: 'disabled'

steps:
- uses: actions/checkout@v2
Expand All @@ -70,4 +78,5 @@ jobs:
env:
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
SLACK_TEST_CHANNEL: ${{ secrets.SLACK_TEST_CHANNEL }}
SYMFONY_DEPRECATIONS_HELPER: ${{ matrix.deprecations-helper }}
CI: true
1 change: 1 addition & 0 deletions .jane-openapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
'clean-generated' => true,
'use-fixer' => true,
'fixer-config-file' => __DIR__ . '/.php-cs-fixer.php',
'default-fetch-mode' => 'preload',
];
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changes between versions

## 5.0.0 (2026-10-02)
* Upgrade JanePHP to 8.0.0
* Require PHP >= 8.4
* Generated models now expose public typed properties instead of getters: use `$user->name` instead of `$user->getName()`
* The HTTP layer is now built on Symfony HttpClient (`HttpClientInterface`) instead of PSR-7 / PSR-18 / HTTPlug
* `ClientFactory::create()` now expects a `Symfony\Contracts\HttpClient\HttpClientInterface` instead of a PSR-18 client
* GET and HEAD operations are now generated with the `preload` fetch mode (`default-fetch-mode` generation option)
* New `JoliCode\Slack\Http\SlackAuthentication` & `JoliCode\Slack\Http\SlackErrorHttpClient` decorator factories replacing the HTTPlug plugins

## 4.10.0 (2026-09-25)

* Upgrade JanePHP generated code
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ requests, and responses of the Slack Web API.

## Installation

This library is built atop of [PSR-7](https://www.php-fig.org/psr/psr-7/) and
[PSR-18](https://www.php-fig.org/psr/psr-18/). So you will need to install some
implementations for those standard interfaces.
This library is built on [Symfony HttpClient](https://symfony.com/doc/current/http_client.html)
(`HttpClientInterface`). Any HTTP client implementing that interface may be
provided to the `ClientFactory`.

If no PSR-18 client or PSR-7 message factory is available yet in your project
or you don't know or don't care which one to use, just install some default:
If no HTTP client is available yet in your project or you don't know or don't
care which one to use, just install the default one:

```bash
composer require symfony/http-client nyholm/psr7
composer require symfony/http-client
```

You can now install the Slack client:
Expand All @@ -48,7 +48,7 @@ composer require jolicode/slack-php-api
// $client contains all the methods to interact with the API
$client = JoliCode\Slack\ClientFactory::create($yourSlackToken);

$user = $client->usersInfo(['user' => 'U123AZER'])->getUser();
$user = $client->usersInfo(['user' => 'U123AZER'])->user;
```

## Documentation
Expand Down
23 changes: 6 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,19 @@
}
},
"require": {
"php": ">=8.4",
"ext-curl": "*",
"php": ">=8.1",
"jane-php/open-api-runtime": "^7.10",
"psr/http-client-implementation": "*",
"php-http/client-common": "^1.9 || ^2.0",
"php-http/discovery": "^1.11",
"php-http/multipart-stream-builder": "^1.1"
"jane-php/open-api-runtime": "^8.0",
"symfony/http-client": "^6.4 || ^7.0 || ^8.0"
},
"require-dev": {
"jane-php/open-api-2": "^7.10",
"symfony/http-client": "^6.0 || ^7.0 || ^8.0",
"nyholm/psr7": "^1.2",
"jane-php/open-api-2": "^8.0",
"symfony/http-client": "^6.4 || ^7.0 || ^8.0",
"friendsofphp/php-cs-fixer": "^3.2.2",
"symfony/phpunit-bridge": "^6.0 || ^7.0 || ^8.0",
"opis/json-schema": "^1.0",
"symfony/console": "^6.0 || ^7.0 || ^8.0",
"symfony/process": "^6.0 || ^7.0 || ^8.0"
},
"conflict": {
"php-http/httplug": "< 2.0"
},
"config": {
"allow-plugins": {
"php-http/discovery": true
}
}
"config": {}
}
14 changes: 7 additions & 7 deletions docs/1-get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

## Installation

This library is built atop of [PSR-7](https://www.php-fig.org/psr/psr-7/) and
[PSR-18](https://www.php-fig.org/psr/psr-18/). So you will need to install some
implementations for those standard interfaces.
This library is built on [Symfony HttpClient](https://symfony.com/doc/current/http_client.html)
(`HttpClientInterface`). Any HTTP client implementing that interface may be
provided to the `ClientFactory`.

If no PSR-18 client or PSR-7 message factory is available yet in your project
or you don't know or don't care which one to use, just install some default:
If no HTTP client is available yet in your project or you don't know or don't
care which one to use, just install the default one:

```bash
composer require symfony/http-client nyholm/psr7
composer require symfony/http-client
```

You can now install the Slack client:
Expand All @@ -32,7 +32,7 @@ A good starting point is the [Authentication Basics documentation](https://api.s
// $client contains all the methods to interact with the API
$client = JoliCode\Slack\ClientFactory::create($yourSlackToken);

$user = $client->usersInfo(['user' => 'U123AZER'])->getUser();
$user = $client->usersInfo(['user' => 'U123AZER'])->user;
```

***
Expand Down
25 changes: 20 additions & 5 deletions docs/2-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ PHPdoc to know which option you can provide to each method:
<?php
//...

$user = $client->usersInfo(['user' => 'U123AZER'])->getUser();
$user = $client->usersInfo(['user' => 'U123AZER'])->user;

dump($user);
```
Expand Down Expand Up @@ -51,7 +51,7 @@ $userNames = [];

/** @var JoliCode\Slack\Api\Model\ObjsUser $user */
foreach ($client->iterateUsersList() as $user) {
$userNames[] = $user->getName();
$userNames[] = $user->name;
}
```

Expand All @@ -69,14 +69,29 @@ do {
]);

/** @var JoliCode\Slack\Api\Model\ObjsUser $user */
foreach ($response->getUsers() as $user) {
$userNames[] = $user->getName();
foreach ($response->members ?? [] as $user) {
$userNames[] = $user->name;
}

$cursor = $response->getResponseMetadata() ? $response->getResponseMetadata()->getNextCursor() : '';
$cursor = $response->responseMetadata?->nextCursor ?? '';
} while (!empty($cursor));
```

## Fetch modes

Since JanePHP 8, GET and HEAD operations are generated with the `preload`
fetch mode (`default-fetch-mode` generation option). The HTTP request is
registered immediately when you call the method, and the response is parsed
the same blocking way as before.

On PHP >= 8.4, endpoints whose success response maps to a single generated
model even return a lazy ghost proxy: the parsed model appears on first
property read. Slack's specification always maps responses to two models
(a `...Response200` and a `...Responsedefault` fallback), so parsing stays
blocking in practice — but you can enable lazy proxies per operation by
tuning the responses in the patched specification, and set a different
fetch mode with the `x-fetch-mode` extension.

## Concrete examples

Here are some real-life examples of interacting with the SDK:
Expand Down
2 changes: 1 addition & 1 deletion docs/3-troubleshoots.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ $results = $client->searchMessages([
'query' => 'test'
]);

var_dump($results->getOk()); // ok property is mapped
var_dump($results->ok); // ok property is mapped
var_dump($results['messages']); // messages property is not mapped but still readable
```

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/retrieve-users.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
$users = iterator_to_array($client->iterateUsersList());

echo sprintf('Here is the names of the members of your workspace: %s', implode(', ', array_map(function(ObjsUser $user) {
return $user->getName();
return $user->name;
}, $users)));
} catch (SlackErrorResponse $e) {
echo 'Fail to retrieve the members.', PHP_EOL, $e->getMessage();
Expand Down
Binary file modified docs/images/model-sample.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading