Recursively includes all .php files in the given directory.
Listeners can be started automatically by passing $listen as true.
param string: Directory to include. param boolean: Start listeners. param string: Path to ignore when starting listeners. rtype: void .. note:
Listener class names are generated compliant to PSR-4 with the directory serving as the top-level namespace.
xp_dir_include('Foo');
With the directory structure.
- Foo/
- Bar.php
Will include the file Foo/Bar.php
xp_include_dir('Foo', true);
With the directory structure.
- Foo/
- Bar.php
- Bar/
- Hello_World.php
Will include the files Foo/Bar.php, Foo/Bar/Hello_World.php and attempt to start classes Foo\Bar, Foo\Bar\Hello_World.
Note
Listeners must extend the XPSPL\Listener class.
<?php
namespace Foo\Bar;
Class Hello_World extends \XPSPL\Listener {
// Do something on the 'foo' signal
public function on_foo(\XPSPL\SIG $signal) {
echo 'foobar';
}
}
When the XP_SIG('foo') signal is emitted the Hello_World->on_foo method will be executed.