An open API service indexing awesome lists of open source software.

https://github.com/toptalent-23/cpanel-php-server

cPanel-PHP-server is a Backend-as-a-Service(BaaS) designed for those who don't want to pay for 3rd party servers and want to host on their cPanel or any Apache server.
https://github.com/toptalent-23/cpanel-php-server

cpanel php server

Last synced: 9 months ago
JSON representation

cPanel-PHP-server is a Backend-as-a-Service(BaaS) designed for those who don't want to pay for 3rd party servers and want to host on their cPanel or any Apache server.

Awesome Lists containing this project

README

          

# cPanel-PHP-server

cPanel-PHP-server is a Backend-as-a-Service(BaaS) designed for those who don't want to pay for 3rd party servers and want to host on their cPanel or any Apache server. The purpose of developing this to speed up my development for mobile apps / angular apps for storing data to the database. Consider this a simple and lite version of firebase or parse server.

# Features!

- Manage Applications.
- Domain & IP whitelisting for application api requests.
- Stats for application api requests usages.
- table-based data storage using MySQL.
- OData Syntax for $select, $orderby, $filter, $skip, $top ($filter do not support functions such as contains or startWith. to use the contains use * e.g. $filter=col * mytext)

### Tech

cPanel-PHP-server uses minimum PHP 7.3 & MySql.

### Installation

cPanel-PHP-server designed to use with ease no complicated installation is required. Just copy all the files and folder to your htdocs/public folder and copy the .htaccess file on your site root folder and then create an empty MySQL database and create a user with all the permission for the database.

After that, open the config.php and change the MySQL database details and that's it!

## API Usages

cPanel-PHP-server v1.0.0

> Scroll down for code samples, example requests and responses.

Base URLs:

* http://your-domain.com/api
* https://your-domain.com/api

Generate Key for Admin API calls

> Enter the url in your browser http|s://your-domain.com/keys/gen This will generate the unique key for your server only to manage the admin-related calls.

Apps

APIs for managing the apps

## Get All Applications

> Code samples

``` shell
# You can also use wget
curl -X GET http://your-domain.com/api/admin \
-H 'Accept: application/json' \
-H 'x-api-key: string'

```

`GET /admin`
*Get All Applications*

Parameters

|Name|In|Type|Required|Description|
|---|---|---|---|---|
|Accept|header|string|true|none|
|x-api-key|header|string|true|none|

> Example responses

> 200 Response

``` json
[
{
"id": "1",
"name": "My First BaaS app",
"description": "this is a test",
"app_key": "b33428f9-aa0d-456d-a87d-fa37c7e1b1f8",
"app_api_slug": "baas-app",
"cors": [
{
"id": "1",
"application_id": "1",
"domain": "your-whitelisted-domain.com",
"ip_address": ""
},
{
"id": "2",
"application_id": "1",
"domain": "my-domain.com",
"ip_address": ""
},
{
"id": "3",
"application_id": "1",
"domain": "",
"ip_address": "192.168.0.1"
}
]
}
]
```

Responses

|Status|Meaning|Description|Schema|
|---|---|---|---|
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Returns the JSON array with a collection of registered applications in the system|None|

## Update an existing application

> Code samples

``` shell
# You can also use wget
curl -X PUT http://your-domain.com/api/admin?id=1 \
-H 'Content-Type: application/json' \
-H 'x-api-key: string'

```

`PUT /admin`
*Update Application*

> Body parameter - NOTE: you don't need to pass the the whole object except those properties you want to update.

``` json
{
"description": "this is a test",
"cors": [
{
"domain": "domain1.com",
"updateWith": "domain4.com"
},
{
"ip_address": "127.0.0.1",
"updateWith": "192.168.0.1"
}
]
}
```

Parameters

