Skip to content
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

feat: add full feature parity #71

Merged
merged 1 commit into from
Jan 25, 2022
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
9 changes: 9 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ARG VARIANT=8-bullseye
FROM mcr.microsoft.com/vscode/devcontainers/php:0-${VARIANT}

RUN pecl install ast && \
echo "extension=ast.so" >> "$PHP_INI_DIR/php.ini-development" && \
mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"

ENV PHAN_ALLOW_XDEBUG 0
ENV PHAN_DISABLE_XDEBUG_WARN 1
45 changes: 45 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.195.0/containers/php
{
"name": "PHP",
"build": {
"dockerfile": "Dockerfile",
"args": {
// Update VARIANT to pick a PHP version: 8, 8.0, 7, 7.4, 7.3
// Append -bullseye or -buster to pin to an OS version.
// Use -bullseye variants on local on arm64/Apple Silicon.
"VARIANT": "8-bullseye"
}
},
"settings": {
"php.validate.executablePath": "/usr/local/bin/php",
"php-cs-fixer.onsave": true,
"php-cs-fixer.config": ".php-cs-fixer.dist.php",
},
"extensions": [
"pkief.material-icon-theme",
"eamodio.gitlens",
"visualstudioexptteam.vscodeintellicode",
"github.copilot",
"felixfbecker.php-debug",
"bmewburn.vscode-intelephense-client",
"junstyle.php-cs-fixer"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [8080],
// Use 'portsAttributes' to set default properties for specific forwarded ports. More info: https://code.visualstudio.com/docs/remote/devcontainerjson-reference.
"portsAttributes": {
"8000": {
"label": "Stream PHP SDK",
"onAutoForward": "notify"
}
},
// Use 'otherPortsAttributes' to configure any ports that aren't configured using 'portsAttributes'.
// "otherPortsAttributes": {
// "onAutoForward": "silent"
// },
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "sudo chmod a+x \"$(pwd)\" && sudo rm -rf /var/www/html && sudo ln -s \"$(pwd)\" /var/www/html"
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
19 changes: 12 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ name: build

on: [pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

jobs:
build:
name: 🧪 Test & lint
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
php-versions: ['7.3', '7.4', '8.0']
php-versions: ['7.3', '7.4', '8.0', '8.1']
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -23,22 +27,23 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl
extensions: ast, mbstring, intl
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ast gives a performance boost to phan

ini-values: post_max_size=256M, max_execution_time=180
tools: composer:v2

- name: Deps
run: composer install --no-interaction

- name: Format
run: vendor/bin/php-cs-fixer fix --config=.php_cs-fixer.dist.php -v --dry-run --stop-on-violation
if: ${{ matrix.php-versions == '7.3' }}
run: vendor/bin/php-cs-fixer fix -v --dry-run --stop-on-violation

- name: Quality
if: matrix.php-versions == '7.4'
run: vendor/bin/phan --force-polyfill-parser || true
Copy link
Contributor Author

@peterdeme peterdeme Jan 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

force-polyfill-parser isn't needed anymore because of ast is added above

if: ${{ matrix.php-versions == '7.3' }}
run: vendor/bin/phan --no-progress-bar

- name: Test
env:
STREAM_API_KEY: ${{ secrets.STREAM_API_KEY }}
STREAM_API_SECRET: ${{ secrets.STREAM_API_SECRET }}
STREAM_KEY: ${{ secrets.STREAM_API_KEY }}
STREAM_SECRET: ${{ secrets.STREAM_API_SECRET }}
run: vendor/bin/phpunit
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ composer.lock
.phplint-cache
.phpunit.result.cache
.envrc
.php_cs.cache
.php*cache
.idea
.vscode
36 changes: 35 additions & 1 deletion .phan/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,39 @@
// TODO: Set this.
'target_php_version' => null,

'plugins' => [
'AlwaysReturnPlugin',
'DuplicateArrayKeyPlugin',
'PrintfCheckerPlugin',
'UnreachableCodePlugin',
'UseReturnValuePlugin',
'EmptyStatementListPlugin',
'LoopVariableReusePlugin',
'RedundantAssignmentPlugin',
'UnknownClassElementAccessPlugin',
'MoreSpecificElementTypePlugin',
'UnsafeCodePlugin',
'WhitespacePlugin',
'PHPDocInWrongCommentPlugin',
'NoAssertPlugin',
'NumericalComparisonPlugin',
'StrictLiteralComparisonPlugin',
'DeprecateAliasPlugin',
'ShortArrayPlugin',
'AvoidableGetterPlugin',
'RemoveDebugStatementPlugin',
'HasPHPDocPlugin',
],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these plugins are amazing. i was able to catch and fix a few issues with it.


'suppress_issue_types' => [
'PhanPluginDescriptionlessCommentOnPublicMethod',
'PhanPluginDescriptionlessCommentOnProtectedProperty',
'PhanPluginDescriptionlessCommentOnPublicProperty',
'PhanPluginDescriptionlessCommentOnPrivateMethod',
'PhanPluginDescriptionlessCommentOnPrivateProperty',
'PhanPluginDescriptionlessCommentOnProtectedMethod',
],

// A list of directories that should be parsed for class and
// method information. After excluding the directories
// defined in exclude_analysis_directory_list, the remaining
Expand Down Expand Up @@ -49,6 +82,7 @@
// should be added to both the `directory_list`
// and `exclude_analysis_directory_list` arrays.
'exclude_analysis_directory_list' => [
'vendor/'
'vendor/',
'tests/',
],
];
File renamed without changes.
29 changes: 29 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# ♻️ Contributing

We welcome code changes that improve this library or fix a problem, please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on Github. We are very happy to merge your code in the official repository. Make sure to sign our [Contributor License Agreement (CLA)](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) first. See our license file for more details.

## Getting started

### Restore dependencies

Installing dependencies into `./vendor` folder:

```bash
$ composer install
```

### Run tests

The tests we have are full fledged integration tests, meaning they will actually reach out to a Stream app. Hence the tests require at least two environment variables: `STREAM_KEY` and `STREAM_SECRET`.

```bash
$ export STREAM_KEY="<your-key>"
$ export STREAM_SECRET="<your-secret>"
$ vendor/bin/phpunit
```

> 💡 Note: On Unix systems you could use [direnv](https://direnv.net/) to set up these variables.

## IDE specific setup

If you use VS Code, you can pull up a Dockerized development environment with [Remote-Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension. The proper configuration is already included in [.devcontainer](./.devcontainer/) folder. Once you're inside the container, just run the `composer install` command and you're good to go.
25 changes: 15 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ require_once "./vendor/autoload.php";
Instantiate a new client, find your API keys in the dashboard.

```php
$client = new GetStream\StreamChat\Client(getenv("STREAM_API_KEY"), getenv("STREAM_API_SECRET"));
$client = new GetStream\StreamChat\Client(getenv("STREAM_KEY"), getenv("STREAM_SECRET"));
```

Generate a token for clientside use
Expand All @@ -64,14 +64,6 @@ $expiration = (new DateTime())->getTimestamp() + 3600;
$token = $client->createToken("bob-1", $expiration);
```

Set location. Tell the client where your app is [hosted](https://getstream.io/chat/docs/multi_region/?language=php&q=locations).

```php

$client->setLocation("singapore");

```

## Update / Create users

```php
Expand Down Expand Up @@ -220,10 +212,18 @@ $client->deleteDevice($device_id, 'june');

### Copyright and License Information

[BSD-3](https://github.com/GetStream/stream-chat-php/blob/master/LICENSE).
[BSD-3](./LICENSE).

## Contributing

Installing dependencies into `./vendor` folder:

```bash
$ composer install
```

For more tips head over to [CONTRIBUTING.md](./CONTRIBUTING.md).

### Commit message convention

Since we're autogenerating our [CHANGELOG](./CHANGELOG.md), we need to follow a specific commit message convention.
Expand All @@ -240,3 +240,8 @@ The job creates a pull request with the changelog. Check if it looks good.
- Merge the pull request.

Once the PR is merged, it automatically kicks off another job which will create the tag and created a GitHub release.

## We are hiring!
We've recently closed a $38 million Series B funding round and we keep actively growing. Our APIs are used by more than a billion end-users, and you'll have a chance to make a huge impact on the product within a team of the strongest engineers all over the world.

Check out our current openings and apply via Stream's website.
24 changes: 16 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"name": "get-stream/stream-chat",
"description": "A PHP client for Stream Chat (https://getstream.io/chat/)",
"keywords": ["stream", "chat", "api", "chat-sdk"],
"keywords": [
"stream",
"chat",
"api",
"chat-sdk"
],
"homepage": "https://getstream.io/chat/",
"license": "BSD-3-Clause",
"authors": [
Expand All @@ -10,24 +15,27 @@
"email": "support@getstream.io"
}
],
"support": {
"issues": "https://github.com/GetStream/stream-chat-php/issues",
"docs": "https://getstream.io/chat/docs/php/?language=php"
},
"require": {
"php": ">=7.3",
"guzzlehttp/guzzle": "^6.3.3 || ^7.0.1",
"firebase/php-jwt": "^v5.0.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.18.0",
"friendsofphp/php-cs-fixer": "^3.0.0",
"phan/phan": "^5.2.1",
"phpunit/phpunit": "^9.5.10",
"ramsey/uuid": "^4.2.3"
"phpunit/phpunit": "^9.5.11"
},
"autoload": {
"psr-0": {
"GetStream\\StreamChat" : "lib/"
"GetStream\\StreamChat": "lib/"
},
"psr-4": {
"GetStream\\Unit\\" : "tests/unit/",
"GetStream\\Integration\\" : "tests/integration/"
"GetStream\\Unit\\": "tests/unit/",
"GetStream\\Integration\\": "tests/integration/"
}
}
}
}
Loading