开发者

Eclipse PDT, how do I get the files on the server?

开发者 https://www.devze.com 2023-01-16 23:04 出处:网络
I am trying to learn 开发者_开发问答how to use Eclipse Helios PDT, but I don\'t understand how one gets the files from their workspace to the server. The PDT documentation is painfully sparse.

I am trying to learn 开发者_开发问答how to use Eclipse Helios PDT, but I don't understand how one gets the files from their workspace to the server. The PDT documentation is painfully sparse.

I have my workspace in /home/bob/workspace and my local dev webroot is /home/bob/public_html.

If I set up a run configuration for my php project I see where I can set up the path to the server, etc, but I do not see any obvious way to auto copy the files to my webroot to actuallly run the project. If I click on run, I just get a 404 in the browser.

With NetBeans, for instance, you can configure a PHP project to copy on save to a local webserver, FTP to a server, etc. Does PDT not have some sort of similar functionality?


I've never really used source control to push files to the production server, but that sounds interesting. What I do is use ANT.

I found that by having the workspace directly in the server location it creates a lot of hidden files, and if you are using source control these hidden files can be in every directory. I didn't feel right just copying and pasting these into my production server...

So: I set up my workspace to have the code in one spot, not on my local server. When I'm ready to test, I run the ant script. This script drops all the files that I want onto the server. Then if I feel it's ready to go, I just move these files to production (ftp or whatever).

Here is my ant script for local:

<?xml version="1.0" encoding="UTF-8"?>

<project default="init" basedir=".">

<target name="init">
    <echo message="Copying files to C:/Sandbox/xampp/htdocs"/>
    <sync todir="C:/Sandbox/xampp/htdocs">
        <fileset dir=".">
            <include name="**/*.html" />
            <include name="**/*.htm" />
            <include name="**/*.php" />
            <include name="**/*.css" />
            <include name="**/*.js" />
            <include name="**/*.jpg" />
            <include name="**/*.png" />
            <include name="**/*.gif" />
            <exclude name="env.php"/>
        </fileset> 
    </sync>
</target>

</project>

You will notice that I exclude a file called "env.php". This file contains the specific environment code. Things like database names and such that differ between local and production.

I realize it's one more step than just hitting ctrl-s then F5 to see changes locally, but it makes deploying it other places a lot simpler.

Have fun!


I'd recommend that you don't actually set up FTP/SFTP and instead use source control to push files to your production server: Git/GitHub, Subversion/Google Code, etc. You'll also get the side benefit of being able to log/diff/revert, and you'll remove the temptation to make a quick hack on the server that isn't reflected in your local files.


You can consider to instead of keeping a local project within the Eclipse Workspace, have the project directly "on the server" - e.g. "Map network drive" to the server having the files (if this is a unix server, and you program in windows, then use Samba on the unix server). Thus, when you save a change, you are actually changing it directly on the server, and hence the change will be reflected immediately when you refresh your browser.


How about a reverse "pull" deployment?

Once you commit to source control (like svn for example), on the server you can issue a svn checkout/update to deploy the code into place from your svn server.

If you have no problem saving some read only svn credentials, you could even have some sort of deployment .php page that executes the svn update command

This obviously is overkill for a local dev environment (just point apache to your workspace), but it makes sure that you have to commit everything to svn before deployment (which has the added benefit of logging every change on the website. )


One more tip for a quick and dirty solution: use a symlink in your default webserver document directory which will point to your workspace dir.

This is ok (my point of view) for development environment only.

To create a symlink: ln -s /home/bob/workspace/your_project_name /home/bob/your_project_name

Also ensure that read and execute permissions exist for webserver for all elements of the path. You can adjust permissions using chmod.


Bob, if you install the Aptana plugin then go show view => Studio => App Explorer You'll see a box looking button. If you click this, there's a web deployment wizard button. You can use this to get it to upload automatically for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消