PHP Project with Aptana Studio

Hello everybody.

Today I am going to show you how you can start a php project with aptana studio.

Aptana Studio is an open source integrated development environment (IDE) for building Ajax web applications. It includes support for JavaScript, HTML, DOM, and CSS with code-completion, outlining, JavaScript debugging, error and warning notification and integrated documentation. Additional plugins allow Aptana Studio to be extended to support Ruby on Rails, PHP, Python, Perl, Adobe AIR, Apple iPhone and Nokia WRT (Web Runtime). Aptana Studio is based on Eclipse and is available as standalone on Microsoft Windows, Mac OS X and Linux, or as a plug-in for Eclipse. [1]

You can download Aptana studio from http://aptana.com/

Now lets get started. I am not going to build something huge in this tutorial. Let us consider the following requirement.

In this tutorial, there will be a page where user will be asked to give his name, there will be a send button also. After pressing the send button, the line “Hello <user name> to php tutorial”. Note that there will be one page, not more then one page.

Easy,dah ….

I hope you have downloaded aptana studio. So why not you just open aptana studio and see what is it really!

I hope you are seeing the following window:-

Well, so lets create a project.

Open File -> New -> Project

Now you will get a wizard. From here select php project.

Ok then, why are you waiting? Click next. J

Now you are asking to give a project name. so let we give it php_tutorial_2 .

Lets see, there is a default path. But we need to store our project in www path, or our local server (which we installed in the last post) will not get it.

So point the location to your wwwroot path. Check out the check box and set the location by your self.

(no,aptana is not dumb, he can give you a lot more flexibility which I will discuss with you later.)

Well, click finish then.

Now in left panel, go to application explorer.

(why master ???? I made a git repository in the last post, remember! Aptana has build in git support J )

In the white blank space in application explorer, click right button. Point to new from template, then point php, and then PHP Template. Just like the picture below.

Now select the project we are working on, and then give the file name index.php. (don’t give the last dot J just kidding ! )

Click finish and we got a php file with …. phpinfo() ??????? L

Remove phpinfo() . but don’t remove the php tag. We will need it. (Actually, I place most of my php code in top, if and only if I don’t have another good option. Usually I take the php code in another file and call the necessary variable and objects from there. But we will go for it later, won’t us? J)

Now we need to add a textbox where user can give his name. as requirement says, so let us make a form.

<?php

?>

<html>

    <head>

        <title>PHP Tutorial 2</title>

    </head>

    <body>

        <form method=“post”>

            Enter your name: <input type=“text” name=“name” />

            <br/>

            <input type=“submit” value=“send”/>

            

        </form>

        

    </body>

</html>

Open your web browser and open the php page (not directly, using localhost, my one is http://localhost/project/php_tutorials/php_tutorial_2/) and I hope you will see something like

Please don’t tell me about the design, I am a very bad designer.

Anyways, we will take the design issue later. What happens when you click on the button? Why not you give a try?

Now it is coding time. Our form uses post method, so we can get the value from $_POST variable. The predefined $_POST variable is used to collect values from a form sent with method=”post”.

Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send.[2]

Lets recode the page,

<?php


if ($_POST)

{

    echo
“Hello “. $_POST[‘name’].
” to php tutorial<br/>”;

}

?>

<html>

    <head>

        <title>PHP Tutorial 2</title>

    </head>

    <body>

        <form method=“post”>

            Enter your name: <input type=“text” name=“name” />

            <br/>

            <input type=“submit” value=“send”/>

            

        </form>

        

    </body>

</html>

Here I am using a if condition to look that $_POST exist or not, and if it exists, I will echo the text in there. Note that the text input in form has a name=”name” , so we will get its value from $_POST[‘name’].

Just see the page in your browser then. J

There are a lot of thing we will do in the future….. with php of course J

(to commit the code to github, assume you done all completely on the last post, see the workspace tab in the left, next to application explorer. Right click on your project, then click team, then commit first, and the last one will be push. I will write more details in future.)

Good night everybody J

Reference:

[1] Aptana Wikipedia page http://en.wikipedia.org/wiki/Aptana#Aptana_Studio

[2] w3schools (one of my favorites) http://www.w3schools.com/php/php_post.asp

Advertisements

5 thoughts on “PHP Project with Aptana Studio

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s