GithubHelp home page GithubHelp logo

apcbundle's Introduction

NOT MAINTAINED

Provide a command line to clear APC cache from the console.

The problem with APC is that it's impossible to clear it from command line. Because even if you enable APC for PHP CLI, it's a different instance than, say, your Apache PHP or PHP-CGI APC instance.

The trick here is to create a file in the web dir, execute it through HTTP, then remove it.

Prerequisite

If you want to clear Apache part of APC, you will need to enable allow_url_fopen in php.ini to allow opening of URL object-like files, or set the curl option.

Installation

  1. Add it to your composer.json:

    {
        "require": {
            "ornicar/apc-bundle": "1.0.*"
        }
    }

    or:

        composer require ornicar/apc-bundle
        composer update ornicar/apc-bundle
  2. Add this bundle to your application kernel:

     // app/AppKernel.php
     public function registerBundles()
     {
         return array(
             // ...
             new Ornicar\ApcBundle\OrnicarApcBundle(),
             // ...
         );
     }
    
  3. Configure ornicar_apc service:

     # app/config/config.yml
     ornicar_apc:
         host: http://example.com
         web_dir: %kernel.root_dir%/../web
    
  4. If you want to use curl rather than fopen set the following option:

     # app/config/config.yml
     ornicar_apc:
         ...
         mode: curl
    

Usage

Clear all APC cache (opcode+user):

      $ php app/console apc:clear

Clear only opcode cache:

      $ php app/console apc:clear --opcode

Clear only user cache:

      $ php app/console apc:clear --user

Clear the CLI cache (opcode+user):

      $ php app/console apc:clear --cli

Capifony usage

To automatically clear apc cache after each capifony deploy you can define a custom task

namespace :symfony do
  desc "Clear apc cache"
  task :clear_apc do
    capifony_pretty_print "--> Clear apc cache"
    run "#{try_sudo} sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} apc:clear #{console_options}'"
    capifony_puts_ok
  end
end

and add these hooks

# apc
after "deploy", "symfony:clear_apc"
after "deploy:rollback:cleanup", "symfony:clear_apc"

Nginx configuration

If you are using nginx and limiting PHP scripts that you are passing to fpm you need to allow 'apc' prefixed php files. Otherwise your web server will return the requested PHP file as text and the system won't be able to clear the apc cache.

Example configuration:

# Your virtual host
server {
  ...
  location ~ ^/(app|app_dev|apc-.*)\.php(/|$) { { # This will allow apc (apc-{MD5HASH}.php) files to be processed by fpm
    fastcgi_pass                127.0.0.1:9000;
    ...

apcbundle's People

Contributors

antonbabenko avatar cordoval avatar dmecke avatar eymengunay avatar garak avatar giosh94mhz avatar helmer avatar jkm9000 avatar nyholm avatar ondrowan avatar ornicar avatar polem avatar shieldo avatar shtumi avatar tjoelsson avatar toaotc avatar tomadam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

apcbundle's Issues

prerequisite to clear apache APC

To clear apache part of apc, you need to allow_url_fopen=1 (or On) in php.ini. This should be mentioned as prerequisite in README.md.

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.