5 minutes starter guide

Preperation

First prepare your maven settings. Follow the instructions from the instruction from the opencube page .
Than follow the 5 minutes starter guide (for PHP 5) from php-maven webpage.
Create a new eclipse project and point the basedir to the created maven project.
Open your pom and add following dependencies.


<dependencies>
...
	<dependency>
		<groupId>org.opencube</groupId>
		<artifactId>phpcube-php5</artifactId>
		<version>1.0</version>
	</dependency>
	<dependency>
		<groupId>org.opencube</groupId>
		<artifactId>config-default</artifactId>
		<version>1.1</version>
	</dependency>
....
</dependencies>

Run "mvn compile".
Than add following include path to your src/main/webapp/index.php
set_include_path('../php'.PATH_SEPARATOR.'../../../target/phpinc');
So now the preparation is ready. We still have to point our webserver configuration to the webapp folder of our project.

Sample phpCube

So now we load our first phpCube document.
To create an phpCube document you have to create two folder under "src/main/php/" "myapp/designs". "myapp" is the application namespace folder and can be differnt. The designs folder is a phpCube convention. We will call our phpCube template "hellophpcube.htm".


<cube:stylesheet>
	<html>
		<body>
			Hello phpCube
		</body>
	</html>
</cube:stylesheet>

To load that phpCube template edit the index.php and replace the exisiting code with:

<?php
set_include_path ( '../php' . PATH_SEPARATOR . '../../../target/phpinc' );
require_once str_replace ( '.', '/', 'org.sample' ) . '/app.php';
require_once ('cube/controller.php');
$page = new cube_page ( 'sample project', $_REQUEST );
$file = "org/sample/myapp/designs/hellophpcube.htm";
$page->loadFile ( $file, 1 );
echo $page->transform();
?>

Now just load the index.php in your browser and you should see "Hello phpCube".

What have I just done?

Congratulations, you just created your first phpCube project! You created a Template (in phpCube known as cubeStylesheets) and loaded it in your index.php.