X

An Oracle blog about NetBeans for PHP

  • News
    August 24, 2008

Prado Hello World Tutorial in NetBeans

In this thread some users of NetBeans PHP ask for a support for Prado framework. Because I haven't worked with this framework yet, I want to learn something more about Prado framework to find out what NetBeans could offer for developers, who build their web applications on top of this framework. The evaluation of the framework takes more time, this entry just shows, how to set up NetBeans to develop applications based on Prado framework.

I went through two tutorials (Hello World and Currency Converter) with using NetBeans. In this entry I will describe how you can create Hello Word application based on Prado framework in NetBeans.

At the beginning I downloaded Prado 3.1.2r2448 from the downloaded page. Then I created prado folder in document root of my Apache. Into the created prado folder I unzipped the content of  prado-3.1.2r2448 folder from the downloaded zip file. The picture on the right shows the folder structure in my document root.

Before creating new project in NetBeans I suggest to register files with the extensions .page as php files. In Options dialog select Miscellaneous category and in this category select Files tab. Click on the New... button and enter page as new extension. In the Associated File Type (MIME) combobox select PHP Files (text/x-php5).


Now I could create new project with name PradoHelloWorld. I placed the project directly into the document root. In the Project Properties dialog I extended the project PHP Include Path with prado/framework folder from the document root. As a result of this NetBeans offers classes and functions from Prado framework in code completion and also other functionalities can work with these files. If you develop only web application based on the Prado framework, you can extend the Global Inlcude Path in the Option dialog to have the Prado framework in the include path for every project automatically.

I changed the content of index.php file with:

<?php
require_once('../prado/framework/prado.php'); // include the prado script
$application = new TApplication; // create a PRADO application instance
$application->run(); // run the application
?>

As a next step I created folder protected and in this folder folders pages and runtime. The runtime folder is a folder, where Prado framework stores application runtime information, such as application state, cached data, etc. This directory must be writable by the Web server process. To achieve this I have just used command


chmod 777 PradoHelloWorld/protected/runtime

Then I created Home.page file in protected/page folder with the content:

<html><body><com:TForm><com:TButton Text="Click me" OnClick="buttonClicked" /></com:TForm></body>
</html>

and also file Home.php:

<?php
class Home extends TPage {public function buttonClicked($sender,$param) {// $sender refers to the button component$sender->Text="Hello World!";
}
}
?>

This is all. Now the HelloWorld tutorial is done. After invoking Run project action I can see the result.


I will continue in an entry about how to use prado-cli.php script and also what the possible support of Prado framework can do in NetBeans.

Join the discussion

