Download the PHP package gordalina/cachetool without Composer
On this page you can find all versions of the php package gordalina/cachetool. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package cachetool
CacheTool - Manage cache in the CLI
CacheTool allows you to work with APCu, OPcache, and the file status cache through the CLI. It will connect to a FastCGI server (like PHP-FPM) and operate on its cache.
Why is this useful?
- Maybe you want to clear the bytecode cache without reloading php-fpm or using a web endpoint
- Maybe you want to have a cron which deals with cache invalidation
- Maybe you want to see some statistics right from the console
- And many more...
Note that, unlike APCu and Opcache, the file status cache is per-process rather than stored in shared memory. This means that running stat:clear
against PHP-FPM will only affect whichever FPM worker responds to the request, not the whole pool. Julien Pauli has written a post with more details on how the file status cache operates.
Installation - Latest version
You can alternatively download a compressed phar by using the URLs below.
CacheTool is also packaged as a docker container available in docker hub and github container registries.
See below for docker usage instructions.
Installation - old versions
Use tag name in the binary file name. E.g to download cachetool 3.2.2
which is compatible with PHP >=5.5.9
use: cachetool-3.2.2.phar
Usage
CacheTool requires an adapter to connect to, it can be cli
, fcgi
, and web
.
The fcgi
adapter is the most common, as it connects directly to php-fpm.
You can pass an IP address or a unix socket to the --fcgi
adapter, or leave it blank and CacheTool will try to find the php-fpm socket for you. If it can't find it, it will default to 127.0.0.1:9000
.
-
You can let CacheTool find the unix socket for you, or default to IP.
-
You can connect to a fastcgi server using an IP address
-
You can connect to a fastcgi server using a unix socket
-
To connect to a chrooted fastcgi server you need to set
--fcgi-chroot
and--tmp-dir
parameters -
Using the CLI
-
Using an HTTP interface
- Using SymfonyHttpClient
You have some useful commands that you can use
Usage via Docker
Images are available in docker hub and github container registries:
gordalina/cachetool:latest
ghcr.io/gordalina/cachetool:latest
This is an example run with the web
adapter:
If the website is behind a proxy and/or load balancer you may want to ask directly the webserver instead of the public facing ip. Additionally, the webserver may be listening in another port. This is an example for running cachetool from the webserver host in such a setup:
Thank you to @jonhattan and @NITEMAN for the work with docker.
Configuration File
You can have a configuration file with the adapter configuration, allowing you to
call CacheTool without --fcgi
, --cli
, or --web
option.
You can pass a --config <file>
option to the application or it will choose to load
a file automaically.
The file must be named .cachetool.yml
or .cachetool.yaml
. CacheTool will look for
this file on the current directory and in any parent directory until it finds one.
If the paths above fail it will try to load /etc/cachetool.yml
or /etc/cachetool.yaml
configuration file.
An example of what this file might look like is:
Will connect to fastcgi at 127.0.0.1:9000
Will connect to cli (disregarding fastcgi configuration)
CacheTool writes files to the system temporary directory (given by sys_get_temp_dir()
)
but if you want to change this, for example, if your fastcgi service is run with PrivateTemp
you can set it on the config file:
Example for the web adapter:
You can define the supported extensions in the config file. By default, apcu
,
and opcache
are enabled. To disable apcu
, add this to your config file:
Usage (as a library)
Add it as a dependency
If you want to use it in a Symfony 2.x project, require the 1.x
version
Create instance
You can use apcu
and opcache
functions
Proxies
CacheTool depends on Proxies
to provide functionality, by default when creating a CacheTool instance from the factory
all proxies are enabled ApcuProxy
, OpcacheProxy
and PhpProxy
, you can customize it or extend to your will like the example below:
Updating CacheTool
Running php cachetool.phar self-update
will update a phar install with the latest version.
Building cachetool.phar
Cachetool uses box to built the phar, see box-project/installation.md on the best way to install it in your situation. To built run box compile
, which will output cachetool.phar
in the project root directory.
Testing
After running composer install
, run ./vendor/bin/phpunit
Troubleshooting test failures
sslip.io
Tests in tests/Adapter/Http/FileGetContentsTest
and tests/Adapter/Http/SymfonyHttpClientTest
rely on sslip.io to resolve hostnames containing an IP to the IP contained. For this to work a nameserver from sslip.io needs to be in the DNS servers configured on the host which runs those tests, otherwise hostnames like _.127.0.0.1.sslip.io
used for testing will not resolve. The IP addresses for the DNS servers can be found on sslip.io, how to configure them depends on the system used to run the tests.
Version Compatibility
CacheTool | PHP |
---|---|
9.x |
>=8.1 |
8.x |
>=8.0 |
7.x |
>=7.3 |
6.x |
>=7.3 |
5.x |
>=7.2 |
4.x |
>=7.1 |
3.x |
>=5.5.9 |
2.x |
>=5.5.9 |
1.x |
>=5.3.3 |
License
CacheTool is licensed under the MIT License - see the LICENSE for details
All versions of cachetool with dependencies
monolog/monolog Version ^3.0
php Version >=8.1.0
psr/log Version ^2.0 || ^3.0
symfony/console Version ^6.0
symfony/dependency-injection Version ^6.0
symfony/finder Version ^6.0
symfony/process Version ^6.0
symfony/yaml Version ^6.0
symfony/http-client Version ^6.0
symfony/http-foundation Version ^6.0
consolidation/self-update Version ~2.1.0