1. Go to this page and download the library: Download piggly/php-hooks 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/ */
piggly / php-hooks example snippets
// Register in tag calculate
$tag = 'calculate';
// Register in tag calculate ready to recieve two args
$tag = 'calculate?2';
// Register in tag calculate with priority 1
$tag = 'calculate::1';
// Register in tag calculate ready to recieve two args and priority 1
$tag = 'calculate?2::1';
// Register in tag calculate with name sum
$tag = 'calculate.sum';
// Register in tag calculate with name sum ready to recieve two args
$tag = 'calculate.pow?2';
// Register in tag calculate with name sum and priority 1
$tag = 'calculate.sum::1';
// Register in tag calculate with name sum, ready to recieve two args and priority 1
$tag = 'calculate.pow?2::1';
function line () { echo "I am line 02\n"; }
function message ( $message ) { echo sprintf("Message: %s\n", $message); }
Hook::action('sentences.line', 'line');
Hook::action('sentences.message', 'message');
Hook::run('sentences', 'Peace and Love');
class Controller
{
// ...
public function home()
{
Hook::action('head', $this, 'homeAction');
// ...
}
public function services()
{
Hook::action('head', $this, 'servicesAction');
// ...
}
public function about()
{
Hook::action('head', $this, 'aboutAction');
// ...
}
public function homeAction ()
{ /** Add css file... **/ }
public function servicesAction ()
{ /** Add css file... **/ }
public function aboutAction ()
{ /** Add css file... **/ }
// ...
}
class Controller
{
// ...
public function home()
{
Hook::dispatch('head', 'importCss', 'home.css');
// ...
}
public function services()
{
Hook::dispatch('head', 'importCss', 'services.css');
// ...
}
public function about()
{
Hook::dispatch('head', 'importCss', 'about.css');
// ...
}
// ...
}
function name ( $message ) { echo sprintf("Your name: %s\n", $message); }
function prog ( $message ) { echo sprintf("Progamming Language: %s\n", $message); }
Hook::dispatch('sentences.name::1', 'name', 'Alpha');
Hook::dispatch('sentences.prog::1', 'prog', 'JS');
Hook::run('sentences', 'Peace and Love');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.