Download the PHP package nazonohito51/require-path-fixer without Composer
On this page you can find all versions of the php package nazonohito51/require-path-fixer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nazonohito51/require-path-fixer
More information about nazonohito51/require-path-fixer
Files in nazonohito51/require-path-fixer
Package require-path-fixer
Short Description Fix require/include path
License MIT
Informations about the package require-path-fixer
RequirePathFixer
Legacy php project have a large number of require statements(require/require_once/include/include_once). And since they are not homogeneous, it is difficult to collect them all. This library searches all require statements and modifies them to be homogeneous code.
Installation
Usage
Advanced usage
Define constants and variables
The following statement will be not replaced, because it is unknown what path COMMON_DIR is.
require_once COMMON_DIR . '/path/to/file.php';
If there is a constant or variable to be replaced, it is passed to the following method.
Restrict modification target
If you have files or directories you don't want to modify, use addBlackList()
.
Or if you want to modify only some files in the repository, use addWhiteList()
. addBlackList()
and addWhiteList()
can be used at the same time.
Define current directory
In PHP, the following statement (starting with '.' or '..') determines the path from the current directory.
require_once './path/to/file.php';
Details are written in the PHP Manual.
If you want to define the current directory, use setWorkingDir()
.
When the current directory is defined, this library resolves the above statement from the current directory.
However, originally the current directory changes depending on the entry point, and it also dynamically changes using chdir()
.
Please be careful when using it.
Define include_path
In PHP, the following statement (relative path) determines the path from the include_path.
require_once 'path/to/file.php';
If you want to define the include_path, use setIncludePath()
.
When include_path is defined, this library resolves the above statement from include_path.
However, originally include_path changes dynamically with set_include_path()
.
Please also be careful when using it.
About analysis logic
This library classifies all statements into seven types and converts them.
Their types are absolute
, variable
, relative
, unique
, working_dir
, include_path
and unexpected
.
absolute
If the path is an absolute path, fix it to the path from the new base path.
variable
If the path can not be resolved, such as unknown variable or constant, do not convert.
relative
In the path is an relative path, basically it is determined only at runtime, so it can not be replaced.
But this library somehow tries to guess the path.
That's unique
, working_dir
, include_path
.
However, if neither can be guessed, it will not be converted.
That's relative
.
unique
In relative paths, if there is only one file in the repository that matches the path in statement, this library converts it to the path to that file.
working_dir
In relative paths starting with '.' or '..', if define current directory by setWorkingDir()
, this library resolves the path from the current directory.
And this library will not guess by unique
.
include_path
In relative paths not starting with '.' or '..', if define include_path by setIncludePath()
, this library resolves the path from the include_path.
And this library will not guess by unique
.
unexpected
The statement will be of this type if it does not fall under either type.
All versions of require-path-fixer with dependencies
webmozart/path-util Version ^2.3
symfony/finder Version ^2.6
phplucidframe/console-table Version ^1.2