Chapters
24 Chapters
|
2:45:42
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: >=5.5.9
Subscribe to download the code!Compatible PHP versions: >=5.5.9
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Subtitles
Subscribe to download the subtitles!
Subscribe to download the subtitles!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
18.
Priming cache.app
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
While the fundamentals of Ansistrano haven't changed, this tutorial is built using Symfony 3, which has significant differences versus Symfony 4 and later.
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": ">=5.5.9",
"doctrine/doctrine-bundle": "^1.6", // 1.6.8
"doctrine/orm": "^2.5", // v2.7.2
"incenteev/composer-parameter-handler": "^2.0", // v2.1.2
"sensio/distribution-bundle": "^5.0.19", // v5.0.20
"sensio/framework-extra-bundle": "^3.0.2", // v3.0.26
"symfony/monolog-bundle": "^3.1.0", // v3.1.0
"symfony/polyfill-apcu": "^1.0", // v1.4.0
"symfony/swiftmailer-bundle": "^2.3.10", // v2.6.3
"symfony/symfony": "3.3.*", // v3.3.5
"twig/twig": "^1.0||^2.0", // v1.34.4
"doctrine/doctrine-migrations-bundle": "^1.2", // v1.2.1
"predis/predis": "^1.1", // v1.1.1
"composer/package-versions-deprecated": "^1.11" // 1.11.99
},
"require-dev": {
"sensio/generator-bundle": "^3.0", // v3.1.6
"symfony/phpunit-bridge": "^3.0", // v3.3.5
"doctrine/data-fixtures": "^1.1", // 1.3.3
"hautelook/alice-bundle": "^1.3" // v1.4.1
}
}
What Ansible libraries does this tutorial use?
# ansible/requirements.yml
-
src: DavidWittman.redis
version: 1.2.4
-
src: ansistrano.deploy
version: 2.7.0
-
src: ansistrano.rollback
version: 2.0.1
8 Comments
What's the default value of query_cache_driver, and is it better/faster to set it to apcu or redis ! By default, does doctrine set the result of repository queries under cache ?
Hi ahmedbhs!
> What's the default value of query_cache_driver
It depends on your version of DoctrineBundle, but basically the short answer is that (if you have a recent version) then it will use the same driver as cache.system. Basically, it creates a new "pool" off of cache.system, which usually uses opcache internally, iirc.
> is it better/faster to set it to apcu or redis
It probably wouldn't make a difference :). The fact that you're caching will give you 99% of the overall boost available.
> By default, does doctrine set the result of repository queries under cache ?
No, it does not cache the *results* of the queries by default. You *can* do this, however. In modern versions of DoctrineBundle, this cache is enabled by default (it uses a pool off of cache.app). However, you need to activate it on a case-by-case basis, as caching query results may mean you need to think about invalidation etc. Specifically, it's the useResultCache(true) part - https://www.doctrine-projec... - I don't have any experience using this. I DO cache sometimes, but I usually will call a query in Doctrine, get the result, then cache whatever I need manually use Symfony's cache service.
Cheers!
Hi. I am using ansistrano to deploy my symfony app and it's working very well. However, sometimes when I release a new version, some of my users are still watching there previous version. I think this is related to the cache service. Do I need to do any configuration for that? I want that everybody can watch the new release immediately after the deploy. I hope you can help me.
Hey Cesar!
Interesting! So.... the answer depends on what you mean exactly by "some of my users are still watching the previous version". On a PHP level, during deploy, 100% of the users are still using the original PHP code path. After deploy, 100% of the users are using the NEW PHP code path (as soon as the symbolic link changes, all requests use the new code). However, if you're referring to JavaScript or CSS, then it's more interesting :). If you make an update to a JS or CSS file and deploy, the new JS or CSS file will be deployed just like any other file. However, the user's browser might still use the old, *cached* version.
Is this your issue? If so, you need to use a cache busting strategy. I *highly* recommend using Webpack Encore, as it will handle cache busting / versioning automatically. We're creating a screencast about this right now - https://knpuniversity.com/s... - but you can find details here: https://symfony.com/doc/cur...
Cheers!
Thanks Ryan for answering. That's exactly my issue with CSS and JS. I would like to buy your tutorial when it's complete. Do I need to watch first another tutorial before to enter in this one?. Also, meanwhile, do you recommend me to use ascetic or http-cache?
Hey Cesar,
Do you mean watching Webpack course before Webpack Encore? Actually Encore is just a simple wrapper around Webpack which makes your work with Webpack library drastically simpler. So, you can start directly with Encore course, but if you need to dive deeper into Webpack - you need the Webpack course. However, I'd recommend to see Webpack course to understand Webpack and Webpack Encore better.
If you mean AsseticBundle - Webpack Encore is the tool which completely replaces this bundle and adds you more more features out of the box. So if you're going to use Encore - forget about AsseticBundle at all.
About HTTP cache: it depends on your project, if you have a simple website with a lot of public content (not user-specific pages or user-specific blocks on each page) - it makes sense. Otherwise it could be even overhead in some cases. Anyway, HTTP cache complicates things a lot and you need to start thinking about cache invalidation on deploys. I'd recommend you to look at Symfony Cache Component first that are enough in most cases and that is much simpler.
Cheers!
Thanks Victor. When are you calculating to finish the Webpack Encore course? I am going to buy it or sure.
Yo Cesar,
Webpack Encore is going to be completely released in a few weeks, as you might notice we're working on it right now and trying to release a new video every day. And Webpack Encore course will be FREE for everyone! But if you're looking for buying something, take a look at paid Webpack course which is already completely released :p
Cheers!
"Houston: no signs of life"
Start the conversation!