I coudn't find the solution for Php deployment to remote server using FTP from SVN after each commit. How can I upload to server by FTP the only added or edited files and delete the deleted files from SVN I think about write post-commit script...
Good question!
I'm not sure a PHP-only approach to syncronizing files that way exists.
I would usually use third-party FTP sync tools like rsync
or ScriptFTP (commercial) to do the syncronizing part.
Take a look into phing, there are a number of FTP extensions (called "tasks") for it. I have no real world experience with them though.
This blog post offers a number of ideas and approaches: Using phing to sync files with shared hosting
You could use svn2web to upload every commited file to a server via Ftp. Svn2web is a collection of php-scripts that you can use as svn hooks. You can set the address, username and password of the ftp-server as an svn property on a directory. Works great!
The best way is (if your server is Linux based) to make an SVN Export to a new directory and then move the new directory to replace the old one (best way to do it is with symbolic links to different versions of the site). This way the site would be unavailable for a second or two, while if you rsync and have a big site, if you change drastically single file, the site would be broken until all files sync.
As for firing this procedure, the best way is to use svn hooks. Also consider doing some automated testing before release-ing (for basic functionality), because you can break your trunk pretty badly some time and the site would definitely be down :)
We are currently incorporating the approach described above in a production environment and the setup is as follows:
- A commit goes in the trunk
- Before it's actually commited, tests are ran on the code to see if everything works
- After several commits a deploy comes (usually developer supervised)
- Tests are run again
- If they are successful - all ok
- If they fail, old export is returned and the site is fully operational once again
It's all written in PHP, by using standart console commands.