Getting started with PHP & liveExtensions

From bemoko developer wiki

Jump to: navigation, search

Introduction

The liveExtensions module provides a working demonstration of integrating bemokoLive with third party products. In particular this module demonstrates how bemokoLive can integrate with Quercus to allow you to build bemokoLive sites using PHP.

Step-by-step Getting started

Pre-requisites

Installation

  • Download liveExtensions from the bemoko download servers - see here for where you can download this from.
  • Copy the live-extensions-1.2.7.jar into the WEB-INF/lib directory of your bemokoLive install.
  • If you are not running bemokoLive on the Resin application server, for example you are running it on Tomcat then:
    • Download Resin 4.0.1 from Caucho.
    • Copy the lib/resin.jar from the Resin package into the WEB-INF/lib directory of your bemokoLive install.
  • Restart your application server, e.g. Tomcat

Using PHP in a bemokoLive site

  • Create a site called php in your sites directory
  • Copy your php.ini file into the conf directory of the php site
  • Create a file called php/ui/128/hello.php
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>bemoko hello</title>
	</head>
	<body>
		<div><?php echo "Hello, World";?></div>
	</body>
</html>

If you have installed everything correctly then you should see the text "Hello, World" displayed.

Developing bemokoLive Sites with PHP

UI Development

Note that PHP scripts are located in the uidirectories in the site directory. bemokoLive will pick the appropriate PHP script for the device based on the logic defined in the UI Configuration.

The output from the scripts will be processed as normal by the site tweakers.

Interacting with the bemokoLive APIs

The bemokoLive APIs are available via the implicit $bemoko PHP variable.

For example:

Get device attribute <?php $bemoko->getDevice()->get("width");?>
Get user profile <?php echo $bemoko->getUser()->getProfile();?>
Get intent parameter <?php echo $bemoko->getIntent()->get("page");?>

Further Reading