|
| 1 | +# Migrating from stream-chat-php to getstream-php |
| 2 | + |
| 3 | +## Why Migrate? |
| 4 | + |
| 5 | +Stream has released **[getstream-php](https://github.com/GetStream/getstream-php)**, a new full-product PHP SDK that covers Chat, Video, Moderation, and Feeds in a single package. It is generated from OpenAPI specs, which means it stays up to date with the latest API features automatically. |
| 6 | + |
| 7 | +**getstream-php** is the long-term-supported SDK going forward. **stream-chat-php** will enter maintenance mode and continue receiving critical bug fixes, but new features and API coverage will only be added to getstream-php. |
| 8 | + |
| 9 | +If you are starting a new project, use **getstream-php**. If you have an existing project using stream-chat-php, we encourage you to migrate at your convenience. There is no rush, as stream-chat-php is not going away, but migrating gives you access to the latest features and the best developer experience. |
| 10 | + |
| 11 | +## Key Differences |
| 12 | + |
| 13 | +| | **stream-chat-php** | **getstream-php** | |
| 14 | +|---|---|---| |
| 15 | +| **Package** | `get-stream/stream-chat` | `getstream/getstream-php` | |
| 16 | +| **Namespace** | `GetStream\StreamChat\Client` | `GetStream\Client` / `GetStream\ChatClient` | |
| 17 | +| **Client init** | `new Client($apiKey, $apiSecret)` | `ClientBuilder::fromEnv()->build()` or `new Client(apiKey: ..., apiSecret: ...)` | |
| 18 | +| **API style** | Associative arrays for everything | Typed model classes with named arguments | |
| 19 | +| **Channel operations** | `$client->Channel($type, $id)->method()` | `$client->methodName($type, $id, ...)` | |
| 20 | +| **Custom fields** | Top-level array keys | `custom: (object) [...]` property | |
| 21 | +| **Filters / Sort** | Associative arrays | `(object)` casts and `SortParamRequest` objects | |
| 22 | +| **Response types** | Associative arrays | Typed response objects | |
| 23 | +| **Autoloading** | PSR-0 | PSR-4 | |
| 24 | +| **Product coverage** | Chat only | Chat, Video, Moderation, Feeds | |
| 25 | + |
| 26 | +## Quick Before/After Example |
| 27 | + |
| 28 | +The most common operation (initialize client and send a message): |
| 29 | + |
| 30 | +**Before (stream-chat-php):** |
| 31 | + |
| 32 | +```php |
| 33 | +use GetStream\StreamChat\Client; |
| 34 | + |
| 35 | +$client = new Client("<api-key>", "<api-secret>"); |
| 36 | + |
| 37 | +$channel = $client->Channel('messaging', 'general'); |
| 38 | +$response = $channel->sendMessage( |
| 39 | + ['text' => 'Hello, world!'], |
| 40 | + 'user-1', |
| 41 | +); |
| 42 | +``` |
| 43 | + |
| 44 | +**After (getstream-php):** |
| 45 | + |
| 46 | +```php |
| 47 | +use GetStream\ClientBuilder; |
| 48 | +use GetStream\GeneratedModels; |
| 49 | + |
| 50 | +$client = ClientBuilder::fromEnv()->build(); |
| 51 | + |
| 52 | +$response = $client->sendMessage( |
| 53 | + 'messaging', |
| 54 | + 'general', |
| 55 | + new GeneratedModels\SendMessageRequest( |
| 56 | + message: new GeneratedModels\MessageRequest( |
| 57 | + text: 'Hello, world!', |
| 58 | + userID: 'user-1', |
| 59 | + ), |
| 60 | + ), |
| 61 | +); |
| 62 | +``` |
| 63 | + |
| 64 | +## Migration Guides by Topic |
| 65 | + |
| 66 | +| # | Topic | Guide | |
| 67 | +|---|-------|-------| |
| 68 | +| 1 | Setup and Authentication | [01-setup-and-auth.md](./01-setup-and-auth.md) | |
| 69 | +| 2 | Users | [02-users.md](./02-users.md) | |
| 70 | +| 3 | Channels | [03-channels.md](./03-channels.md) | |
| 71 | +| 4 | Messages and Reactions | [04-messages-and-reactions.md](./04-messages-and-reactions.md) | |
| 72 | +| 5 | Moderation | [05-moderation.md](./05-moderation.md) | |
| 73 | +| 6 | Devices | [06-devices.md](./06-devices.md) | |
| 74 | + |
| 75 | +Each guide provides side-by-side "Before" and "After" code examples for every operation, along with notes on key differences. |
| 76 | + |
| 77 | +## Continued Support for stream-chat-php |
| 78 | + |
| 79 | +stream-chat-php is not being removed or abandoned. It will continue to receive: |
| 80 | + |
| 81 | +- Critical bug fixes |
| 82 | +- Security patches |
| 83 | +- Requested features on a case-by-case basis |
| 84 | + |
| 85 | +However, all new API features, generated model types, and multi-product support will only be available in getstream-php. We recommend migrating when it makes sense for your project timeline. |
| 86 | + |
| 87 | +## Resources |
| 88 | + |
| 89 | +- [getstream-php on GitHub](https://github.com/GetStream/getstream-php) |
| 90 | +- [getstream-php on Packagist](https://packagist.org/packages/getstream/getstream-php) |
| 91 | +- [Stream Chat documentation](https://getstream.io/chat/docs/) |
0 commit comments