Introduction

Let's talk about everything we put at your disposal !

Overview

The webservices (WS) AppsPanel are available in version 4 since November 2015.

They offer a REST API (GET, POST, PUT, PATCH, DELETE, ... and customized protocols) and can be used on the command line.

Their operation relies on a PHP 5.6 architecture, based on the use of namespaces and inheritance.

This API relies in particular on the use of databases MySQL 5.5.49 and MongoDB, virtual machines using Node.js, Redis or even beanstalkd.

This page gathers your application's environment information (storage, configuration file, url, domains, etc.).

Storage of data

Below are the different ways you can store data in any form.

Available directories

APPLICATION REPOSITORY : contains files and directories for of your applications.

DATA REPOSITORY : This directory is empty by default. It allows to store files uploaded by the application on the server.

📘

Note

These 2 directories are accessible in FTP via the identifiers you have received by email.
They are also accessible within the application via methods, see Config section.

Mysql

Your data is stored in a database that is dedicated to your application, the database will be named ap_[app_name]_[environment].

📘

Note

The database contains generic tables useful for the proper functioning of the application. For more information, see Mysql section.

MongoDB

A MongoDB database is also at your disposal.

For more information on how to access and use it, see MongoDB section.

Architecture of a project

Versioning

You can use versioning for web services.
First of all you need to create a new directory in the "app" folder that will be called
'v[your-version]' example : "v2".

And you will need to move the "modules" folder to the new version directory.

  • classes
  • app
    • modules
    • v2
      • modules

You will need to change the config in the app.xml in the root folder of the application by adding a new tag like so:

<app>
	<versions>
		<version>
			<app>1</app>
			<ws>2</ws>
		</version>
	</versions> 
</app>

The "ws" tag refers to the version of your web services.

You will also need to refresh the cache configuration of your app in the Apps Panel Back Office for versioning to work.
To do so, you need to go to the parameters page then to the Cache configuration page and click on "Reload the configuration of my application".

Urls available

All urls are in https.
Your urls are unique and are directly related to your application :

  • [app_name].apnl.ws : roots of webservices
  • [app_name].apnl.ws/website : access to the client's website
  • [app_name].appspanel.mobi : mobile version of the presentation site (Prez Apps)
  • [app_name].appspanel.mobi/dl : access to application download links
  • [app_name].appspanel.info : web version of the presentation sheet of the app [app_name]. (on which we will also find the links of dl by making / dl think about the deactivation or protection during the putting in prod!)
  • d.[app_name].apnl.ws : url to recup the data stored in DATA REPOSITORY
  • sdk.[app_name].apnl.ws : url webservice "core", sdk appspanel
  • stats.[app_name].apnl.ws : ws of app stats
  • iac.[app_name].apnl.ws : the IAC of the app

Create a project

If you already have access to the Apps Panel Back Office, just under your profile section there is a "Manage My Apps" link.
This link will give you a listing of applications you already have access to but also the possibility of creating a new one.

You need to choose an application name and you can decide if you want a multi-environment application.
It basically means that you're application repository will contain three branches for developpment (Dev, Qa and Prod).

You will received a confirmation email containing all necessary information and a link to the Github project.

Once you cloned your application repository, we strongly advised you to see Project Architecture.

First webservice

If you have already created and cloned your project repository, you are ready to create your first web service.

First of all you will need to create a new PHP class/file in the app/modules directory like so :

  • classes
  • app
    • modules
      • FirstClass.php

Example of class :

<?php

namespace App\Modules;

use \Lib\Controller\WSController;


class HelloWorld extends \Modules\Elements
{

    /**
     * @param WSController $controller
     * @param array $params get parameters
     * @return array|string
     */
    public static function get(WSController $controller, $params = array())
    {
        return 'hello world !';
    }
}

This webservice is available on :


GET /helloworld HTTP/1.1
Host: your_project-your_env.apnl.ws
X-AP-Key: your_ap_key
X-AP-Deviceuid: test

Once your new class is created, you will need to declare PHP tags and the namespace you are in which at this point will be App\Modules.

You can also declare new directories in the "modules" folder as long as you declare the right namespace in your PHP classes.

Apps Panel uses Restful web services and method naming needs to follow http methods (get, post, put, patch, delete). Methods visibility needs to be public.

Here's the list of required headers in order to make your api calls functional :

  • X-AP-Deviceuid (It's the client device uid).
  • X-AP-Key (Which is your application key that can be found in your application configuration file).

Default response format is in XML but you can change that to JSON with the "accept" header set to "application/json".