https://github.com/php-module/include-all
A small and simple class to automatically include whole the directories and subdirectories files in php.
https://github.com/php-module/include-all
Last synced: over 1 year ago
JSON representation
A small and simple class to automatically include whole the directories and subdirectories files in php.
- Host: GitHub
- URL: https://github.com/php-module/include-all
- Owner: php-module
- License: mit
- Created: 2021-04-27T13:45:16.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-09-22T18:38:43.000Z (almost 4 years ago)
- Last Synced: 2025-02-20T16:49:55.528Z (over 1 year ago)
- Language: PHP
- Size: 26.4 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# IncludeAll
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.
## THE OLD WAY FOR INCLUDING FILES
```php
include 'myDirectory/someFile.php';
include 'myDirectory/otherFile.php';
include 'myDirectory/anotherFile.php';
include 'myDirectory/yetAnotherFile.php';
```
## THE NEW WAY USING 'INCLUDE-ALL'
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.
### Without using composer autoload
```php
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');
```
### Using composer autoload
```php
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');
```
## HOW TO INSTALL
It is possible to get the source code from github following the url shown bellow:
[php-module/include-all](https://github.com/php-module/include-all)
### If using composer:
```bash
composer require php_modules/core php_modules/include-all
```
Adding it as a requirement inside the `composer.json` file:
```json
{
"require": {
"php_modules/include-all": "^1.0.5"
}
}
```
## Simple using example:
```php
$includeAll = require ('path/to/include-all/index.php');
$includeAll->includeAll ('./path/to/directory');
```
### Using the constructor directly
```php
require ('path/to/include-all/index.php');
use Sammy\Packs\IncludeAll;
$includeAll = new IncludeAll ();
$includeAll->includeAll ('./path/to/directory');
```