|Name|In|Type|Required|Description|
|---|---|---|---|---|
|id|query|integer(int32)|true|none|
|Accept|header|string|true|none|
|x-api-key|header|string|true|none|
|body|body|[UpdateApplicationRequest](#schemaupdateapplicationrequest)|true|none|

> Example responses

Responses

|Status|Meaning|Description|Schema|
|---|---|---|---|
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|none|None|

``` json
{
"message": "Application updated"
}
```

## Create Application

> Code samples

``` shell
# You can also use wget
curl -X POST http://your-domain.com/api/admin \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'x-api-key: string'

```

`POST /admin`
*Create Application*

> Body parameter

>

NOTE: "cors" is an optional property. If you do not want to whitelist, do not include "cors" in the body.

``` json
{
"name": "My First BaaS app",
"description": "this is a test",
"app_api_slug": "baas-app",
"cors": [
{
"domain": "your-whitelisted-domain.com",
},
{
"domain": "my-domain.com",
},
{
"ip_address": "192.168.0.1"
}
]
}
```

Parameters

|Name|In|Type|Required|Description|
|---|---|---|---|---|
|Accept|header|string|true|none|
|x-api-key|header|string|true|none|
|body|body|[CreateApplicationRequest](#schemacreateapplicationrequest)|true|none|

> Example responses

> Returns the message and api key for the newly created application. You have to pass g-api-key in the header to manage the store.

``` json
{
"message": "Application was created.",
"g-api-key": "c41bc073-c613-44d3-8bc3-9aac3392a1dd"
}
```

Responses

|Status|Meaning|Description|Schema|
|---|---|---|---|
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Returns the message and api key for the newly created application. you have to pass g-api-key in the header to manage the store.|None|

## Delete an existing application

> Code samples

``` shell
# You can also use wget
curl -X DELETE http://your-domain.com/api/admin?id=1 \
-H 'Accept: application/json' \
-H 'x-api-key: string'

```

`DELETE /admin`
*Delete Application*

Parameters

|Name|In|Type|Required|Description|
|---|---|---|---|---|
|id|query|integer(int32)|true|none|
|Accept|header|string|true|none|
|x-api-key|header|string|true|none|

> Example responses

Responses

|Status|Meaning|Description|Schema|
|---|---|---|---|
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|none|None|

``` json
{
"message": "Application Deleted"
}
```

Stores

>

This is where you can insert/update/delete/get your store data. Please keep in mind that when creating the app, whatever the app-api-slug you have passed will update the .htaccess accordingly, and you can access your store using the same. E.g. http://your-domain/api/{app-api-slug}/{storename} (http://your-domain/api/adeels-app/dev-store1). Please NOTE that {store_name} can be anything you want to call your store. This will generate the table in MySQL with a prefix of app-api-slug_storeName

>

This is table-based storage using MySql. This creates a new table for each store along with your app api slug, e.g. baas-app_myStoreName


>

You do not need to create the schema; upon the first record insert, it will determine the values data type and create the table and columns according to it. Please do not use spaces or any special characters in the json property name except underscores.
For the complex type, it does support array and object in the payload, and the system will generate that column as a JSON column and store the data in JSON format. For a better understanding please take a look at the request samples I've included below.

## Store - Insert Record

> Code samples

``` shell
# You can also use wget
curl -X POST http://your-domain.com/api/baas-app/dev-store1 \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'g-api-key: string'

```

`POST /{app-api-slug}/{any-thing}`
*- Insert Record*

> Body parameter

``` json
{
"string_col": "adeel",
"int_col": 1233232,
"long_string_col": "adasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadad",
"bool_col": true,
"double_col": 10.23,
"array_col": [
1,
2,
3
],
"array_col_object": [
{
"n1": "v1"
},
{
"n1": "v2"
},
{
"n1": "v3",
"n2": "bv1"
}
],
"object_col": {
"person": "adeel",
"email": "someemail@email.com"
},
"date_time_col": "2020-08-16T15:03:00.000Z"
}
```

Parameters

|Name|In|Type|Required|Description|
|---|---|---|---|---|
|Accept|header|string|true|none|
|g-api-key|header|string|true|When you have created the new app, it should have a return response along with g-api-key|
|body|body|JSON|true|none|

> Example responses

Responses

|Status|Meaning|Description|Schema|
|---|---|---|---|
|201|[Created](https://tools.ietf.org/html/rfc7231#section-6.3.1)|none|None|

``` json
{
"message": "record inserted",
"record_id": 1,
"status": true
}
```

## Generic-GetSingleRecordsWithCustomColumns

> Code samples

``` shell
# You can also use wget
curl -X GET http://your-domain.com/api/azeem/members/2?cols=string \
-H 'Accept: string' \
-H 'g-api-key: string'

```

`GET /azeem/members/2`
*Generic - Get Single Records With Custom Columns*

Parameters

|Name|In|Type|Required|Description|
|---|---|---|---|---|
|cols|query|string|true|none|
|Accept|header|string|true|none|
|g-api-key|header|string|true|none|

> Example responses

Responses

|Status|Meaning|Description|Schema|
|---|---|---|---|
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|none|None|

Response Schema

This operation does not require authentication

## Generic-UpdateRecord

> Code samples

``` shell
# You can also use wget
curl -X PUT http://your-domain.com/api/azeem/members/2 \
-H 'Content-Type: application/json' \
-H 'Accept: string' \
-H 'g-api-key: string'

```

`PUT /azeem/members/2`
*Generic - Update Record*

> Body parameter

``` json
{
"string_col": "Adeel Rizvi",
"int_col": 12334567,
"long_string_col": "this is a long string",
"bool_col": false,
"object_col": {
"person": "Adeel Rizvi",
"email": "someemail@email.com"
}
}
```

Parameters

|Name|In|Type|Required|Description|
|---|---|---|---|---|
|Accept|header|string|true|none|
|g-api-key|header|string|true|none|
|body|body|[Generic-UpdateRecordRequest](#schemageneric-updaterecordrequest)|true|none|

> Example responses

Responses

|Status|Meaning|Description|Schema|
|---|---|---|---|
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|none|None|

Response Schema

This operation does not require authentication

## Generic-DeleteSingleRecord

> Code samples

``` shell
# You can also use wget
curl -X DELETE http://your-domain.com/api/azeem/members/2 \
-H 'Accept: string' \
-H 'g-api-key: string'

```

`DELETE /azeem/members/2`
*Generic - Delete Single Record*

Parameters

|Name|In|Type|Required|Description|
|---|---|---|---|---|
|Accept|header|string|true|none|
|g-api-key|header|string|true|none|

> Example responses

Responses

|Status|Meaning|Description|Schema|
|---|---|---|---|
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|none|None|

Response Schema

This operation does not require authentication

## Generic-GetAllRecords

> Code samples

``` shell
# You can also use wget
curl -X GET http://your-domain.com/api/azeem/members/all \
-H 'Accept: string' \
-H 'g-api-key: string'

```

`GET /azeem/members/all`
*Generic - Get All Records*

Parameters

|Name|In|Type|Required|Description|
|---|---|---|---|---|
|Accept|header|string|true|none|
|g-api-key|header|string|true|none|

> Example responses

Responses

|Status|Meaning|Description|Schema|
|---|---|---|---|
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|none|None|

Response Schema

This operation does not require authentication

## Generic-TruncateStore

> Code samples

``` shell
# You can also use wget
curl -X DELETE http://your-domain.com/api/azeem/members/all \
-H 'Accept: string' \
-H 'g-api-key: string'

```

`DELETE /azeem/members/all`
*Generic - Truncate Store*

Parameters

|Name|In|Type|Required|Description|
|---|---|---|---|---|
|Accept|header|string|true|none|
|g-api-key|header|string|true|none|

> Example responses

Responses

|Status|Meaning|Description|Schema|
|---|---|---|---|
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|none|None|

Response Schema

This operation does not require authentication

## Generic-DeleteStore

> Code samples

``` shell
# You can also use wget
curl -X DELETE http://your-domain.com/api/azeem/members/storage \
-H 'Accept: string' \
-H 'g-api-key: string'

```

`DELETE /azeem/members/storage`
*Generic - Delete Store*

Parameters

|Name|In|Type|Required|Description|
|---|---|---|---|---|
|Accept|header|string|true|none|
|g-api-key|header|string|true|none|

> Example responses

Responses

|Status|Meaning|Description|Schema|
|---|---|---|---|
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|none|None|

Response Schema

This operation does not require authentication

# Schemas

CreateApplicationRequest




``` json
{
"name": "24h Fitness Gym",
"description": "Fitness mobile app store",
"app_api_slug": "azeem",
"cors": [
{
"domain": "domain1.com"
},
{
"domain": "domain2.com"
},
{
"domain": "domain3.com"
},
{
"ip_address": "127.0.0.1"
}
]
}

```

CreateApplicationRequest

### Properties

|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|name|string|true|none|none|
|description|string|true|none|none|
|app_api_slug|string|true|none|none|
|cors|[[Cor](#schemacor)]|true|none|none|

Cor




``` json
{
"domain": "domain1.com"
}

```

Cor

### Properties

|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|domain|string|false|none|none|
|ip_address|string|false|none|none|

UpdateApplicationRequest




``` json
{
"description": "this is a test",
"cors": [
{
"domain": "domain1.com",
"updateWith": "domain4.com"
},
{
"domain": "domain2.com"
},
{
"domain": "domain3.com"
},
{
"ip_address": "127.0.0.1",
"updateWith": "192.168.0.1"
}
]
}

```

UpdateApplicationRequest

### Properties

|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|description|string|true|none|none|
|cors|[[Cor1](#schemacor1)]|true|none|none|

Cor1




``` json
{
"domain": "domain1.com",
"updateWith": "domain4.com"
}

```

Cor1

### Properties

|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|domain|string|false|none|none|
|updateWith|string|false|none|none|
|ip_address|string|false|none|none|

Generic-InsertRecordRequest




``` json
{
"string_col": "adeel",
"int_col": 1233232,
"long_string_col": "adasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadadadasdasdadasdadadad",
"bool_col": true,
"double_col": 10.23,
"array_col": [
1,
2,
3
],
"array_col_object": [
{
"n1": "v1"
},
{
"n1": "v2"
},
{
"n1": "v3",
"n2": "bv1"
}
],
"object_col": {
"person": "adeel",
"email": "someemail@email.com"
},
"date_time_col": "2020-08-16T15:03:00.000Z"
}

```

Generic-InsertRecordRequest

### Properties

|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|string_col|string|true|none|none|
|int_col|integer(int32)|true|none|none|
|long_string_col|string|true|none|none|
|bool_col|boolean|true|none|none|
|double_col|number(double)|true|none|none|
|array_col|[string]|true|none|none|
|array_col_object|[[ArrayColObject](#schemaarraycolobject)]|true|none|none|
|object_col|[ObjectCol](#schemaobjectcol)|true|none|none|
|date_time_col|string|true|none|none|
|null_col|string|true|none|none|

ArrayColObject




``` json
{
"n1": "v1"
}

```

ArrayColObject

### Properties

|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|n1|string|true|none|none|
|n2|string|false|none|none|

ObjectCol




``` json
{
"person": "adeel",
"email": "someemail@email.com"
}

```

ObjectCol

### Properties

|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|person|string|true|none|none|
|email|string|true|none|none|

Generic-UpdateRecordRequest




``` json
{
"string_col": "Adeel Rizvi",
"int_col": 12334567,
"long_string_col": "this is a long string",
"bool_col": false,
"object_col": {
"person": "Adeel Rizvi",
"email": "someemail@email.com"
}
}

```

Generic-UpdateRecordRequest

### Properties

|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|string_col|string|true|none|none|
|int_col|integer(int32)|true|none|none|
|long_string_col|string|true|none|none|
|bool_col|boolean|true|none|none|
|object_col|[ObjectCol](#schemaobjectcol)|true|none|none|

### Development

Want to contribute? cPanel-PHP-server is open to improvements, so feel free to create a Pull Request to help the community become greater.

License
----

MIT