Lithe Import is a PHP library designed to facilitate the dynamic inclusion of PHP files and the management of external variables.
You can install Import using Composer. Run the following command in your terminal:
composer require lithemod/importTo include a single PHP file, use the file method:
use Lithe\Support\import;
$result = import::file('path/to/your/testfile.php');To include all PHP files from a specified directory (and its subdirectories), you can set the directory and call the get method:
use Lithe\Support\import;
$importer = import::dir('path/to/directory')->exceptions(['exclude.php']);
$importer->get();You can specify external variables that should be available in the included files:
use Lithe\Support\import;
$vars = ['var1' => 'value1'];
import::with($vars)->dir('path/to/directory')->get();To exclude specific files from being included, use the exceptions method:
$importer = import::dir('path/to/directory')->exceptions(['exclude.php']);
$importer->get();with(array $vars): Sets external variables to be available in the included files.dir(string $directory): Sets the directory for file inclusion.exceptions(array $exceptions): Specifies files to be excluded from inclusion.file(string $file): Includes a single PHP file and returns its result.get(): Includes all PHP files from the specified directory, excluding specified exceptions.
This project is licensed under the MIT License. See the LICENSE file for details.