What is the best way to store read-only configuration in symfony?
I have some name/description pairs inside a JSON file, currently sitting in a bundle's resource directory that I'd like to use inside my controllers and views but don't want to insert into my database.
And what do you recommend for parsing / getting the values to display? Making a specific service for the DiC doesn't feel to good tbh..
Same scenario with me ,I worked with ymls file , create a yml file in config folder like product.yml , parse it in controller then send its josn to template .
And this is the right way to play with static data .
Related
I wrote an app that fills a database from a local JSON file, and the app doesn't use this file after that.
Is there a way to remove it by code (by deleting it for example)?
Thanks.
So I'm designing a program that lets a user send a JSON to an API using HTTP-Post.
The Json are stored in a folder inside my application called JsonFiles then inside this folder are then put into there own brand name so the path looks something like this >JsonFiles>Nike>OrderConfirm.Json
What would be a good way to let the user select a JSON File from the user interface in like a dropdown menu?
What I have so far is being able to pick a specific file from the component.ts using import,
but this is no good due to I need user interaction to choose the file. In case anyone is wondering I'm creating an application for work.
Thanks guys so much.
You can move these json files to the assets folder. So it will be available to fetch using http request.
httpClient.get(`/JsonFiles/Nike/${jsonFileName}.json`)
And in the component you just need to keep the file names.
files = ['OrderConfirm']
You can also just keep your folder anywhere, But add that path to angular.json as follows,
"assets": [
"src/assets",
"src/favicon.ico"
]
For ref: https://github.com/angular/angular-cli/wiki/stories-asset-configuration
I am trying to login and register users in codeigniter but with out using database and I would like to use json instead of database.
Can anyone give me small example that how can we do this in codeigniter.
I have worked login and registration with using database and I don't have idea of how we can do by using json.
Can any one explain me and give me small example of how to do that.
Well yes you can use helper FILE and save data in in that file.
To write / Access data, you need to do few steps:
Load File Helper
Check if File exists
Get all text and decode in array (I assume you will store in JSON format)
Fetch username/password and verify
Add new username/password in that array
Convert into JSON and save in file
I'm really wondering what's the correct and best-practice way for importing data from a json file in an ionic 2 project so I can show it in a template, for example.
Some solutions I can find use interfaces, some don't. Some implement own small services, some don't. Some use http.get().map().subscribe(), some just use subscribe(). I would really like to know how to do this properly and would be glad if somebody could enlighten me.
From my view the best practice is to use a service and use http get request to get json file from your server. We did the same for getting language json file.
If you want securely get json file then you should put your json file at secure folder rather than public folder and create an api to get json file or json object from server.
Hope it will help
I'm trying to create an HTML file to be uploaded to a different server from a Rails app. I need a solution similar to a mailer in Rails. Does anyone know of a feasible way to achieve this?
If you are trying to send a file between servers, the easiest way is to create an API endpoint on the other server that allows uploading a file and use an API key to secure the connection. You could very easily use an HTTP POST method to perform the transfer (https://rubygems.org/gems/httmultiparty). If you need to generate the file first:
data = render_to_string("post/show")
HTTParty.post('http://other.host/posts', contents: data)