Download the PHP package arraypress/wp-slurp without Composer
On this page you can find all versions of the php package arraypress/wp-slurp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download arraypress/wp-slurp
More information about arraypress/wp-slurp
Files in arraypress/wp-slurp
Package wp-slurp
Short Description Include every PHP file in a directory, in a fixed order.
License GPL-2.0-or-later
Homepage https://github.com/arraypress/wp-slurp/
Informations about the package wp-slurp
WordPress Slurp
Include every PHP file in a directory, in a fixed order.
What it does
A plugin that grows past a handful of files ends up with a bootstrap listing every one of them by hand, and a merge conflict every time two people add a class. This replaces that list with the directory it lives in.
The ordering is the point. DirectoryIterator and glob( ..., GLOB_NOSORT )
hand back whatever the filesystem holds — creation order on APFS, hashed
elsewhere — so a class extending another in the same folder loads cleanly on
your machine and fatals on the server. Files here are always loaded in name
order, which is something you control.
Features
- Load every PHP file in a directory, sorted by name
- Load several directories in the order you list them
- Recurse into subdirectories, each still sorted
- Skips the
index.phpsilence stubs - Returns the paths it loaded, so a bootstrap can be asserted on
- Reports what a directory would load without loading it
- A directory that is not there is skipped, not fatal
Installation
Quick start
Prefix filenames to pin order within a directory — 10-base.php,
20-extends-base.php. Sorting is by string, so numbers need padding.
A note on side effects
Files are require_onced, so anything at file scope runs the moment you call
this. Declare your classes and functions in these files and hook from a
bootstrap that runs afterwards, or load order becomes hook order.
Requirements
- PHP 8.3 or later
License
GPL-2.0-or-later