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

Advertisements

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!

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

Leave a ReplyCancel reply