Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Testing PHP scripts with MySQL access offline without changing live system – recommended workflow

this question might sound simple but I havent been able to find answers online so far.
I am running a website that has php scripts accessing a mysql database.
Whenever I make changes I don’t want to work test the changes on the live website, so I test them on my local PHP server and a local MySQL database. Now obviously when i upload the changes I have to change the line establishing the connection

$con=mysqli_connect(...);

This is obviously not a huge deal but I bet professionals have their workflow set up in a way where this is not necessary right? Could any professional PHP developers tell me there workflow for making changes to a live site?

Thank you!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I am using PHPstorm btw.

>Solution :

the easiest way

if (ENVIRONMENT !== 'production')
{
   $con=mysqli_connect(localhost...);
}
else
{
   $con=mysqli_connect(live serwer...);
}

and read ENV

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading