A small and simple class to automatically include whole the directories and subdirectories files in php using retalive or absolutes paths.
This should be used to bootstrap a group of the application dependencies that should be loaded everytime in a script.
Just a great way for avoiding to use the include or require serveral times when trying to load a big number of files inside a directory.
include 'myDirectory/someFile.php';
include 'myDirectory/otherFile.php';
include 'myDirectory/anotherFile.php';
include 'myDirectory/yetAnotherFile.php';
You can use the include-all library with and without composer.
If not using composer the library brigns an autoload file wich should be encountered inside the directory it is located.
The include-all autoload file
should be required such as the vendor/autoload.php
is... Before trying to use the library.
use Sammy\Packs\IncludeAll;
require_once 'path/to/include-all/autoload';
$includeAll = new IncludeAll;
# Using the dot slash (./) at the beggining
# of the path is assuming that myDirectory is
# located in the same directory[ or path] the
# php script is.
$includeAll->includeAll('./myDirectory');
use Sammy\Packs\IncludeAll;
# Assuming that the vendor directory is
# located in the same where the current
# script is.
require_once __DIR__ . '/vendor/autoload';
$includeAll = new IncludeAll;
# Using the dot slash (./) at the beggining
# of the path is assuming that myDirectory is
# located in the same directory[ or path] the
# php script is.
$includeAll->includeAll('./myDirectory');
It is possible to get the source code from github following the url shown bellow: php-module/include-all
composer require php_modules/core php_modules/include-all
Adding it as a requirement inside the composer.json
file:
{
"require": {
"php_modules/include-all": "^1.0.5"
}
}
$includeAll = require ('path/to/include-all/index.php');
$includeAll->includeAll ('./path/to/directory');
require ('path/to/include-all/index.php');
use Sammy\Packs\IncludeAll;
$includeAll = new IncludeAll ();
$includeAll->includeAll ('./path/to/directory');