Setting up a PHP project

From Asterix HTML
Jump to navigation Jump to search

See NetBeans IDE PHP Quick Start Tutorial for more.

PHP Application

To start setting up a PHP project...

Inside NetBeans, you'll see a, "Projects" tab...
Inside this tab, right click and hit, "New Project..."
Then on the frame that open up, select "PHP"...
Then click on "PHP Application"...

The other options you see here, such as PHP Application with Existing Sources would also interest you, but lets keep this simple for now ....one simple step at a time, where you and me stay on the same page

After clicking on "PHP Application", click on, "Next" to get to New PHP Project

Name and Location

Each of you will fill in your own Project name in here, for example, Fox.Asterix.co.za

Sources Folder

There's something filled in here that you probably do not want to fiddle with!- unless you really know what you're doing on a computer and that you have a clear vision of what data files you want stored where!

The nice thing about NetBeans is that once you've decided to put a project somewhere on your computer, it stays there! ....with all the bits and pieces that you'll want to add!- such as images and recordings and more web pages, etc etc

So, bottom line, rather don't fiddle with what, "Sources Folder" is set to!

PHP Version

Leave this set to, PHP 7.0. If and when I start to teach you PHP, you need to be sure that I have set your subdomain server, on the Internet, to deliver PHP 7 to your web pages.

If I get this wrong on the server side, the PHP work you do might not work properly!

Default Encoding

UTF-8 is fine. Don't change that. This is rocket-science stuff waiting for you to discover AFTER I have finished a year with you!

Put NetBeans metadata into a separate directory

Leave this as it is .....no tick here!

Just leave the metadata to do what it wants. This is more rocket-science waiting for later, after I've finished a year with you! You'll find this in the world I'm taking you into. If you see something, rather don't touch!- unless I tell you to!

Now let's click, "Next" and see what happens...

Run Configuration

....needs to be very carefully set! There is a bit of work coming up for you here!- so do not rush through this!

Run As

Set this to, "Remote Web Site (FTP, SFTP)"

Be sure to be sitting down and all strapped in! This is where you see the magic that replaces your need of something like FileZilla! This is where you are going to point your NetBeans PHP project to your own place on the Internet!

NOTE: Don't fuss about this being a, "PHP project"! PHP is backwards compatible with HTML!- so all I am doing here is making sure that if and when I start to teach you PHP, you don't need to make any changes to your NetBeans project!

Project URL

Set this to your own URL, for example, [1]

Remote Connection

You need to manage your remote (FTP) connections. This is where you set setup and test your remote connections, and then ensure you have the correct connection associated with your project

To ensure that you have the right FTP access codes connected to this PHP project, click on, "Manage" (on the line that says, "Remote Connection"). You'll have the, "Manage Remote Connections" panel in front of you.

Manage Remote Connections

This part is interesting and potential tricky, so do not rush and keep your wits about you!

  • Be sure to have your FTP access codes on hand!- the FTP username and password that I gave you for FileZilla! You'll need that same information here!
  • Once you have told your project that it runs as a remote website, you have to ensure that you have the right FTP access codes connected to this PHP project.

Click, "Add.." to get the, "Create New Connection" panel to pop up....

Fox, I want to set the, "Connection Name" (in your case) to, "fox.asterix.co.za"

This is the same as your subdomain name and I'd like you to look at the style I am using here- all lower case and just the basic domain name without "http://" at the start or "/" at the end. It is not critical you follow this style of naming your FTP connections, but this is the way I want you to do for now!

Leave the, "Connection Type" set to, "FTP" and click OK

Getting your connection to work

Now you are in a place where you get to mess around with your FTP access codes, trying to do things like remember your username and password, and get a number of other settings right

  • Hostname : Your subdomain name- for example, "fox.asterix.co.za"
  • Username : The same FTP username I gave you for FileZilla
  • Password : The same FTP password I gave you for FileZilla
Be sure to press the, "Test Connection" button to make sure your connection works!
If you connection does not work, that there is something wrong with your access codes.

NOTE : This is where you build up your collection of FTP connections, when you are working with more than one website. For example, this is where I will have a set of keys for each of you, so that I'll be able to access any of your websites, if-and-when I need.

WARNING : You must see, "Connection succeeded" when you test!

Now let's look at some of the other settings on this panel....

Timeout

I like to push this up from 30 seconds to 200 seconds! Sometimes out Internet is slow in South Africa and I am hosting your domains somewhere between California and Virginia! And don't forget we have an undersea Internet cable to South Africa that might not be working properly

Initial Directory

This is a tricky one to get right!. Let's leave this as just, "/" for now, and see if we need to come back to fix this later.

Now press, "OK" to get back to panel that is called, "New PHP Project"

New PHP Project (continued)

Don't rush, there are still settings to look at here!

The first thing you must do is ensure that the, "Remote Connection:" is now pointed to the right place

Upload Directory

Remove whatever you see there, leave just the, "?" ...this is also a tricky setting, that we might need to come back to later

Upload Files

Think about this one! CAREFULLY!

I like to set, Upload Files: to, On Save, but that's because I have more data than I know what to do with! On Save is telling my NetBeans that every time I hit Ctrl-S (or find and click the, "Save" button!), NetBeans will immediately synchronize whatever I am working on with my website on the Internet!

This is a very clean way of working, where your website that is live on the Internet, is keeping up with you ....every single step of the way!

.... OR ....

If you are trying to save a bit of data, then leave Upload Files: set to, On Run. This will tell NetBeans to only synchronize all your local work, with your website on the Internet, when you press,"Run"

This is not such a clean way of working. Sometimes this is confusing. It's almost like working the way you were before (with Notepad and FileZilla), where you first edit in one place, and then have to remember to upload all your work later

At least you have an option! If you have enough data, use the, On Save option

Besides, the files you are going to be working with are not all that big .....just a couple of kilobytes per HTMP page perhaps. Other big files, like images, you don't go changing them every day, do you now!?

Right, this is where it's safe to hit, "Finish" ....but, just for fun, let's see what pops up when we hit, "Next" instead!

PHP Frameworks

Just all sorts of rocket-science stuff we don't need! So just hit, "Next" again....

Composer

More stuff you don't need! Let's just hit, "Finish" like I said we could!

All done!

If you did everything right, your very first PHP project for HTML is up!

Main Page | Basic web design | Navigation | Ranking | Support | Asterix Home