Comments ( 14 )
  • n198 Monday, August 25, 2008

    tnx, very good!


  • Jens-Martin Tuesday, August 26, 2008

    Great post!

    Would love to see full support for PRADO in NetBeans!


  • Kevin Bond Wednesday, August 27, 2008

    Cool!

    Anybody make a Zend Framework project yet?


  • Petr Thursday, August 28, 2008

    Hi Kevin,

    are you asking about how to set up NetBeans with Zend framework? Or to have Zend framework support in NetBeans?

    Thanks,

    Petr


  • oi Friday, August 29, 2008

    Helo,

    Please not the framework plugins developing.

    I would like to use php support for netbeans, but javadoc is not work.

    So auto code completion is not work at oop programming, php support is unusable.

    So eclipse pdt is better than netbeans php support regrettably :(

    I think types, ex.:

    class cname {

    /\*\*

    @var ClassTypeName \*\*/

    private $someVariable;

    /\*\*

    \* @return ClassTypeName

    \*/

    public function getAnotherObject()

    {

    return $this->someVariable;

    }

    }


  • Petr Saturday, August 30, 2008

    Hi oi,

    thanks for your comments. In this moment this is a bug. We still didn't finished the first version, so I hope that the first release will not have this problem.

    Regards,

    Petr


  • Eirik Hoem Sunday, August 31, 2008

    Very interesting. I've been working with Prado for a few years now, and I recently got around to evaluating NetBeans 6.5 with PHP support. Having full support for Prado would be really nice.

    If there are any changes that needs to be made in Prado to have full support I'm sure the development team would be open for a discussion.


  • Petr Sunday, August 31, 2008

    Hi Eirik,

    thanks for your comment. It looks like you have big experience with Prado. Is it right?

    Regards,

    Petr


  • Kevin Bond Tuesday, September 2, 2008

    Hi Petr,

    I guess I am asking both questions, both ZF setup and support.

    -Kevin


  • Petr Tuesday, September 2, 2008

    Hi Kevin,

    I understand:). Write tutorial, how to set up ZF shouldn't be hard.

    There are requests to support this framework, other one etc. I'm going to clarify this situation in tomorrows entry.

    Thanks,

    Petr


  • Petr Wednesday, September 3, 2008

    Message for oi:

    The issue with defining type in the php doc for a class field is now fixed. http://www.netbeans.org/issues/show_bug.cgi?id=145692. I hope that it works for you.

    Thanks,

    Petr


  • Edward Amankwa Wednesday, February 4, 2009

    I have tried your tutorials and I get this error:

    Warning: require_once(../prado/framework/prado.php) [function.require-once]: failed to open stream: No such file or directory in C:\\wamp\\www\\PradoTest\\index.php on line 2

    Fatal error: require_once() [function.require]: Failed opening required '../prado/framework/prado.php' (include_path='.;C:\\php5\\pear') in C:\\wamp\\www\\PradoTest\\index.php on line 2


  • links of london Thursday, October 29, 2009

    It was a very nice idea! Just wanna say thank you for the information you have shared. Just continue writing this kind of post. I will be your loyal reader. Thanks again.


  • Sinner Sunday, January 3, 2010

    Hello.

    I'm pretty new in all of this...

    I done everything and get this result:

    //

    TPhpErrorException

    Description

    [Warning] Cannot modify header information - headers already sent by (output started at C:\\xampp\\htdocs\\pradoHelloWorld\\index.php:8) (@line 435 in file C:\\xampp\\htdocs\\prado\\framework\\Web\\THttpResponse.php).

    Source File

    C:\\xampp\\htdocs\\prado\\framework\\Web\\THttpResponse.php (435)

    0424: $this->sendHttpHeader();

    0425: $this->sendContentTypeHeader();

    0426: if($this->_bufferOutput)

    0427: ob_flush();

    0428: }

    0429:

    0430: /\*\*

    0431: \* Send the HTTP header with the status code (defaults to 200) and status reason (defaults to OK)

    0432: \*/

    0433: protected function sendHttpHeader ()

    0434: {

    0435: header("HTTP/1.1 {$this->_status} {$this->_reason}", true, $this->_status);

    0436: }

    0437:

    0438: /\*\*

    0439: \* Sends content type header if charset is not empty.

    0440: \*/

    0441: protected function sendContentTypeHeader()

    0442: {

    0443: $charset=$this->getCharset();

    0444: if($charset==='' && ($globalization=$this->getApplication()->getGlobalization(false))!==null)

    0445: $charset=$globalization->getCharset();

    0446: if($charset!=='')

    0447: {

    Stack Trace

    #0 [internal function]: PradoBase::phpErrorHandler(2, 'Cannot modify h...', 'C:\\xampp\\htdocs...', 435, Array)

    #1 C:\\xampp\\htdocs\\prado\\framework\\Web\\THttpResponse.php(435): header('HTTP/1.1 200 OK', true, 200)

    #2 C:\\xampp\\htdocs\\prado\\framework\\Web\\THttpResponse.php(424): THttpResponse->sendHttpHeader()

    #3 C:\\xampp\\htdocs\\prado\\framework\\Web\\THttpResponse.php(414): THttpResponse->flushContent()

    #4 C:\\xampp\\htdocs\\prado\\framework\\TApplication.php(1102): THttpResponse->flush()

    #5 C:\\xampp\\htdocs\\prado\\framework\\TApplication.php(376): TApplication->flushOutput()

    #6 C:\\xampp\\htdocs\\pradoHelloWorld\\index.php(11): TApplication->run()

    #7 {main}


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.