Index: src/webservice/CMakeLists.txt
===================================================================
--- src/webservice/CMakeLists.txt	(revision 16cceaa3078254d1ce5255c09bcc1498bedbd731)
+++ src/webservice/CMakeLists.txt	(revision 1c92d589185764978c35e1e7e1b04736bc39d9a7)
@@ -20,5 +20,12 @@
 ######################
 
-SET(WEBSERVICE_OUTPUT_DIRECTORY ${WEB_OUTPUT_DIRECTORY}/webservice)
+SET(WEBSERVICE_OUTPUT_DIRECTORY "${WEB_OUTPUT_DIRECTORY}/webservice")
+SET(WEBSERVICE_TEST_OUTPUT_DIRECTORY "${WEB_TEST_OUTPUT_DIRECTORY}/webservice")
+
+# switch Slim mode according to CMake debug mode
+SET(WEBSERVICE_MODE "production")
+IF(BUILD_DEBUG)
+	SET(WEBSERVICE_MODE "development")
+ENDIF(BUILD_DEBUG)
 
 # ADD_CUSTOM_COMMAND(
@@ -29,9 +36,42 @@
 # )
 
+CONFIGURE_FILE("config/config.php.in" "${WEBSERVICE_OUTPUT_DIRECTORY}/config/config.php")
+# workaround to copy "hidden" file .htaccess. copy command ignores it
+CONFIGURE_FILE("htaccess.in" "${WEBSERVICE_OUTPUT_DIRECTORY}/.htaccess")
+
 FILE(GLOB src_HTDOCS "htdocs/*.*")
