why is /app/config/parameters.yml added to .gitignore file in - symfony

Why is the /app/config/parameters.yml file in symfony/symfony-standard .gitignore file? I thought the live (prod) settings of a project are defined in this file.

Yes, settings are defined in that file but it's added to .gitignore file because you don't want to store things like database password or csrf token in version control system as this is data which should be kept secret.
You have parameters.yml.dist file which is meant to keep placeholders for such data and running composer install will check if all data defined in parameters.yml.dist is present in parameters.yml. If not it will as you to provide it.
Check best practices for more info

Related

Couldn't setup an existing drupal site on local server

imported database, copied drupal site files to wamp/www folder, changed database configuration files, but got "Drupal already installed" error.
Tried by increasing packet size on mysql configuration file.While trying with an empty database , through the setup steps, site being installed. Is there any solution to use the existing database
Drupal version:8.9.20
Php: 7.4.26
apache: 2.4.51
mysql:5.7.36
This message can happen for several different reasons, so here is a start to help you trouble shoot:
MySQL max_allowed_packet, innodb_buffer_pool_size, innodb_lock_wait_timeout
Adding this to verify that this is the packet setting you updated in my.ini
Try updating the innodb_buffer_pool_size & innodb_lock_wait_timeout settings as well
Be sure to restart MySQL after the update is made
drupal.org source
Verify Permissions settings.local.php & MySQL DB user
Make sure the file permissions on your /sites/default/ folder is correct, and settings.local.php file (or whichever settings file you are using)
Make sure the DB user you have configured in the settings file has the correct permissions to the DB as well
Check log files
Check all log files in your WAMP log folder to see if there is any additional information

Symfony access assets folder

I have some folders in www/web/ which is the root.
It's the following folder: assets/exports/
And it contains a file export.xsl
When I do in javascript:
window.open('/assets/exports/export.xsl');
I'm going to the following link:
http://mywebsite/assets/exports/export.xsl
But I get a: 404 not found
Is symfony somehow protecting this link?
So, my question is, how can I access this file, so it starts downloading for the visitor?
From Symfony Documentation:
Keep in mind that web/ is a public directory and that anything stored here will be publicly accessible, including all the original asset files (e.g. Sass, LESS and CoffeeScript files).
Make sure you put the files in a proper directory: <symfony_root_dir>/web. See below.
Then accessing the http://mywebsite/assets/exports/export.xsl returns the file's content.
Check also your server configuration, virtual host config and read web server configuration guide from Symfony to see if you configured it properly.

Writable /vendor directory? Simple data storage

I'm creating symfony2 bundle which helps making request to some API.
When user not pass the token value (required in request) then I try to acquire this token and save it in my bundle directory (to read it later). But this path is not writable.
How can I handle simple data storage? Is my approach good or I miss something?
Should my bundle save such values in /vendor directory?
#edit: Asking user to make the directory writable is IMO bad solution
No. /vendor should not be writable by your application. You'll likely overwrite anything you save to /vendor the next time you perform a composer update or composer install.
It sounds like what you need is a persistent piece of configuration information that's outside the scope of your parameters.yml or config.yml (since you want to change it at runtime). Saving into a cache directory doesn't sound appropriate, so you're going to want to store it in some persistent location; probably your database, or a persistent key in redis or other similar storage.
If a cache directory is sufficient, though, you can get the location from the container's kernel.cache_dir parameter; but that will be erased each time the cache is cleared..

Difference between parameters.yml and config.yml in Symfony2

I don't understand the difference between these two ways of setting global constants in Symfony2. Is it only about being able to set default values and types in config.yml (+configuration.php) ?
parameters.yml file is the place for all constants that are environment dependent. If you use composer to deploy your app it will ask you about their values. You can also define paramteters.yml.dist to provide some defaults values. If you use parameters.yml you have all parameters needed to setup an application (for example on production server) in one place.
Nope, nope, nope.
parameters.yml is for passwords and server specific parameters such as database connection information.
The main difference between config.yml (and all the other config files) and parameters.yml is that parameters.yml should never be checked in to your source control system. Doing so will expose your passwords and other private information to whomever has access to your source code.
It is the way to separate some independent data in files. You can put in your config.yml all the data located in another config-files (parameters.yml, routing.yml, security.yml and so on). But it will be hard to maintain the whole project even if you are the single developer on the project.
All config data should be splitted according to their domain. Settings for email - in email-settings file, settings for integrating payment system - in payment-settings file, services - in services-config file.
If you have some personal information in the config files you can add this file to .gitignore and define some default values to the your_config.yml.dist. Then you can set up your composer to run some script to fill your_config.yml file like it has been made in symfony standard edition.

How to prevent git pull from overwriting a file?

I use Git and GitHub to push changes I make on my local web development environment to my GitHub account and from there I pull these updates to my live production site. I am working with WordPress, so what I have done is .gitignore the wp-config.php file as my productions site has its own unique wp-config.php file with its own respective database credentials. As I am git ignoring this file, when I pull to my production site it gives me the following error:
error: Your local changes to the following files would be overwritten by merge:
wp-config.php
Please, commit your changes or stash them before you can merge.
Aborting
How do I prevent this wp-config.php file from being overwritten (more specifically deleted) when I do a git pull?
This is your machine specific config file. For such case its better to use build tool. For you its better to create your custom configuration on a special file my-config.php and include it in wp-config.php. Also ignore my-config.php in .gitignore. Now you'll never see any problem like this.
What you will see is my-config.php file not found error. And write it about in your README.
I do this whole thing with configure, make even the project is in php
If this was not a config file, and you are sure about the changes you can commit first and then execute pull. Other option is stash which is already told in the error message.
Your changes won't be overwritten. That's what the error message is telling you. The pull failed because git doesn't want to overwrite your changes.
To allow the pull to take place and keep your changes, do git stash before pulling. This will save a copy of your changes and allow you to pull without any issue. Then git stash pop after pulling will restore your changes. Note that you may experience a merge conflict if the changes you are pulling to wp-config.php touch the same part of the file as your local changes.
The other side doesn't have the ignore file in effect yet. Once it's there, you won't have this message. Also it's still tracked. So in addition to changing the .ignore file on both sides, you also need to delete it on both sides and from then on it will not get in the way.
Also take a look at octopress if you are going to be using git as part of your blogging routine.

Resources