Loading a user's configuration file into symfony console - console

I have a Symfony console application and I'd like to let the user set some configuration in a yaml file.
I have looked through the Symfony documentation but the documentation appears to be all about application, service or bundle configuration.
Is there a Symfony 4 package/class which I can use to provide a path to a yaml file and read its contents?

Related

User Secrets not loading with WebApplication.CreateBuilder(args)

My understanding from the Microsoft documentation is the userSecret configuration is supposed to be automatically created by the WebApplication.CreateBuilder() while in the development environment. This is not true for my current WebAPI .net7 application. I have run the init command and populated the secrets file. Any ideas on why the userSecrets would be missing from the configuration sources?

How to load configuration dynamically in Next.js deployed app?

I want to have dynamic configuration for my Next.js project.
I want to be able to change it after Next.js is built and deployed.
Right now I'm using .env and .env.production which are part of dotenv repo. But it seems that Next.js or dotenv compile the content and there is no way to change them dynamically.
How can I do that?
You can't change .env after building and deploying. But a workaround is always there.
Put a JSON file separated from the project and host in the server. Read the JSON file from that server and use that variable in the configuration. But there is a security issue if you put secrets and credentials in that JSON. for that, you can write a simple node project with returning JSON configuration using API. Use a token key to access that API. Put this token secret in that node project. So, changing those variables in that node or JSON project will be more cost-effective than rebuilding and deploying again the whole project.
or simply put those configuration in database.

Manage User Secrets in a custom config file

I have a Xamarin.Forms app. As it does not have built in configuration file, I used a solution found here:
https://www.andrewhoefling.com/Blog/Post/xamarin-app-configuration-control-your-app-settings
and here
https://github.com/HoeflingSoftware/XamarinAppSettings
So now I have a custom appsettings.json file. The secrets in the file are replaced in AzureDevops pipeline. But how can I run the app from Visual Studio (on an emulator)? If it was a web application, I would use Manage User Secrets functionality, which would store the secrets in my file system. So it would be used automatically when the app is running during development. But how can I do it for a Xamarin.Forms app with its custom json file?
You could use the Replace Text in Source Files task on Marketplace to replace text in your source, before you build the project. You can then store the secret as a secure value in the pipeline variables library.
We use a similar approach to update the build versions for Xamarin Apps and for providing access to the Signing files.

application insights configuration in yml

We are using DropWizard to create java applications running as a server inside a docker container.
Command to create such applications is as below -
java -jar service-name.jar server service-name.yml
service-name.yml is a file that holds all configuration settings.
Can you suggest how do we configure application insights inside this yml file?
I don't know how DropWizard configuration reading works. But if there are hooks in the code to read the configuration, you can read all the configuration required for ApplicationInsights and manually configure in your code using TelemetryInitializers.

How can I access bundle web directory from Symfony Command?

I am creating a Symfony Bundle where I have my commands, entities and all the logic that I need.
But in one of my commands I need to store files in /web/bundles/mybundle/images.
I've been googling a lot and I can't find anyway to get my bundle web root directory from a command.
Is there any Symfony function to get my bundle web root directory?
There is nothing in the Symfony2 core which will give you directly the path of your web directory...
One possible solution:
$path = realpath($this->container->getParameter('kernel.root_dir').'/../web');

Resources