1. Go to this page and download the library: Download teofanis/hook-press 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/ */
teofanis / hook-press example snippets
return [
// Namespaces to consider as your application roots
'roots' => [
'App\\',
],
// Optional: trait grouping
'traits' => [
'enabled' => true,
'namespaces' => ['App\\Traits\\'],
'group_key' => 'traits', // where the trait map will be stored
],
// Define your discovery “maps”
'maps' => [
'payout_methods' => [
'namespaces' => ['App\\Classes\\PayoutMethods\\'],
'conditions' => [
'isInstantiable',
'implementsInterface' => 'App\\Interfaces\\PayoutMethod',
],
],
],
// Exclusions (exact class, namespace prefix, or regex)
'exclusions' => [
'classes' => [],
'namespaces' => [],
'regex' => [],
],
// Where the computed map is stored
'store' => [
'driver' => 'file', // 'file' or 'cache'
'file' => ['path' => 'bootstrap/cache/hook-press.php'],
'cache' => ['store' => null, 'key' => 'hookpress:map', 'ttl' => null],
],
// Where HookPress reads the Composer classmap from (leave as default in apps)
'composer' => [
'classmap_path' => 'vendor/composer/autoload_classmap.php',
'artisan_command' => 'hook-press:build',
],
];
use HookPress\Facades\HookPress;
// Entire map (all keys)
$all = HookPress::map();
// Specific map
$methods = HookPress::map('payout_methods');
// Classes that use a trait
$searchables = HookPress::classesUsing(\App\Traits\Searchable::class);
// Rebuild on demand (usually done via Composer hook)
HookPress::refresh();
// Clear the stored map
HookPress::clear();