-ADD_CUSTOM_TARGET(webservice ALL
+ADD_CUSTOM_TARGET(webservice-prepare ALL
 	COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/htdocs" "${WEBSERVICE_OUTPUT_DIRECTORY}"
 # 	DEPENDS "${WEBSERVICE_OUTPUT_DIRECTORY}/${STAFF_WSDL_FILE}"
-	COMMENT "Preparing webclient"
+	COMMENT "Preparing webservice"
 	SOURCES ${src_HTDOCS}
 )
+# ADD_CUSTOM_TARGET(webservice-install ALL
+# 	COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/htdocs" "${WEBSERVICE_OUTPUT_DIRECTORY}"
+# # 	DEPENDS "${WEBSERVICE_OUTPUT_DIRECTORY}/${STAFF_WSDL_FILE}"
+# 	COMMENT "Preparing webclient"
+# 	SOURCES ${src_HTDOCS}
+# )
+
+
+
+
+
+
+
+
+
+#######################
+#
+# PHPUnit tests
+#
+#######################
+CONFIGURE_FILE("testconfig/testconfig.php.in" "${WEBSERVICE_TEST_OUTPUT_DIRECTORY}/testconfig/testconfig.php")
+
+FILE(GLOB src_HTDOCS_TEST "tests/*.*")
+ADD_CUSTOM_TARGET(webservice-tests-prepare ALL
+	COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/tests" "${WEBSERVICE_TEST_OUTPUT_DIRECTORY}"
+# 	DEPENDS "${WEBSERVICE_OUTPUT_DIRECTORY}/${STAFF_WSDL_FILE}"
+	COMMENT "Preparing webservice tests"
+	SOURCES ${src_HTDOCS_TEST}
+)
Index: src/webservice/config/config.php.in
===================================================================
--- src/webservice/config/config.php.in	(revision 1c92d589185764978c35e1e7e1b04736bc39d9a7)
+++ src/webservice/config/config.php.in	(revision 1c92d589185764978c35e1e7e1b04736bc39d9a7)
@@ -0,0 +1,44 @@
+<?php
+/*
+    Copyright (C) 2015 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library 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
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+    MA 02110-1301  USA.
+*/
+
+$config = [
+	"version" => "@VERSION@",
+	"webserviceApiVersion" => "@WEBSERVICE_API_VERSION@",
+	"mode" => "@WEBSERVICE_MODE@",
+];
+
+function getConfig($key){
+	global $config;
+
+	if(!arraY_key_exists($key, $config)){
+		error_log("Expected config value ". $key ." does not exists");
+		return FALSE;
+	}
+	return $config[$key];
+}
+
+if(getConfig("mode") == "development"){
+	error_reporting(E_ALL);
+}
+
+set_include_path(get_include_path() . PATH_SEPARATOR . "../vendor/");
+require 'vendor/autoload.php';
+
+?>
Index: src/webservice/htaccess.in
===================================================================
--- src/webservice/htaccess.in	(revision 1c92d589185764978c35e1e7e1b04736bc39d9a7)
+++ src/webservice/htaccess.in	(revision 1c92d589185764978c35e1e7e1b04736bc39d9a7)
@@ -0,0 +1,25 @@
+######################
+#
+#    Copyright (C) 2015 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
+#
+#    This library is free software; you can redistribute it and/or
+#    modify it under the terms of the GNU Lesser General Public
+#    License as published by the Free Software Foundation; either
+#    version 2.1 of the License, or (at your option) any later version.
+#
+#    This library 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
+#    Lesser General Public License for more details.
+#
+#    You should have received a copy of the GNU Lesser General Public
+#    License along with this library; if not, write to the Free Software
+#    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+#    MA 02110-1301  USA.
+#
+######################
+
+# Requires AllowOverride All directive in your apache config
+RewriteEngine On
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteRule ^@WEBSERVICE_BASE_URL@ @WEBSERVICE_BASE_URL@/index.php [QSA,L]
Index: src/webservice/htdocs/404.html
===================================================================
--- src/webservice/htdocs/404.html	(revision 1c92d589185764978c35e1e7e1b04736bc39d9a7)
+++ src/webservice/htdocs/404.html	(revision 1c92d589185764978c35e1e7e1b04736bc39d9a7)
@@ -0,0 +1,8 @@
+<html>
+	<head>
+		<title>URL not found</title>
+	</head>
+	<body>
+		<h1>URL not found</h1>
+	</body>
+</html>
Index: src/webservice/htdocs/index.php
===================================================================
--- src/webservice/htdocs/index.php	(revision 1c92d589185764978c35e1e7e1b04736bc39d9a7)
+++ src/webservice/htdocs/index.php	(revision 1c92d589185764978c35e1e7e1b04736bc39d9a7)
@@ -0,0 +1,75 @@
+<?php
+/*
+    Copyright (C) 2015 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library 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
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+    MA 02110-1301  USA.
+*/
+
+include("config/config.php");
+
+function stations(){
+	$stations = Array();
+// 	$station = Array();
+// 	$station["id"] = "123456";
+// 	$station["name"] = "Station Name";
+// 	$station["longitude"] = 52.320;
+// 	$station["latitude"] = 48;
+// 	$station["city"] = "Krefeld";
+// 	$station["values"] = Array();
+// 	$station["values"][] = "temperature";
+// 	$station["values"][] = "humidity";
+// 	$station["url"] = "stations/". $station["id"];
+// 	$stations[] = $station;
+	echo json_encode($stations);
+}
+
+$app = new \Slim\Slim
+(
+	array
+	(
+		"mode" => "production"
+	)
+);
+$app->setName("siweather");
+
+// Only invoked if mode is "production"
+$app->configureMode('production', function () use ($app) {
+    $app->config(array(
+        'log.enable' => true,
+        'debug' => false
+    ));
+});
+// Only invoked if mode is "development"
+$app->configureMode('development', function () use ($app) {
+    $app->config(array(
+        'log.enable' => false,
+        'debug' => true
+    ));
+});
+
+// $app->notFound(function () use ($app) {
+//     $app->render('404.html');
+// });
+
+// $app->get("/stations", "stations");
+$app->get("/stations", "stations");
+$app->get("/stations/:uuid", function ($uuid){
+	echo "stations 123";
+});
+$app->run();
+
+?>
+
Index: src/webservice/testconfig/testconfig.php.in
===================================================================
--- src/webservice/testconfig/testconfig.php.in	(revision 1c92d589185764978c35e1e7e1b04736bc39d9a7)
+++ src/webservice/testconfig/testconfig.php.in	(revision 1c92d589185764978c35e1e7e1b04736bc39d9a7)
@@ -0,0 +1,30 @@
+<?php
+/*
+    Copyright (C) 2015 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library 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
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+    MA 02110-1301  USA.
+*/
+
+$testconfig = [
+	"webserviceUrl" => "http://localhost@WEBSERVICE_BASE_URL@/index.php",
+	"webserviceUrlRewrite" => "http://localhost@WEBSERVICE_BASE_URL@",
+	"webserviceApiVersion" => "@WEBSERVICE_API_VERSION@",
+];
+
+set_include_path(get_include_path() . PATH_SEPARATOR . "@WEB_TEST_OUTPUT_DIRECTORY@");
+require 'vendor/autoload.php';
+
+?>
Index: src/webservice/tests/TestStations.php
===================================================================
--- src/webservice/tests/TestStations.php	(revision 1c92d589185764978c35e1e7e1b04736bc39d9a7)
+++ src/webservice/tests/TestStations.php	(revision 1c92d589185764978c35e1e7e1b04736bc39d9a7)
@@ -0,0 +1,66 @@
+<?php
+/*
+    Copyright (C) 2015 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library 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
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+    MA 02110-1301  USA.
+*/
+
+class TestStations extends PHPUnit_Framework_TestCase
+{
+	protected $config;
+
+    protected function setUp()
+    {
+		$file = "webtests/webservice/testconfig/testconfig.php";
+		$this->assertFileExists($file);
+		require($file);
+		$this->config = $testconfig; 
+		$this->assertNotNull($this->config);
+    }
+
+	public function testEmptyStations()
+	{
+		$this->queryEmptyStationList($this->config["webserviceUrl"]);
+	}
+	
+	public function testStationRewrite()
+	{
+		$this->queryEmptyStationList($this->config["webserviceUrlRewrite"]);
+	}
+	
+	protected function queryEmptyStationList($url){
+		$this->assertInternalType('string', $url ."/");
+		$client = new GuzzleHttp\Client
+		(
+			[
+				"base_uri" => $url,
+				"timeout" => 2.0,
+			]
+		);
+		$response = $client->get("index.php/stations");
+		$this->assertNotNull($response);
+		$this->assertEquals($response->getStatusCode(), 200);
+		$this->assertEquals($response->getReasonPhrase(), "OK");
+
+		$body = $response->getBody();
+		$this->assertTrue(!empty($body));
+		$stations = json_decode($body);
+		$this->assertNotNull($stations);
+		$this->assertInternalType("array", $stations);
+		$this->assertEquals(count($stations), 0);
+	}
+}
+?>
