blob: febbfb9692179b55888a35f03e78a71b6b3152a1 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
-->
<html>
<head>
<title>NetBeans IDE PHP Quick Start Tutorial</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
<link rel="stylesheet" type="text/css" href="../../../netbeans.css">
<meta name="keywords" content="NETBEANS, TUTORIAL, GUIDE, USER, DOCUMENTATION">
<meta name="description" content="A very simple and quick introduction to the NetBeans IDE workflow by walking you through the creation of a
simple Hello World PHP application." >
</head>
<body>
<h1>NetBeans IDE PHP Quick Start Tutorial</h1>
<p>This document provides general guidelines for preparing the environment for PHP development, setting up a PHP project, and developing and running your first PHP application in the NetBeans IDE for PHP. </p>
<p><b>Contents</b></p>
<img src="../../../images_www/articles/73/netbeans-stamp-80-74-73.png" class="stamp" alt="Content on this page applies to NetBeans IDE 7.2, 7.3, 7.4 and 8.0" title="Content on this page applies to the NetBeans IDE 7.2, 7.3, 7.4 and 8.0" >
<ul><li><a href="#componentInstallation">Component Installation</a></li>
<li><a href="#setUpProject">Setting up a PHP project in the NetBeans IDE for PHP</a> </li>
<li><a href="#yurFirstPhpProject">Running Your First PHP Project</a></li>
<li><a href="#usingDBServers">Using Database Servers with NetBeans IDE for PHP</a></li>
<li><a href="#nextSteps">Next Steps</a></li>
</ul>
<p><b>To follow this tutorial, you need the following software and resources.</b></p>
<table>
<tbody>
<tr>
<th class="tblheader" scope="col">Software or Resource</th>
<th class="tblheader" scope="col">Version Required</th>
</tr>
<tr>
<td class="tbltd1"><a target="_blank" href="https://netbeans.org/downloads/index.html">NetBeans IDE</a></td>
<td class="tbltd1">PHP download bundle</td>
</tr>
<tr>
<td class="tbltd1">A PHP engine</td>
<td class="tbltd1">Version 5
</tr>
<tr>
<td class="tbltd1">A web server</td>
<td><a target="_blank" href="http://httpd.apache.org/download.cgi">Apache HTTP Server 2.2</a> is recommended.<br></td>
</tr>
<tr>
<td class="tbltd1">A PHP debugger</td>
<td><a target="_blank" href="http://www.xdebug.org">XDebug 2.0 or later</a></td>
</tr>
</tbody>
</table>
<p>
<!--
<h2><a name="configuringSoftware"></a>Required Software</h2>
<p>To create, run, and debug PHP projects you need the following software:</p>
<ul>
<li>The NetBeans IDE for PHP. Downloads are available <a href="
http://bits.netbeans.org/download/trunk/nightly/latest/">here</a>. </li>
<li>A web server. Typically development and debugging is performed on a local web server, while the production environment is located on a remote web server. The current version enables using a local server. Using a remote server with FTP access will be supported in future versions. PHP support can be added to a number of web servers (IIS, Xitami, and so on), but most commonly <a target="_blank" href="http://httpd.apache.org/download.cgi">Apache HTTP Server</a> is used. Click <a target="_blank" href="http://httpd.apache.org/docs/2.2/install.html">here</a> for information on how to install and configure Apache 2.2. <a target="_blank" href="http://httpd.apache.org/docs/2.2/install.html"></a></li>
</ul>
<ul>
<li>The PHP engine. The supported version is PHP5. Downloads are available <a target="_blank" href="http://www.php.net/downloads.php">here</a>. </li>
<li>The PHP debugger. The NetBeans IDE for PHP allows you to use <a target="_blank" href="http://www.xdebug.org">XDebug</a>, but using a debugger is optional. The recommended version is XDebug 2.0 as it is compatible with PHP5. </li>
</ul>
-->
</p>
<p class="tips">You can install the PHP engine, web server and database separately or use AMP (<strong>A</strong>pache, <strong>M</strong>ySQL, <strong>P</strong>HP) packages. </p>
<h2><a name="componentInstallation"></a>Installation and Configuration</h2>
<p>The following documents contain instructions for one or two ways to set up a PHP web stack on your operating system. These instructions are not definitive. The web stack consists of third-party software, your environment may differ, and you might prefer a different AMP package or another way to set up PHP. You might need to supplement our instructions with your own investigations.</p>
<ul>
<li><a href="configure-php-environment-windows.html">Configuring PHP Development Environment in Windows</a></li>
<li><a href="configure-php-environment-ubuntu.html">Configuring PHP Development Environment in the Ubuntu Linux Distribution</a> </li>
<li><a href="configure-php-environment-mac-os.html">Configuring PHP Development Environment in Mac Operating System (Mac OS X)</a></li>
</ul>
<h2><a name="setUpProject"></a>Setting up a PHP Project in the NetBeans IDE for PHP </h2>
<p>For help in installing and starting NetBeans IDE, please see the <a target="_blank" href="https://netbeans.org/community/releases/73/install.html">installation documentation</a>.</p>
<p>To start PHP development in the NetBeans IDE for PHP, you first need to create a project. A project contains the information on the location of the project files and the way you want to run and debug your application (run configuration).<br>
</p>
<ol>
<li>Start the IDE, switch to the Projects window, and choose File &gt; New Project.
The Choose Project panel opens. </li>
<li>In the Categories list, choose PHP. </li>
<li>In the Projects area, choose PHP Application and click Next. The New PHP Project &gt; Name and Location panel opens.
<br><img src="../../../images_www/articles/72/php/quickstart/new-project-name-location.png" alt="Name and Location panel of New PHP Project wizard, with Source Folder location as XAmpp document root." title="Name and Location panel of New PHP Project wizard, with Source Folder location as XAmpp document root." class="margin-around" ></li>
<li>In the Project Name text field, enter <tt>NewPHPProject</tt>.<br>
</li>
<li>In the Sources Folder field, browse for your PHP document root and create a subfolder there called <tt>NewPHPProject</tt>.
The document root is the folder where the web server looks for files to open in the browser. The document root is specified in the web server <a href="../../trails/php.html#configuration">configuration file</a>.
For example, on Xampp, the document root is XAMPP_HOME/htdocs.
</li>
<li>Leave all other fields with their default values. Click Next. The Run Configuration window opens.
<br><img src="../../../images_www/articles/72/php/quickstart/new-project-run-config.png" alt="Run Configuration panel of New PHP Project wizard, with default values chosen" class="margin-around" ></li>
<li>In the Run As drop-down list, select Local Web Site. The project will run on your local Apache server. Your other options are to run the project remotely via FTP and to run it from the command line.</li>
<li>Leave the Project URL at default. </li>
<li> Click Finish. The IDE creates the project. </li>
</ol>
Learn more about <a href="project-setup.html">Setting up a PHP project in NetBeans</a>.
<h2><a name="yurFirstPhpProject"></a>Running Your First PHP Project</h2>
<ol>
<li>Start the IDE, choose File &gt; Open Project. The Open Project dialog box opens.</li>
<li>Select <tt>NewPHPProject</tt> and click Open Project. The NewPHPProject tree appears in the Projects window and the project's <tt>index.php</tt> file opens in the editor and in the Navigator window. <br>
<img src="../../../images_www/articles/72/php/quickstart/getting-started-open-new-project.png" alt="NewPHPProject open in the IDE, showing index.php in editor" class="margin-around" border="1"></li>
<li>Enter the following code inside the <tt>&lt;?php ?&gt;</tt> block:
<pre class="examplecode"> echo "Hello, world! This is my first PHP project!";</pre>
</li>
<li>To run the project, position the cursor on the NewPHPProject node and choose Run from the context menu. The figure below shows what you should see in the browser window:<br>
<img src="../../../images_www/articles/72/php/quickstart/getting-started-browser-hello-world.png" alt="New PHP Project Panel with the fields filled in" class="margin-around" border="1"><br>
Congratulations! Your program works!</li>
</ol>
<h2><a name="usingDBServers"></a>Using Database Servers with NetBeans IDE for PHP</h2>
You can use various database servers
with the NetBeans IDE for PHP, although the most popular is the MySQL server. Downloads are available <a target="_blank" href="http://dev.mysql.com/downloads/mysql/5.1.html">here</a>. <br>
<strong>Note:</strong> The recommended version of the product is MySQL Server 5.0.<br>
See also:
<ul>
<li> <a href="../ide/install-and-configure-mysql-server.html">Setting Up the MySQL Database Server in the Windows Operating System</a> </li>
<li><a href="wish-list-lesson1.html">Creating a Sample Database with Test Data</a> </li>
<li><a href="../../articles/mysql.html">MySQL and the NetBeans IDE</a> </li>
<li><a href="../ide/mysql.html">Connecting to a MySQL Database</a> <br>
</li>
</ul>
<h2><a name="nextSteps"></a>Next Steps </h2>
<p>Meanwhile, to find information specific to the kind of applications you are developing, use the NetBeans IDE
learning trail for that type of application. Each learning trail contains a series of tutorials and
guides that range in scope from basic to advanced. The following
learning trails are available:</p>
<table width="100%">
<tr>
<td>
<ul>
<li><a href="../../trails/php.html">PHP Programming</a></li>
<li><a href="../../trails/java-se.html">Basic Java Programming</a></li>
<li><a href="../../trails/matisse.html">Java GUI Applications</a></li>
<li><a href="../../trails/web.html">Web Services Applications</a></li>
<li><a href="../../trails/java-ee.html">Java EE &amp; Java Web Applications</a></li>
</ul>
</td>
<td>
<ul>
<li><a href="../../trails/mobility.html">Mobile Applications</a></li>
<li><a href="../../trails/platform.html">NetBeans Plug-ins and Rich-Client Applications</a></li>
<li><a href="../../trails/cnd.html">C/C++ Applications</a></li>
</ul>
</td>
</tr>
</table>
<br>
<div class="feedback-box" ><a href="/about/contact_form.html?to=3&amp;subject=Feedback:%20PHP%20Quickstart">Send Feedback on This Tutorial</a></div>
<br style="clear:both;" >
<p>To send comments and suggestions, get support, and keep informed on the latest
developments on the NetBeans IDE PHP development features, <a href="../../../community/lists/top.html">join
the users@php.netbeans.org mailing list</a>.</p>
</body>
</html>