PHP code example of brain / striatum

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

    

brain / striatum example snippets

 php
Brain\Hooks::addAction( 'myplugin.init', 'init', [ new MyPlugin, 'init' ] );
 php
// action
Brain\Hooks::trigger( 'foo_action', $optional_1, $optional_2, $and_so_on );

 // filter
$filtered = Brain\Hooks::filter( 'bar_filter', $unfiltered, $optional_1 );
 php
Brain\Hooks::addAction( 'plugin.init', 'init', [ new MyPlugin, 'init' ] );
 php
$hooks = new Brain\Hooks;
$hooks->addAction( 'plugin.init', 'init', [ new MyPlugin, 'init' ] );
 php
class A_Plugin_Class {
    
  function __construct( \Brain\Hooks $hooks ) {
    $this->hooks = $hooks;
  }
      
  function get_a_filtered_value( $a_value ) {
    return $this->hooks->filter( 'a_filter', $a_value, $this );
  }
      
}