Chapters
23 Chapters
|
2:20:28
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!
Subscribe to download the code!
-
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!
20.
Using & Overriding Secrets
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.
This tutorial also works great for Symfony 6!
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": "^7.3.0 || ^8.0.0",
"ext-ctype": "*",
"ext-iconv": "*",
"composer/package-versions-deprecated": "^1.11", // 1.11.99
"knplabs/knp-markdown-bundle": "^1.8", // 1.9.0
"sensio/framework-extra-bundle": "^6.0", // v6.2.1
"sentry/sentry-symfony": "^4.0", // 4.0.3
"symfony/asset": "5.0.*", // v5.0.11
"symfony/console": "5.0.*", // v5.0.11
"symfony/debug-bundle": "5.0.*", // v5.0.11
"symfony/dotenv": "5.0.*", // v5.0.11
"symfony/flex": "^1.3.1", // v1.21.6
"symfony/framework-bundle": "5.0.*", // v5.0.11
"symfony/monolog-bundle": "^3.0", // v3.6.0
"symfony/profiler-pack": "*", // v1.0.5
"symfony/routing": "5.1.*", // v5.1.11
"symfony/twig-pack": "^1.0", // v1.0.1
"symfony/var-dumper": "5.0.*", // v5.0.11
"symfony/webpack-encore-bundle": "^1.7", // v1.8.0
"symfony/yaml": "5.0.*" // v5.0.11
},
"require-dev": {
"symfony/maker-bundle": "^1.15", // v1.23.0
"symfony/profiler-pack": "^1.0" // v1.0.5
}
}
25 Comments
Now that Knp markdown is abandoned I tried to implement the markdown caching service using the suggested twig filter. However that does not support/expose MarkdownParserInterface. I noticed that the twig filter uses michelf php-markdown though, which does support that interface. Luckily I did this in another branch which is now named 'broken' :( Autowiring does not pick up the michelf classes, do I need to put Michelf\Markdown in autoload.php? How do I stop twig from inlining the classes and making them disappear?
I get :
Sentry\State\HubAdapter
How to see DSN?
So in your controller method, you want to run
dump($sentryHub->getClient()->getOptions());Hey Name->Nick,
Thank you for this tip again!
Cheers!
Hey Ruslan,
If you want to dump SENTRY_DSN, you can do it in whatever PHP file you want, e.g. add this in a controller where you need this value:
Both should print you your DSN value for Sentry if you set any in your .env files
I hope this helps!
Cheers!
How do you access secrets in code? It doesn't seem like getenv() will pull a secret.
I figured out what I was doing wrong, so ignore this question.
No problem :)
Hi, I'm getting:
Environment variable not found: "SENTRY_DSN".
But the secret is configured as below:
And my sentry.yaml file show:
I've delete the SENTRY_DSN lines from .env and .env.local
It started working, I'm not sure why, but the only thing I think changed was that I restarted the Symfony server.
Hey Joao P.
That's weird. Perhaps it was due to the cache? Who knows :)
No, it wasn't cache. Cleared it alright
I'm getting the following error when trying to reveal secrets in prod environment:
PHP Fatal error: Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException: Circular reference detected for parameter "env(base64:default::SYMFONY_DECRYPTION_SECRET)" ("env(base64:default::SYMFONY_DECRYPTION_SECRET)" > "env(default::SYMFONY_DECRYPTION_SECRET)" > "env(SYMFONY_DECRYPTION_SECRET)" > "env(base64:default::SYMFONY_DECRYPTION_SECRET)"). in cauldron-overflow\vendor\symfony\dependency-injection\Container.php:389I used this command:
php bin/console secrets:list --env=prod --reveal, Symfony version: 5.1.2Any ideas?
Hey @Beam OP!
I know this :). You have found a Symfony bug! https://symfonycasts.com/sc...
It is fixed in Symfony 5.1.3, but that hasn't been released yet - I expect that to happen any day now - it's been 28 days since the last bug release.
Cheers!
I am getting the following error in logs when switching to prod:
Hey Michał,
If you use Git - try to commit changes and run:
$ git grep dsn
This command will show you all the spots where you use dsn. Make sure that all dsn options are set properly in your project. Also, keep eyes closer where those values should come from, probably you need to set up an env var in your .env or .env.local files? Or probably specifically in .env.prod in your case?
Cheers!
Hey! Doesn't secrets work for console commands? Something weird is happening with my project. When I ran
./bin/console doctrine:database:dropit returns <blockquote>Connection does not contain a 'path' or 'dbname' parameter and cannot be dropped.</blockquote> I set a breakpoint at exception line and found out that$paramslocal variable does <b>not</b> contain data for my PostgreSQL connection: at least $params["driver"] = pdo_mysql . I faced with the issue after deploying my whole Docker Compose stack to remote machine through Docker Machine. I set all the demo env var through secrets intentionally. After deploying I decided to re-create database and started withdoctrine:database:dropand got that error. Trying to executedoctrine:migrations:migrateshows$dsn == mysql:host=localhost;dbname=;charset=utf8mb4;Nonsense! To be honest I just lost debugging call stack to find out why the app takes default env values instead of stored in secrets. Any ideas?The problem is that the secrets are NOT read for some reason. They are successfully displayed with `./bin/console secrets:list --env=demo --reveal` but do not work until decrypting into `.env.demo.local`. `debug:config framework secrets` confirms that secrets are enabled. Some googling showed that there might be a problem with sodium extension but I have one both on dev and demo machine/environments.
Event setting SYMFONY_DECRYPTION_SECRET environment variable gives no help...
OMG! Shame on me! I've just forgot to comment out env vars in .env file. I use an empty env vars in .env just not to forget to set them in .env.<env_name> file. Thus empty values in .env just override secrets. And only decrypting secrets with `secrets:decrypt-to-local` writes .env.<env_name>.local which in its turn override empty values in `.env`.
Dang! what a sneaky error. I'm glad you figured it out. FYI what you put on the
.env.<environment_name>will override any other value you already haveCheers!
"Houston: no signs of life"
Start the conversation!