Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Apc Bundle Laravel Package

ornicar/apc-bundle

Ornicar APC Bundle integrates Alternative PHP Cache (APC) with Symfony applications, providing cache services and tools to store, retrieve, and clear cached data. It helps speed up PHP apps by reducing repeated computations and database queries.

View on GitHub
Deep Wiki
Context7

Getting Started

Start by reading the one-line description again: this is a Symfony bundle, explicitly unmaintained, and points to smart-core/accelerator-cache-bundle as its successor. From a Laravel developer's perspective, that's the headline. There is no Laravel integration path here — no service provider, no config/cache.php driver, no facade. Leveraging it "day-to-day" in a Laravel app really means not putting it in a Laravel app.

The only honest getting-started path is for a legacy Symfony 2.x codebase you've inherited and are trying to keep alive:

  1. composer require ornicar/apc-bundle — expect this to fight modern Symfony/PHP constraints; the bundle targets ~2.x.
  2. Register it in app/AppKernel.php:
    new Ornicar\ApcBundle\OrnicarApcBundle(),
    
  3. Confirm the original APC extension is loaded (php -m | grep apc). This is APC, not APCu — they share a name prefix and almost none of the same story on PHP 7+.
  4. Open Resources/config/services.xml after install. That file, plus the DI extension, is effectively the entire package. Inject the service it declares rather than calling apc_*() in your code.

First use case: the bundle exists to register a configured cache service in Symfony's container so controllers and services can fetch()/save() without hardcoding extension calls, or so Doctrine's ApcCache adapter gets a wired-up implementation. If you want a "first win," it's injecting that service into whatever consumed apc_fetch() previously.

Where to look first: the DI extension and services.xml. If the service you want isn't declared there, there is nothing else to learn — this is a registration wrapper, not a library with an API.

For a Laravel project, the first stop is config/cache.php and the Cache facade. If you have an APCu-shaped requirement, target a maintained PSR-6/PSR-16 adapter or a small custom store — not this bundle.

Implementation Patterns

  • Inject, don't call globals. Wrap the service behind constructor injection so the code is testable and swappable later:
    public function __construct(Cache $cache) { $this->cache = $cache; }
    
    apc_fetch() sprinkled through controllers is the thing that makes migration painful later.
  • Key namespacing with a version prefix. APC keys are a flat global namespace with no invalidation primitives. Use catalog.v3.product.42 and bump the version segment to invalidate a whole slice at deploy time.
  • Explicit TTLs on every write. save($key, $value, $ttlSeconds) maps directly to apc_store. There is no default TTL, no tag invalidation, no "forget" cascade — you own expiry.
  • Stay on Doctrine\Common\Cache\Cache if you can. If surrounding code already speaks the Doctrine cache interface and uses the APC driver, keeping that contract means your eventual swap to AcceleratorCacheBundle or symfony/cache is a config change, not a refactor.
  • Wrap the wrapper. Define an application-level AppCache interface (or a tiny class) that owns every apc_* call. That single seam is the whole migration path later and costs nothing today.
  • Cache warmers are a trap worth knowing. A Symfony CacheWarmer is a natural place to precompute data on deploy — but only if CLI and FPM actually share the cache (see Gotchas).
  • If you're actually in Laravel: the pattern is inverted. Register a Cache::extend() driver or bind a PSR-16 adapter, and treat anything APC-shaped as a single-node fallback behind Cache::store('array') semantics. Do not add this bundle to a Laravel composer.json.

Gotchas and Tips

  • This is APC, not APCu. APC was deprecated in PHP 5.4 and removed in PHP 7+. On any modern PHP runtime the extension this bundle wraps simply isn't there. If you're on PHP 7+, stop and go to smart-core/accelerator-cache-bundle (APCu) or symfony/cache directly.
  • CLI and web don't share APC by default. apc.enable_cli=1 is required for console commands and warmers to populate the same cache the FPM worker reads. This is the #1 "the cache is always cold" bug with this bundle. Confirm before you build around it.
  • Per-SAPI php.ini. FPM pool config and CLI config often differ. Verify apc.enabled, apc.shm_size, and apc.enable_cli with phpinfo() per SAPI — not just in the shell.
  • No PSR-6 or PSR-16. There is no CacheItemPoolInterface. You get array-style fetch/store/delete. Any framework-native abstraction you want must be your own thin adapter.
  • Memory fragmentation, not bugs. If apc_store starts failing under churn, you're hitting apc.shm_size/apc.ttl limits and fragmentation. Watch apc.php stats before chasing it in application code.
  • Deploy invalidation. New code plus stale entries produces classic "old code is still running" symptoms. Either restart web workers on deploy or key-version everything; there is no cache:clear that touches this.
  • Extension points are minimal but real. The DI extension lets you override service definitions via a CompilerPass or an alias in app/config/services.yml. Use that — do not edit the vendor copy.
  • Do not patch the vendor tree. Forks and PRs aren't being merged. Keep any fixes in a decorator or a wrapper class so a future migration to AcceleratorCacheBundle stays a clean swap.
  • Treat it as a migration backlog item. If it's in a legacy Symfony app you own, the day-to-day win is containment: isolate behind your interface, instrument hit/miss and failures, and document a removal date. The package's 0 dependents and unmaintained status mean the team owns every future compatibility and security question.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin