PHP code example of nexylan / slack-bundle

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

    

nexylan / slack-bundle example snippets




namespace AppBundle\Controller;

use Nexy\Slack\Attachment;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class DefaultController extends Controller
{
    public function indexAction()
    {
        $slack = $this->get('nexy_slack.client');

        $message = $slack->createMessage();

        $message
            ->to('#test')
            ->from('John Doe')
            ->withIcon(':ghost:')
            ->setText('This is an amazing message!')
        ;

        $message->attach((new Attachment())
             ->setFallback('Some fallback text')
             ->setText('The attachment text')
         );

        $slack->sendMessage($message);
    }
}
 bash
$ composer 
 php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Http\HttplugBundle\HttplugBundle(),
        new Nexy\SlackBundle\NexySlackBundle(),
    );

    // ...

    return $bundles
}