PHP code example of nicklambourne / slackblocks

1. Go to this page and download the library: Download nicklambourne/slackblocks 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/ */

    

nicklambourne / slackblocks example snippets




declare(strict_types=1);

 = new S\MessagePayload(
    channel: 'C0123456789',
    text: 'Build #482 passed',
    blocks: [
        new S\HeaderBlock('Build #482 passed'),
        new S\SectionBlock(fields: ["*Branch*\n`main`", "*Tests*\n1,247 passed"]),
        new S\ActionsBlock(elements: [
            new S\ButtonElement(text: 'View build', actionId: 'view', url: 'https://ci.example.com/482'),
        ]),
    ],
);
echo $message->toJson();