简体   繁体   中英

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

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!

我建议您实际上不要设置FTP / SFTP,而是使用源代码控制将文件推送到生产服务器:Git / GitHub,Subversion / Google Code等。您还可以获得能够获得的附带好处记录/差异/恢复,你将消除在服务器上快速破解本地文件中没有反映的诱惑。

You can consider to instead of keeping a local project within the Eclipse Workspace, have the project directly "on the server" - eg "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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM