The Geany character sequence “%f” is substituted by the name of the current file without the path. The default path is the current project path.

PHP Index File

<?php
/*
* index.php
*
* Copyright 2013 edward <http://Ojambo.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
?>
<!DOCTYPE html>
<html xml:lang="en" lang="en">
<head>
<title>Ojambo.com Geany PHP Web Server Index</title>
<meta charset="utf-8" />
</head>
<body>
<h1><?php echo "This is the Index Page"; ?></h1>
<p><a href="tester.php">Tester Page</a></p>
</body>
</html>

The PHP code is embedded in the h1 HTML tags. If the document is a PHP file then PHP embedded code can be interpreted by a web server. The anchor link points to another PHP file called “tester.php”.

PHP Tester File

<?php
/*
* tester.php
*
* Copyright 2013 edward <http://Ojambo.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
?>
<!DOCTYPE html>
<html xml:lang="en" lang="en">
<head>
<title>Ojambo.com Geany PHP Web Server Tester</title>
<meta charset="utf-8" />
</head>
<body>
<h1><?php echo "This is the Tester Page"; ?></h1>
<p><a href="index.php">Index Page</a></p>
</body>
</html>

The PHP file is loaded as a new page. The PHP embedded code inside the h1 tags is interpreted by a web server. The anchor link points to a separate PHP file called “index.php”.

How To Use:

Open Browser For Speed

Build -> Execute.

Alternate method is to click the run icon in the toolbar or F5

Close terminal to close web server.

Ojambo.com Geany Execute Menu

Ojambo.com Geany Execute Toolbar

Demonstration:

Ojambo.com Geany PHP Web Server Tutorial

Ojambo.com Geany PHP Web Server Index

Ojambo.com Geany PHP Web Server Tester

Conclusion:

Geany is a powerful editor that has features only available in much larger IDEs. An important tool that PHP application developers need is project-specific execution. Each project can have custom menu labels and commands.

The build menu configuration for a project can override the system defaults. A new execute command can be created to use the PHP built-in web server and open in a web browser.

Recommendations:

Create projects for PHP web applications.

Override the default execution command in order to use the toolbar execute icon

Create a custom execute command if your will use non web-specific PHP code.

This entry was posted
on Wednesday, July 31st, 2013 at 12:00 am and is filed under Tips & Tricks.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.