// composer.json
{
"require": {
"php": ">=8.2",
"ext-ctype": "*",
"ext-iconv": "*",
"knplabs/knp-time-bundle": "^2.2", // v2.4.0
"php-cs-fixer/shim": "^3.46", // v3.46.0
"phpdocumentor/reflection-docblock": "^5.3", // 5.3.0
"phpstan/phpdoc-parser": "^1.25", // 1.25.0
"symfony/asset": "7.0.*", // v7.0.3
"symfony/asset-mapper": "7.0.*", // v7.0.2
"symfony/console": "7.0.*", // v7.0.2
"symfony/dotenv": "7.0.*", // v7.0.2
"symfony/flex": "^2", // v2.4.3
"symfony/framework-bundle": "7.0.*", // v7.0.2
"symfony/http-client": "7.0.*", // v7.0.2
"symfony/monolog-bundle": "^3.0", // v3.10.0
"symfony/property-access": "7.0.*", // v7.0.0
"symfony/property-info": "7.0.*", // v7.0.0
"symfony/runtime": "7.0.*", // v7.0.0
"symfony/serializer": "7.0.*", // v7.0.2
"symfony/stimulus-bundle": "^2.13", // v2.13.3
"symfony/twig-bundle": "7.0.*", // v7.0.0
"symfony/ux-turbo": "^2.13", // v2.13.2
"symfony/yaml": "7.0.*", // v7.0.0
"symfonycasts/tailwind-bundle": "^0.7.1", // v0.7.1
"twig/extra-bundle": "^2.12|^3.0", // v3.8.0
"twig/twig": "^2.12|^3.0" // v3.8.0
},
"require-dev": {
"symfony/debug-bundle": "7.0.*", // v7.0.0
"symfony/maker-bundle": "^1.52", // v1.53.0
"symfony/stopwatch": "7.0.*", // v7.0.0
"symfony/web-profiler-bundle": "7.0.*" // v7.0.2
}
}
6 Comments
Hi!
Just by the curiosity - what did Kevin do, in the 1:23, so he got auto completion of
cache-get(...(rest of the code)? He had it before (before recording), so PHPStorm remembered it (cached ^^), or was some kind of AI completion used?Thanks!
Hey @Jan-Makarewicz!
Ugh, yeah, I had Github Copilot enabled, so this was AI. I have since disabled it when doing videos as it's a distraction.
--Kevin
Quick question about composer require differences.
In "03. The HTTP Client Service", we ran composer require for http-client to make it a direct dependency, even though it was already installed.
For CacheInterface, symfony/cache was also installed and auto-wireable. Why wasn't composer require symfony/cache necessary in that chapter, unlike with http-client?
Thanks!
Hey @Kazuki-M,
Great question!
symfony/cacheis required by the Symfony Framework itself, so if you are working on a Symfony app, you always have it available to autowire.Something I ran into is that the name of the cache, which is the 1st parameter of
$cache->get(), has to be insnake_case. Since most variables in PHP arecamelCase, I named the cache parameter with camel case like so:$cache->get('issLocationData', ...)and it was returningnull. It was not erroring out or warning it just returningnull.I even went to the documentation to see if I can find something about it and this is what the docs are stating about it.
https://symfony.com/doc/current/components/cache.html#cache-contracts<br />Now you can retrieve and delete cached data using this object. The first argument of the get() method is a key, an arbitrary string that you associate to the cached value so you can retrieve it later. The second argument is a PHP callable which is executed when the key is not found in the cache to generate and return the value:It states that it is an arbitrary string but the format it is not specify in the docs neither in this video.
Hey @gilbertodiaz ,
There's no much about the cache key name in the docs because it's really can be a random string, it isn't required to be snake_case only. I just double-check the camelCase key in
$cache->get()locally and it works the same way as snake_case for me, at least on my Mac OS. Are you using a filesystem adapter too? Because I suppose for some other filesystem adapters it might be indeed important. So, if you're on a filesystem adapter - you either miss something important in your code, e.g. forgot a return statement in the anonymous function maybe? Or you're probably on Windows OS? I suppose Windows may be case-insensitive which causes issues with camelCase naming strategy, thought it still would be weird I suppose.In short, both naming strategies: camelCase and snake_case - should work as cache key names, and most probably it's either adapter-specific, or environment-specific, or user-specific issue.
Cheers!
"Houston: no signs of life"
Start the conversation!