PHP code example of guywarner / laravel-google-chat-alerts

1. Go to this page and download the library: Download guywarner/laravel-google-chat-alerts 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/ */

    

guywarner / laravel-google-chat-alerts example snippets


use GuyWarner\GoogleChatAlerts\Facades\GoogleChatAlert;

GoogleChatAlert::message("You have a new subscriber to the {$newsletter->name} newsletter!");

return [
    /*
     * The webhook URLs that we'll use to send a message to Google Chat.
     */
    'webhook_urls' => [
        'default' => env('GOOGLE_CHAT_ALERT_WEBHOOK'),
    ],

    /*
     * This job will send the message to Google Chat. You can extend this
     * job to set timeouts, retries, etc...
     */
    'job' => GuyWarner\GoogleChatAlerts\Jobs\SendToGoogleChatChannelJob::class,
];


GoogleChatAlert::message("You have a new subscriber to the {$newsletter->name} newsletter!");

// in config/google-chat-alerts.php

'webhook_urls' => [
    'default' => 'https://chat.googleapis.com/v1/spaces/XXXX',
    'sales' => 'https://chat.googleapis.com/v1/spaces/YYYYYY',
],

use GuyWarner\GoogleChatAlerts\Facades\GoogleChatAlert;

GoogleChatAlert::to('sales')->message("You have a new subscriber to the {$newsletter->name} newsletter!");

use GuyWarner\GoogleChatAlerts\Facades\GoogleChatAlert;

GoogleChatAlert::message("A message *with some bold statements* and _some italicized text_.");

use GuyWarner\GoogleChatAlerts\Facades\GoogleChatAlert;

GoogleChatAlert::message("New support ticket. <users/all>");
bash
php artisan vendor:publish --tag="google-chat-alerts-config"