I am writing php web applications, and simply deploy them via FTP. To make it work, I often have some tweaking/debugging to do given that I have little control over the (free) web server hosting me, so what's working in my local environment might not work live.
For example I keep a separate php file containing class_db_myapp.php which extends a class_db.php with specific DB parameters : db name, username, password which won't be the same local and live. (For information : Lately I started using git for version control)
As my app evolves, some files get renamed / deleted / created. When comes the time to upload a new version, I have to either rely on my memory to know what I have to upload / delete or simply delete all / upload all. But in the second case I need to avoid erasing the class_db_myapp.php file...
I haven't come up with a proper solution to this.
What are the best practices in this domain?
I may have missed an existing discussion on this subject, if so please point me to it.
Thank you.
Deploy an ApplicationIn the Project Explorer view, right-click {project name} and click Run As ▸ Run on Server. Ensure Choose an existing server is selected. From the table of servers, expand localhost , select the server on which to deploy the application and click Finish .
If the ftp server supports symbolic links you can use the following technique:
If something went wrong you can easily revert to the previous version by modifying the symlink again.
For database and other settings that are different in the live environment, there are several options:
1) To solve the "different configuration on dev and live servers" problem I use this:
// Change 'localhost' to your dev server's address
define('IS_LIVE', 'localhost' != $_SERVER['HTTP_HOST']);
// Database configuration
$db_cfg = IS_LIVE?
array(...): // Live server config
array(...); // Dev server config
2) To keep the dev and live files synched I use Beyond Compare, a visual diff tool that allows me to compare whole directories, including remote ones via (S)FTP.
I set up a profile so that the left window shows files on dev server, the right one shows files on live server. This way I can see what differences there are between the servers (changed, missing or added files) and allows me to easily copy whole directories, files, or specific lines in files between them. Very useful.
It also lets you 'ignore' particular directories that you don't want to synch, like the ones with user generated files or logs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With