1. Go to this page and download the library: Download nghia-kun/laravel-chat-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nghia-kun / laravel-chat-api example snippets
use Kun\LaravelChatApi\Facades\GoogleChat;
// Simple text message
GoogleChat::sendMessage('Hello from Laravel!');
// Card with title and body
GoogleChat::sendCard('Deploy finished', 'v2.5.0 was deployed to production successfully.');
// Alert / error notification
GoogleChat::sendAlert('Payment failed', 'Order #1234 could not be charged.', 'ERROR');
GoogleChat::sendAlert('Disk usage high', 'Server disk at 90%.', 'WARNING');
GoogleChat::sendAlert('Backup done', 'Nightly backup completed.', 'SUCCESS');
GoogleChat::to('https://chat.googleapis.com/v1/spaces/OTHER/messages?...')
->sendMessage('Message to a different space.');
use Kun\LaravelChatApi\GoogleChatService;
class OrderController extends Controller
{
public function __construct(protected GoogleChatService $chat) {}
public function store(Request $request)
{
// ... create order ...
$this->chat->sendMessage("New order #{$order->id} received!");
}
}