Update cvs and files with eclipse - php

In the past, with Eclipse and a PHP Server/system, I had it setup so that when I commited changes to the CVS repository, it also saved the actual php files on the server. I had this functionality on a another computer in the past (I can't check this computer). The files for the repository seemed to have been saved in a different folder. So the cvs is in a folder stucture like var/cvs and my system files/PHP files facing clients are in something like var/www/html/. How would one go about setting something like this up? I use sftp to change files right now with Filezilla. It was very convenient before being able to commit the changes and check the web to make sure that changes worked. Right now I have to commit the changes then save the file with ftp to see the changes. Would love to be able to get rid of the sftp with Filezilla step if at all possible...

It sounds to me that you are testing your latest changes on the live website, which is bad idea, because if you inadvertently edit some error in the files, your website may expose that to the public.
My current work-flow is as follows:
I use Netbeans on a local project, which is the SVN checkout too. On most projects I use the Netbeans option "Copy files from source folder to another location" to copy the edited files "on save" to the local test webserver directory. If the changes work on the local webserver, I'll commit them to the SVN repository and login to the live-webserver via SSH and checkout the latest revision from the SVN.
So in fact I have four copies of each file:
The working copy (a Netbeans project and SVN checkout)
/home/feeela/projects/xyz/ (editing here only)
The test-server copy; Netbeans stores a copy there on each save;
/var/www/vhosts/xyz/ (127.0.0.1/xyz/)
The SVN repository; I'll manually commit files to it after testing on the local webserver;
/var/svn/xyz/ (svn commit -m "my last change")
The SVN checkout on the live-server, which is the actual website;
/var/www/vhosts/xyz/ (svn update # xyz.com/)
I don't have a clue, how setup the "local copy" feature (which can also refer to some other machine) with Eclipse. If someone knows a way to reproduce the above workflow using Eclipse and not need to manually sync the files to the test-server, I#ll be glad to read it hereā€¦

You could use a post-commit hook script on the CVS server to update (refresh) a working copy on var/www/html/. Every time you commit, the hook script would thus get the latest version of the files on the server and put them in var/www/html/.

Related

Git workflow, am I doing it right?

More and more projects are starting to pile up and I want some workflow and also version control over the different projects. I'm trying to set the "right" workflow with Xampp, Git, GitDesktop and PhpStorm on a Windows 2012r2 machine.
Xampp base: d:\xampp
http://localhost = d:\xampp\htdocs
Dev repositories: d:\xampp\htdocs\repositories\dev\GitDemo
Live repositories: d:\xampp\htdocs\repositories\live\GitDemo
Live folder: d:\xampp\htdocs\GitDemo
Live URL: http://servername/GitDemo (intranet use only)
Right now I have my repositories folder inside the htdocs folder, otherwise I would need another alias/copy action to be able to see what I'm developing. But at the same time the repositories folder is exposed. How to hide this? htaccess?
I've ran git init --bare inside the live folder for this project. With GitDesktop I've created the repository for GitDemo inside d:\xampp\htdocs\repositories\dev.
Using PhpStorm I've created a project based upon local files and pointed it towards d:\xampp\htdocs\repositories\dev\GitDemo. I'm able to see the changes made using git status, add them using git add . and commit them succesfully with git commit -m "my commit..".
I've created a remote server git remote add live master and created a post-receive to checkout the files inside d:\xampp\htdocs\repositories\live\GitDemo to d:\xampp\htdocs\GitDemo.
This all feels like a "ton" of work to set up initially and somewhat redundant (having the same files in 3 locations).
Is this the ideal way to set this up, or do you suggest an alternative approach? Thanks for sharing your thoughts!
I've been thinking about the most logical solution (to my opinion at this moment). Here's how I solved my unclear items as described:
I've optimized it by:
Bringing the repositories directory outside htdocs to d:\repositories\dev\ and d:\repositories\live.
I've set up a symlink to http://localhost/dev/GitDemo that links to
d:\repositories\dev\GitDemo. In this way I don't need to place the
repositories folder inside the htdocs folder and still benefit from
Apache being able to serve the content, which actually resides outside the htdocs folder.
The live version is now placed at http://localhost/GitDemo and with a post-receive hook it gets deployed from d:\repositories\live\GitDemo.git to d:\xampp\htdocs\GitDemo.
If you think I made a mistake or have mistaken something from the way it's supposed to be, please correct me as I'm still not sure this is the correct way but at least it seems like it to me.

NetBeans + FTP + BitBucket

I know this has been asked before, but I couldn't get the answer I needed.
Currently I'm developing an website using PHP and was using Notepad++ before, and it all worked well because I'm developing with a co-worker so we both keep on changing different files on the FTP.
Switched to NetBeans. All went ok, pulled the entire website via FTP to my local computer and everytime I edited a file and saved it uploaded to the FTP. But, there is a problem. If my colleague updates a file, it doesn't update on my local folder. So, I thought: "Let's try versioning".
Created a team on bitbucket, created a repository. All went ok.
But now, I'm in a struggle to get everything up and running on both NetBeans (mine and colleague's) so that my colleague is editing a file on his NetBeans and constantly saving so that it gets saved on FTP and only when he stops working on that file push it to BitBucket so that I can pull after.
Suggestions?
About setting up your work environment :
In order to set up your bitbucket repository and local clone, go read this link (official doc).
You will need to repeat the cloning part once for each PC (e.g : once on yours, once on your colleague's).
Read the account management part to see how you can tag your actions with your account, and your colleague's action with his own account.
Start using your git workflow ; when you are tired of always typing your password to upload modifications to your bitbucket account, take the time to read the ssh keys setup part - read carefully, you will need to execute the procedure once for you and once for your colleague.
Using your local git repository with Netbeans is pretty straightforward :
From netbeans, run the File > New Project ... command (default: Ctrl+Shift+N),
Select PHP application with Existing Sources and click Next >,
For the Sources Folder: line, select your local git directory,
Fill the remaining fields, and if you want the last Run configuration screen, then click Finish.
After the project is created in netbeans, you can modify the Run configuration part by right clicking on the project's icon, selecting the Properties menu entry, and going to the Run configuration item.
About solving your workflow "problem" :
Your current FTP workflow can lead you to blindly squash your colleague's modifications (when uploading), or have your colleague's modification blindly squash your own local modifications (when downloading). This is bad, and you will generally notice it only after the bad stuff happened - too late.
Correctly using version control allows you to be warned when this could potentially happen, and to keep an almost infinite undo stack on the modifications of the project's files. The cost, however, is that both of you will have to add several actions in your day to day workflow - some choices can not be made automatically.
You may find it cumbersome in the beginning, but it really pays off, and quite quickly - we're talking big bucks here. So use it and learn.
On top of using Ctrl+S to save your modifications on disk, you and your colleague will need to integrate 3 extra commands in your daily work :
Save your work to your local repository (git add / git commit)
Download the latest modifications shared by your colleague (git pull)
Upload your work to the central repository (git push)
You can access these commands :
from a terminal,
from a GUI frontend : you can try TortoiseGit for windows, or gitk for linux,
from Netbeans :
in the contextual menu of the files/folders in the project tree (right click on the item, there is a "Git" entry),
using the Team > Git > ... menu
Since you provided a git tag, I'll describe what's to do for Git.
set up a remote bare repo on a server that you both could access (BitBucket in your case):
http://git-scm.com/book/en/Git-on-the-Server-Getting-Git-on-a-Server
you both clone that remote repo to your local machines:
http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository#Cloning-an-Existing-Repository
each of you works in her part of the application. When one is done, publish the work to the server:
http://git-scm.com/book/en/Git-Basics-Working-with-Remotes#Pushing-to-Your-Remotes
By now, the remote server holds the version that was just pushed. What's missing is the deployment of the website. This has been discussed here:
Using GIT to deploy website
Doing so, you will decouple your work from that of your colleague since you're not changing files over FTP all the time. You work in your part, your partner works on her part. The work is getting merged and then a new version of the website gets published.
You can create git or Mercurial repositories in Atlassian Bitbucket (http://bitbucket.org). If your team is new to version control, i advise you no forks in your first project.
The easy solution ins to use Atlassian SourceTree (http://www.sourcetreeapp.com/) to control your code since there is a bug in netbeans. See NetBeans + Git on BitBucket
You need to create a new repository in bitbucket. I assume you already configure the ssh2 keys. Using Git you need:
git clone --bare --shared php_project php_project.git
git commit
Using Mercurial you need:
hg init
hg commit
Good luck / boa sorte
Pedro

How to work with ssh in PhpStorm?

I have the project in the remote server and i have only ssh access. How i can work with this project? I am looking for information for either PhpStorm or NetBeans.
You have several options, depending on your system.
You can rsync or scp up your files when you want to publish.
You can use version control (cvs, svn, git, mercurial, ...) and via ssh perform an "update" when you wish your code to go live.
You can set up a sshfs filesystem locally.
I don't know about NetBeans, but PhpStorm has a feature that allows uploading files as soon as they change to a server (via FTP or SSH).
I don't have a lot of experience with this feature but it does seem to work well. PhpStorm can also be configured to deploy changes that occurred outside (it seems to do so as soon as it regains focus). It also seems to properly delete files that have been deleted from the project, so it's a real sync, not just "upload".
See how to configure it under "To have PhpStorm upload changed files automatically" here: http://www.jetbrains.com/phpstorm/webhelp/uploading-and-downloading-files.html

SVN checkout browser

I've been looking all over for a SVN browser. Now I'm not talking about anything like WebSVN or TRAC, I don't want to browse the repository; I want to browse the checkout.
I'm looking for a program that lets me browse the checkout (working copy) and shows me the info I'd normally need to SSH for. So I could mark specific files or folders for some commit button, or see the status, or view a diff between the working and a prev version. Basically a web GUI for a svn checkout.
A [windows] program that can let you work on a remote checkout as if it were local would also work.
Currently I have a checkout on my server running under dev.mysite.com. I log in via ftp and edit and upload the files. I also keep SSH open so I can do a svn st to see what files I've worked on and to commit changes. I want to work on the files on the same environment so I can't simply use a local checkout. But I don't want to need to work via SSH.
Are there any apps such as I described? Like a repo browser but for checkouts to do commits. Like WebTortoiseSVN or such.
Thanks
Why don't you SFTP-mount the remote site locally and use something like Tortoise SVN ( http://tortoisesvn.tigris.org/ ) to manage the SVN stuff locally?
For example you mount dev.yoursite.com as drive Z: and you can use it as a local drive. Tortoise SVN automatically finds that it holds a SVN checkout and you can use it transparently.
As the checkout information is stored in the file system is there any reason that you cant mount the ftp directory as a local folder (or just browse to the ftp:// url) and use tortoise on it?
Have you tried the pecl package?
http://www.php.net/manual/en/book.svn.php
It's an API for SVN, so it's not a GUI, but I'm sure you can build one on top.
On a sidenote: your question is somewhat difficult to understand for me. I am not sure what you are really asking for, so if you could clearify some more, I might be able to add to my question.
EDIT If you just need an SVN manager, then go with Tortoise (mentioned elsewhere) or consider using an IDE that has built-in SVN support, like Eclipse.

php, user-uploaded files, version control, and website deployment

I have a website that I regularly update the code to. I keep it in version control. When I want to deploy a new version of the site, I do an export and then symlink the served directory name to the directory of the deployment.
There is a place where users can upload files, and I noticed once that, after I had deployed a new version, the user files were gone! Of course, I hadn't added them to the repository, and since the served site was from an export, they weren't uploaded into a version-controlled directory anyways.
PHP doesn't yet have integrated svn functionality, so I couldn't do much programmatically to user uploaded files. My solution was to create an additional website, files.website.com, which sits in a parallel directory to the served website, and is served out of a directory that is under version control. That way they don't get obliterated when I do an upgrade to the website. From time to time, I manually add uploaded files to the svn project, deleted user-deleted ones, and commit the new version. I'm working on a shell script to run from cron to do this, but it isn't my forte, so it's on the backburner as it's not a pressing need.
Is there a better way to do this?
I usually dont keep user generated data/file in svn. only the code, db schema/test data. What i usually do to deploy is an rsync from an up to date working copy which excludes the upload dir and .svn dirs. IMO content should be handled by more traditional filesystem/db backup mechanisms and not version control.
EDIT:
Just to be clear your symlinking strategy seems like a good practice. youre jsut missing the backup part it think. Id probably just tar | gzip the uploaded stuff in the cron job instead of interacting with SVN. And then probably have a seperate one to use mysqldump to dump the db and gzip that as well.
I would continue with the practice of exporting the site as upgrades are needed but have a symbolic link to a directory outside of the version controlled directory with the user uploaded content. This way when you do an export you only need to recreate the symlink if it gets blown away. You should then of course be backing up that user content as needed.
Rather than manually doing the export and managing symlinks, you could make your deployment directory a subversion checkout (from a production branch). That way, deploying is as simple as checking in your updates to the production branch.
This works as long as you have sufficient control of your subversion server and hosting setup, and your subversion repository is "ready to run." In this situation, your user directory could be an empty placeholder in subversion and would be left alone by the update process that runs on commit (business as usual for svn update). I'd still recommend (as mentioned by #Flash84x and #prodigitalson) a separate process to back up the user content.
There's an Ars Technica article with a description of how to set this up.
Update: If you follow this approach, make sure that your web server does not allow access to the .svn files in the deployment checkout.

Categories