2017 © Pedro Peláez
 

symfony-bundle apc-bundle

Provides a command line tasks to operate with APC (APCu) cache from the console

image

symbio/apc-bundle

Provides a command line tasks to operate with APC (APCu) cache from the console

  • Monday, July 2, 2018
  • by vonschau
  • Repository
  • 7 Watchers
  • 0 Stars
  • 16 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 700 % Grown

The README.md

Provide a command line to clear APC/APCu cache from the console., (*1)

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

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

Installation

  1. Add it to your composer.json:, (*4)

    json { "require": { "symbio/apc-bundle": "dev-master" } }, (*5)

    or:, (*6)

    sh composer require symbio/apc-bundle:dev-master composer update symbio/apc-bundle:dev-master, (*7)

  2. Add this bundle to your application kernel:, (*8)

      // app/AppKernel.php
      public function registerBundles()
      {
          return array(
              // ...
              new Symbio\ApcBundle\SymbioApcBundle(),
              // ...
          );
      }
  3. Add parameter with website URL:, (*9)

      # app/config/parameters.yml, app/config/parameters.yml.dist
      cache.base_url: https://your.website.url
  4. Configure symbio_apc service:, (*10)

      # app/config/config.yml
      symbio_apc:
          base_url:   %cache.base_url%/
          web_dir:    %kernel.root_dir%/../web
  5. Set Apache user write permissions to web_dir, (*11)

      $ chmod 775 web

Usage

Clear all APC/APCu cache:, (*12)

  $ php app/console symbio:apc:clear
  $ php app/console symbio:apcu:clear

Capifony usage

To automatically clear APC/APCu cache after each capifony deploy you can define a custom task, (*13)

namespace :symfony do
  desc "Clear APC/APCu cache"
  task :clear_apc do
    capifony_pretty_print "--> Clear APC cache"
    run "#{try_sudo} sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} symbio:apc:clear --env=#{symfony_env_prod}'"
    capifony_puts_ok
  end
end

and add this hook, (*14)

# apc
after "deploy", "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/APCu' 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/APCu cache., (*15)

Example configuration:, (*16)

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

The Versions

02/07 2018

dev-master

9999999-dev http://www.symbiodigital.com/

Provides a command line tasks to operate with APC (APCu) cache from the console

  Sources   Download

MIT

The Requires

 

task apc symfony apcu

16/12 2016

1.0.0

1.0.0.0 http://www.symbiodigital.com/

Provides a command line tasks to operate with APC (APCu) cache from the console

  Sources   Download

MIT

The Requires

 

task apc symfony apcu