Giter Club home page Giter Club logo

chop's Introduction

chop

Reset the OPcache content from the CLI, without reloading PHP-FPM.

Operates the same way cachetool does, but is much smaller. Chop can only do one thing: clear the opcache content. There is no support for the APCu cache, realpath cache and none of the extra opcache commands that cachetool has.

Chop also has no dependencies besides hollodotme/fast-cgi-client. This makes it unlikely to conflict with the dependencies of your own project. Because of this, there is no need to use Chop as a PHAR. Installing it through Composer results in easier coupling with the PHP version of your application.

Installation

composer require dreadnip/chop

Usage

This is a single-command application, so calling the binary is enough:

php /path/to/your/project/vendor/bin/chop

By default, the command will print a success message or error to the console. You can suppress this output with the -q option.

php /path/to/your/project/vendor/bin/chop -q

The tool attempts to use sane defaults:

If no argument is passed, it'll look for a php-fpm socket file in the following places:

private const POSSIBLE_SOCKET_FILE_PATTERNS = [
    '~/.sock/*.sock',
    '/var/run/php*.sock',
    '/var/run/php/*.sock',
    '/var/run/php-fpm/*.sock',
];

This should find your socket file on most Linux distributions. If we forgot a common location, please open an issue/PR.

If multiple socket files are found, it'll try to select one by checking the filename for both the major and minor number of your PHP version.

For example: if your server has the followning socket files, and you're running PHP 8.1, it'll select the socket file with both 8 and 1 in the filename.

php_80_fpm_sites.sock
**php_81_fpm_sites.sock**
php_82_fpm_sites.sock

When no file socket file can be found, it will default to 127.0.0.1:9000.

If the defaults don't work for you, you can also explicitly pass an IP address or a path to a socket file using the --fcgi option:

php /path/to/your/project/vendor/bin/chop --fcgi=/var/run/php-fpm.sock

Deployer integration

Define a task with the command

task('clear:opcache', function () {
    run('{{bin/php}} {{ release_path }}/vendor/bin/chop');
});

Call the task after your deployment

after('deploy:symlink', 'clear:opcache');

Or run it manually

dep clear:opcache stage=production -vvv

Credit

This tool is of course inspired and based on the awesome cachetool.

Just like cachetool, the FastCGI socket code is handled by hollodotme/fast-cgi-client.

chop's People

Contributors

bjorvack avatar sanderdlm avatar

Watchers

 avatar

Forkers

sumocoders

chop's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.