• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PHP-DI / PHP-DI / 1826
94%
master: 95%

Build:
Build:
LAST BUILD BRANCH: php8
DEFAULT BRANCH: master
Ran 06 Jan 2018 10:22PM UTC
Jobs 1
Files 59
Run time 3s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
1826

push

travis-ci

mnapoli
Restore a definition cache for autowiring and Container::make() performances

This restores some kind of cache like there was in PHP-DI 4 and 5 (which was removed during v6's development). However this is not a full restore, this new cache is very simple and targeted at specific use cases.

Related to #543 and #547.

Compiling the container is the most efficient solution, but it has some limits. The following cases are not optimized:

- autowired (or annotated) classes that are not declared in the configuration
- wildcard definitions
- usage of `Container::make()` or `Container::injectOn()` (because those are not using the compiled code)

If you make heavy use of those features, and if it slows down your application you can enable the caching system. The cache will ensure annotations or the reflection is not read again on every request.

The cache relies on APCu directly because it is the only cache system that makes sense (very fast to write and read). Other caches are not good options, this is why PHP-DI does not use PSR-6 or PSR-16.

To enable the cache:

```php
$containerBuilder = new \DI\ContainerBuilder();
if (/* is production */) {
    $containerBuilder->enableDefinitionCache();
}
```

To be clear: compilation should be used first. This cache is only for specific use cases.

30 of 30 new or added lines in 3 files covered. (100.0%)

1266 of 1350 relevant lines covered (93.78%)

62.02 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
3
100.0
src/ContainerBuilder.php
19
100.0
src/Definition/Source/SourceCache.php
Jobs
ID Job ID Ran Files Coverage
2 1826.2 06 Jan 2018 10:21PM UTC 0
93.78
Travis Job 1826.2
Source Files on build 1826
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #1826
  • 26fcc6e0 on github
  • Next Build on apcu-cache (#1829)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc