Consider from the view point of wev developer, a public running site, whose code is to be made public but some data transactions on the site occur via php to MySQL server.
Code like this is usually,
<?php
$servername = "localhost";
$username = "username";
$password = "password";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
placed in a file connect.php
which is used to initiate connections.
What would be the best way to prevent public access to this file's content over GitHub public repo.
If in case
.gitignore
is used to remove the file from the repo, can we still keep the repo in sync with the webserver's serving directory.
Would like to know what would be the recommended way.