PHPackages                             smart-core/accelerator-cache-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. smart-core/accelerator-cache-bundle

ActiveSymfony-bundle[CLI &amp; Console](/categories/cli)

smart-core/accelerator-cache-bundle
===================================

Provides a command line task to clear PHP Accelerators cache from the console

1.3.0(8y ago)671.4M↓30.3%18[5 issues](https://github.com/Smart-Core/AcceleratorCacheBundle/issues)[2 PRs](https://github.com/Smart-Core/AcceleratorCacheBundle/pulls)3MITPHP

Since Jun 10Pushed 5y ago2 watchersCompare

[ Source](https://github.com/Smart-Core/AcceleratorCacheBundle)[ Packagist](https://packagist.org/packages/smart-core/accelerator-cache-bundle)[ Docs](https://github.com/Smart-Core/AcceleratorCacheBundle)[ RSS](/packages/smart-core-accelerator-cache-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (11)Used By (3)

Provide a command line to clear PHP Accelerator cache from the console.

The problem with Accelerator cache (like APC, Wincache, Opcache) 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
============

[](#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
============

[](#installation)

1. Add it to your composer.json:

```
{
    "require": {
        "smart-core/accelerator-cache-bundle": "dev-master"
    }
}
```

```
or:

```

```
composer require smart-core/accelerator-cache-bundle
composer update smart-core/accelerator-cache-bundle
```

2. Add this bundle to your application kernel:

```
// app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new SmartCore\Bundle\AcceleratorCacheBundle\AcceleratorCacheBundle(),
        // ...
    );
}
```

3. Configure `accelerator_cache` service:

```
# app/config/config.yml
accelerator_cache:
    host: http://example.com
    web_dir: %kernel.project_dir%/web
```

4. If you want to use curl rather than fopen set the following option:

```
# app/config/config.yml
accelerator_cache:
    ...
    mode: curl
#   additional options can be passed to the command
#   curl_opts:
#       CURLOPT_*: custom_value
```

Usage
=====

[](#usage)

Clear all Accelerator cache (opcode+user):

```
$ php app/console cache:accelerator:clear

```

Clear only opcode cache:

```
$ php app/console cache:accelerator:clear --opcode

```

Clear only user cache:

```
$ php app/console cache:accelerator:clear --user

```

Clear the CLI cache (opcode+user):

```
$ php app/console cache:accelerator:clear --cli

```

Composer usage
==============

[](#composer-usage)

To automatically clear accelerator cache after each composer install / composer update, you can add a script handler to your project's composer.json :

```
        "post-install-cmd": [
            "SmartCore\\Bundle\\AcceleratorCacheBundle\\Composer\\ScriptHandler::clearCache"
        ],
        "post-update-cmd": [
            "SmartCore\\Bundle\\AcceleratorCacheBundle\\Composer\\ScriptHandler::clearCache"
        ]
```

+You can specify command arguments in the `extra` section:

- `--opcode` (to clean only opcode cache):

```
        "extra": {
          "accelerator-cache-opcode": "yes"
        }
```

- `--user` (to clean only user cache):

```
        "extra": {
          "accelerator-cache-user": "yes"
        }
```

- `--cli` (to only clear cache via the CLI):

```
        "extra": {
          "accelerator-cache-cli": "yes"
        }
```

- `--auth` (HTTP authentification):

```
        "extra": {
          "accelerator-cache-auth": "username:password"
        }
```

Capifony usage
==============

[](#capifony-usage)

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

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

and add these hooks

```
# clear accelerator cache
after "deploy", "symfony:clear_accelerator_cache"
after "deploy:rollback:cleanup", "symfony:clear_accelerator_cache"
```

Nginx configuration
===================

[](#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 accelerator cache.

Example configuration:

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

```

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity51

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor3

3 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~180 days

Recently: every ~259 days

Total

10

Last Release

3101d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/35e4e44d75c04a317fb981738075cd861c584e267a65a296568813c78dfef899?d=identicon)[artemdigi](/maintainers/artemdigi)

---

Top Contributors

[![ornicar](https://avatars.githubusercontent.com/u/140370?v=4)](https://github.com/ornicar "ornicar (19 commits)")[![shieldo](https://avatars.githubusercontent.com/u/97280?v=4)](https://github.com/shieldo "shieldo (16 commits)")[![artemdigi](https://avatars.githubusercontent.com/u/34234796?v=4)](https://github.com/artemdigi "artemdigi (8 commits)")[![eymengunay](https://avatars.githubusercontent.com/u/242627?v=4)](https://github.com/eymengunay "eymengunay (6 commits)")[![kbond](https://avatars.githubusercontent.com/u/127811?v=4)](https://github.com/kbond "kbond (5 commits)")[![tborealis](https://avatars.githubusercontent.com/u/1591228?v=4)](https://github.com/tborealis "tborealis (3 commits)")[![giosh94mhz](https://avatars.githubusercontent.com/u/5219975?v=4)](https://github.com/giosh94mhz "giosh94mhz (3 commits)")[![BoShurik](https://avatars.githubusercontent.com/u/1428848?v=4)](https://github.com/BoShurik "BoShurik (3 commits)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (2 commits)")[![helmer](https://avatars.githubusercontent.com/u/586545?v=4)](https://github.com/helmer "helmer (2 commits)")[![dmecke](https://avatars.githubusercontent.com/u/1172148?v=4)](https://github.com/dmecke "dmecke (2 commits)")[![tjoelsson](https://avatars.githubusercontent.com/u/2793514?v=4)](https://github.com/tjoelsson "tjoelsson (1 commits)")[![toaotc](https://avatars.githubusercontent.com/u/871030?v=4)](https://github.com/toaotc "toaotc (1 commits)")[![antonbabenko](https://avatars.githubusercontent.com/u/393243?v=4)](https://github.com/antonbabenko "antonbabenko (1 commits)")[![Zubis](https://avatars.githubusercontent.com/u/1670194?v=4)](https://github.com/Zubis "Zubis (1 commits)")[![bocharsky-bw](https://avatars.githubusercontent.com/u/3317635?v=4)](https://github.com/bocharsky-bw "bocharsky-bw (1 commits)")[![cordoval](https://avatars.githubusercontent.com/u/328359?v=4)](https://github.com/cordoval "cordoval (1 commits)")[![garak](https://avatars.githubusercontent.com/u/179866?v=4)](https://github.com/garak "garak (1 commits)")[![iwankgb](https://avatars.githubusercontent.com/u/939646?v=4)](https://github.com/iwankgb "iwankgb (1 commits)")[![jkm9000](https://avatars.githubusercontent.com/u/21393?v=4)](https://github.com/jkm9000 "jkm9000 (1 commits)")

---

Tags

accelerator-cachecliopcode-cachephpsymfonytaskapcwincacheOpcache

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/smart-core-accelerator-cache-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/smart-core-accelerator-cache-bundle/health.svg)](https://phpackages.com/packages/smart-core-accelerator-cache-bundle)
```

###  Alternatives

[jmose/command-scheduler-bundle

This Symfony bundle will allow you to schedule all your commands just like UNIX crontab

3361.4M1](/packages/jmose-command-scheduler-bundle)[clue/term-react

Streaming terminal emulator, built on top of ReactPHP.

10410.2M2](/packages/clue-term-react)[sixdays/opcache-bundle

Provides a command line task to clear opcache cache from the console

3061.3k](/packages/sixdays-opcache-bundle)[dukecity/command-scheduler-bundle

This Symfony bundle will allow you to schedule all your commands just like UNIX crontab

25350.9k5](/packages/dukecity-command-scheduler-bundle)[wearerequired/wp-cli-clear-opcache

Use WP-CLI to clear the OPcache for a site via HTTP.

1735.6k](/packages/wearerequired-wp-cli-clear-opcache)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
