Content of this series:

The power of OData – Part 1 – Introduction

      The power of OData – Part 2 – Setting up the Environment (this part)

The power of OData – Part 3 – Creating a data Model

The power of OData – Part 4 – Creating an OData service

The power of OData – Part 5 – Consuming the service with SAPUI5

As already mentioned in the first part of this series (The power of OData – Part 1 – Introduction) I’d like to write about the usage of custom OData producers that can be combined with SAP Netweaver Gateway services or Sharepoint services to create even richer and better applications.

This post will deal with the initial setup of a development environment for developing own producers and services.As I wrote in another post about AIE (Trying new features and versions in Eclipse), I’m a fan of Eclipse. Therefore, I will use this as my basic IDE here to setup the needed tools. This also has the side-effect that I have all of my development tools in just one single IDE, as said within the mentioned blog post. You can for sure use other IDEs like Netbeans or just a plain text editor. So in the next lines, I will talk about choosing the needed Eclipse plugins, setting up a local web and database server and installing the OData producer SDK.

For this development example, I choose to use PHP. This is not a must; there exist SDK versions for Java, Python or .NET as well, but I feel that many organizations have their custom development, their web applications or services done in PHP in combination with MySQL.

Setting up a local webserver

My webserver of choice for local development is XAMPP available from ApacheFriends ( The main advantage is that it comes with a ready to use Apache installation that includes the newest PHP, MySQL as well as Perl, FileZilla, Mercury and Tomcat, if anyone needs this, so that Java development and hosting would be possible. Another advantage is that this package is available for all major operating systems: Windows, Linux and OS X. As I use OS X at home, this enables me to develop wherever I am with the same solution.

The installation process is straight forward. After a successful installation, a control center is available that lets us start and stop the individual services as well as access the config files with one click:

XAMPP Controll Panel.png

XAMPP Config Options.png

If we navigate to localhost using our favorite browser, we should see the XAMPP start page, after we started the Apache service.

XAMPP Welcome.png

From this site, we can access PHP info, phpmyadmin for managing MySQL or J2EE specific things:

XAMPP Menu.png

Lucky for us, XAMPP comes with a user-friendly configuration, so that not much has to be changed. There is one line that has to be added in Apache’s configuration, what will be shown in the next topic.

Installing the SDK

The OData Producer Library for PHP is available as an open source library from GitHub:

After downloading the contents of the package should be extracted to a newly created directory within the “htdocs” folder under the XAMPP installation directory, which normally is C:\xampp \htdocs\ (for Windows users).

For this test, I created a folder “customer_api” and placed the OData producer files in this location:

htdocs path.pnghtdocs content 1.png

Now, your service root is accessible through a browser by calling the URL http://localhost/customer_api

Let’s look at the content.

We don’t actually need Docs and Tests here, so we can get rid of them. Web.config can be deleted as well, as this is specific for Microsofts IIS and we are using Apache here.

htdocs content 2.png

Finally, we have library and services. Within the library folder are the sources that create the services and provide the output we consume later on. Within services are the main services stored, that can be accessed. Index.php and Dispatcher.php are used to redirect request to the specific services. More about creating and routing services will come in the development part of this series.

There is one last thing we need here. As I wrote, Index.php and Dispatcher.php should redirect the requests. So we have to rewrite the requests by using Apache’s mod_rewrite module. To activate this module, we have to edit http.conf.

Open this file within your favorite text edit and search for this line:

#LoadModule rewrite_module modules/

Remove the leading “#” to uncomment the line, save the config file and restart Apache.

Within the folder you created above, create a new file called “.htaccess”. This file will control access to the folder and will redirect every request that calls a <service.svc> to our Index.php that will handle the request.

Open the file in a text editor and insert the following content:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule (\.svc*) /customer_api/Index.php
php_value include_path ".;C:\xampp\htdocs\customer_api\library"

This simply redirects all requests ending in .svc to Index.php.

The last line will define an include_path only relevant for the current application. As we don’t need it elsewhere, you can insert it in this .htaccess file without the need of editing your php.ini, as I suggested in the previous version of this post. If you then go to http://localhost/customer_api, you should see a string saying “No configuration info found for”

I’ve also added my service.config.xml as there seems to be some problems with this.

Let’s move on to Eclipse to complete the environmental setup.

Installing Eclipse plugins

Whenever I start setting up my environment, I download a new basic Eclipse instance. I would recommend getting the newest Java EE edition from their download page:

In my case, this would be the following version:

Eclipse J2EE.png

Next would be the decision what languages we need and what we want to develop.

For this series, we will be developing PHP applications as well as UI5 applications. It might be worth thinking about integrating the ABAP development tools within our installation so that we have one single application ready for accessing different systems.

The update sites for SAP tools (ABAP dev tools and UI5 tools) is the following:

The site for Juno can be found at

From the options screen, choose these packages:

  • ABAP Development Tools for SAP NetWeaver
  • UI Development Toolkit for HTML5

PHP related plugins and add-ons can be found here what also is the URL to be used as update site in Eclipse. Here, I would recommend installing the following:

  • PDT Extensions
  • PHP Development Tools (PDT)
  • PHPUnit

The other plugins aren’t needed for this series, but may be worth some try, depending on the amount of PHP development that is done.

After the installation and restart of Eclipse, let’s import our OData project as a last step. Go to “FileàNewàProject” and choose “PHP Project”

new project 1.png

On the next screen, enter a project name and choose “Create project at existing location (from existing source)”. Enter here the path to the created folder in htdocs.

new project 2.png

Now click finish and your project is created. If you haven’t done yet, it is time to add the .htaccess file now. I think that Eclipse is better for editing this than a normal text editor.

new project 3.png

Continue to read the next part about creating the data model and some sample data for the service: The power of OData – Part 3 – Creating a data Model

To report this post you need to login first.


You must be Logged on to comment or reply to a post.

    1. Marc Augustin Post author

      Hi Paulo,

      at this stage, you should only get the message “No configuration info found for” in your browser. Your error looks like the service.config.xml can’t be found.

      In your customer_api directory, do you have a services directory in which a service.config.xml file exists?

      I’ve attached mine here, you can check if this one works, I don’t have problems with it, jsut did a clean install on a new laptop.

      Also, I added some advices above, if one might encounter class loading problems. Here is the new part:

      One final edit to php.ini. Open php.ini from your XAMPP console and search for “include_path”. You should find the following:

      include_path=”.;C:\xampp\php\PEAR” modify thiy line by adding the path to the library folder of the customer_api project. For me, the line looks like this after the edit:


      Paths must be seperated by ;

      I hope this helps, real output will be generated in part 4, until then, there won’t be much to see.


  1. Marc Augustin Post author

    Guys, I’ve just updated the post again and moved the “include_path” configuration inside the .htaccess file, so that you don’t have to touch your php.ini and remain a plain installation of XAMPP.

  2. Reinhard Weidner

    Hi Guys,

    everyone building this on a LAMP-System (Linux) and wondering why you always see the directory listing, you have to add

         Directoryindex Index.php

    to your apache default configuration since capitals are different characters in Linux

    index.php != Index.php!!!

    Other solution would be copy Index.php to index.php, but I prefer to keep the libraries clean.

    On Ubuntu it would be in /etc/apache2/sites-available/default

    example of my config

    <VirtualHost *:80>

         Documentroot     /srv/www

         Directoryindex     index.htm index.html index.php Index.php

    1. Marc Augustin Post author

      Hi Reinhard,

      thanks for pointing this out. Didn’t pay attention to the case-sensitivity of *nix systems, as I tested under Windows.

      That’s one point where the Microsoft origin of the libraries and protocols can be seen.


  3. Robert Mast

    As I wanted my oData-service to provide oData from a cheap LAMP-hostingprovider I looked for a way to get it done really simple and portable, starting from the tutorial above:

    Copy the following resulting files and directories to the root of your (sub)domain:

    • library
    • services
    • Dispatcher.php
    • Index.php

    Add the following line to Index.php, just before the ‘require_once’ at line 34:

    set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__).’/library’);

    make sure the file service.config.xml is in the services-subdirectory and modify it’s path on line 5 to get rid of the absolute reference and the confusing backslashes:


    Finally make sure your .htaccess in the root of your (sub)domain points to the service in the right way and add:

    <IfModule mod_rewrite.c>

    RewriteEngine on

    RewriteRule .*(\.svc*) /Index.php


    Directoryindex index.htm index.html index.php

    # the rest of your site on the domain will still function as usual as our special triggering Index.php contains a capitalized ‘I’, which is rather unusual for a unix-environment.


Leave a Reply