lithemod/import

There is no license information available for the latest version (v1.0.0) of this package.

Support for facilitating the dynamic inclusion of PHP files and the management of external variables.

v1.0.0 2024-10-02 15:36 UTC

This package is auto-updated.

Last update: 2024-11-02 15:54:30 UTC


README

Lithe Import is a PHP library designed to facilitate the dynamic inclusion of PHP files and the management of external variables.

Installation

You can install Import using Composer. Run the following command in your terminal:

composer require lithemod/import

Usage

Including a Single File

To include a single PHP file, use the file method:

use Lithe\Support\import;

$result = import::file('path/to/your/testfile.php');

Including All Files from a Directory

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();

Using External Variables

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();

Excluding Files

To exclude specific files from being included, use the exceptions method:

$importer = import::dir('path/to/directory')->exceptions(['exclude.php']);
$importer->get();

Methods Overview

  • 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.

License

This project is licensed under the MIT License. See the LICENSE file for details.