Drale

NetBeans PHP Project on Dreamhost Advanced Setup

This guide will show you how to setup a PHP project in NetBeans covering a complicated situation, such as files behind public root. PHP support is new in NetBeans so hopefully this guide will help some new comers to NetBeans that want to use it for PHP websites.

What some may experience when first using an IDE such as NetBeans or Dreamweaver is the native tendency for these programs to guess what is best for you when it comes to your project paths and live site paths. One may be fustrated that when running their project off the IDE it will point them to someting like http://www.domain.com/www.domain.com/testfile.html or upload their files to a similar wrong location in FTP. Especially when trying to mirror the directory structures and names locally and on the server. With the proper setup this can be avoided.

This fake project will cover all the following situations:

  • You want some system files will be behind public web root.
  • You are using Dreamhost. (with some adjustments to the guide this can work for any host)
  • You are building a website for a domain you are temporarily pointing to a placeholder page or DNS isn’t setup for it.
  • You already have another working domain besides the new one that you want to run the development on.

The domain you have not purchased or setup will be called newdomain.com. The working domain will be the same way… devel.workingdomain.com.
If  your new domain is already setup on dreamhost you can use a subdomain devel.newdomain.com to hide your project.
If you already have your domain you can skip the mirror process.

  1. Login to you Dreamhost account
  2. Create a subdomain mirror to newdomain.com

Download NetBeans. Get the PHP version at the minimum.

You can replace devel.workingdomain.com with devel.newdomain.com if you need to.

  1. Create a new project with these settings
    • Run As Remote Web Site FTP
    • Project URL: http://devel.workingdomain.com/ (don’t forget the trailing slash)
    • Setup FTP connection by clicking Manage.
    • Upload Directory: / (a single forward slash)
      (the upload directory is not newdomain.com because the folder newdomain.com in your project will be uploaded into /.)
    • Upload Files setting Run / Manual is your preference.
  2. Delete the new index.php file
  3. Right-click on Source Files and create a new folder in the left pane called newdomain.com
  4. Create any folders you need under Source Files that will be outside of public. You can do this now or later when you are working on your project.
  5. Create a new PHP page under newdomain.com called index.php
  6. Go to File > Project Properties
    • Under sources change Web Root to newdomain.com
    • Under Run Configuration > Index File hit browse and select index.php under newdomain.com. You should see http://devel.workingdomain.com/index.php below the Arguments box

Now your files will upload to the correct directories behind and inside of the public folder. Also, your files behind root will be included in your NetBeans project. When you hit run it will open your browser to the temporary domain you have mirrored and run index.php.

Things to note:

You can configure these individually:

  • What local folder in your project is the web root
  • The live/devel project url
  • Your index file location
  • FTP upload directory

This gives you flexibility. Make sure you set your Web Root folder under Properties > Sources before choosing your Index File under Run Configuration.


Categorised as: Guides, Software


Leave a Reply

Your email address will not be published.