nytris / boost
Installs: 2 988
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: >=8.1
- asmblah/php-code-shift: @dev
- psr/cache: ^1.0
Requires (Dev)
- mockery/mockery: ^1.6
- phpunit/phpunit: ^10.2
README
Improves PHP performance, especially when open_basedir
is in effect.
Why?
open_basedir
disables the PHP realpath and stat caches, this library re-implements them in a configurable way.- Even when
open_basedir
is disabled, the native caches are only stored per-process. This library allows them to be stored using a PSR-compliant cache.
Note that for the native filesystem wrapper (when this library is not in use):
- The
stat
cache only keeps a single file, the most recent stat taken. - There is a separate similar one-stat cache for
lstat
results.
When in use, this library caches stats for all files accessed and not only the most recent one.
Usage
Install this package with Composer:
$ composer install nytris/boost
Now load it as early as possible in your application, for example a /bootstrap.php
:
<?php declare(strict_types=1); use Nytris\Boost\Boost; use Symfony\Component\Cache\Adapter\FilesystemAdapter; require __DIR__ . '/vendor/autoload.php'; // Install Nytris Boost as early as possible so that as many files as possible are cached. if (getenv('ENABLE_NYTRIS_BOOST') === 'yes') { (new Boost( realpathCachePool: new FilesystemAdapter( 'nytris.realpath', 0, __DIR__ . '/var/cache/' ), statCachePool: new FilesystemAdapter( 'nytris.stat', 0, __DIR__ . '/var/cache/' ), hookBuiltinFunctions: false ))->install(); } ...
See also
- PHP Code Shift, which is used by this library.