This repository has been archived by the owner on May 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
Home
Eddymens edited this page May 10, 2016
·
31 revisions
The concept behind the Devless php core is to provide a out of the box api generation ability as well as the ability to swap pieces of data (schema) and logic(scripts) within a Devless install Devless has six main segments
Provides basic analytics on :
- service calls
- error and info logs
- funnel
Details about the app
App Name App description Api Key Api Token
Users create services from here. A service is a representation of a piece of functionality needed in an app to create a service you need to define :
- The service name
- Provide a description for the service
- Define the connector and the kind of database you want to connect to (default is sqlite). A sample table and script is generated once a service is created
- It has three components thus :
- Db This is the data house for a service.
- Tables for this service are created with the db core
- Table schemas can be created from the table tab or via a post call to
api\v1\<service name>\schema\
Below is a sample schema payload
Schema structure
{
"resource":[
{
"name":"products",
"description":null,
"field":[
{
"name":"orders",
"field_type":"reference",
"default":null,
"required":true,
"is_unique":false,
"ref_table":"orders",
"validation":true
},
{
"name":"product_name",
"field_type":"text",
"default":null,
"required":true,
"is_unique":false,
"ref_table":"customer",
"validation":true
}
]
}
]
}
- You can also access a table with an api call in the format
api\v1\service\<service_name>\db\<table_name>
-
Quering the table by making a get request
api\v1\service\<service_name>\db\<table_name>
an option is passing query parameters query params. without the parameters all the table content is returned.
NB: By default without specifying the number of records to return a query brings back a max of 100 records and may differ based on system performance.
-
Insert data into the table by making a
**POST**
requestapi\v1\service\<service_name>\db\<table_name>
and passing json body insert data structure
{
"resource":[
{
"name":"orders",
"field":[
{
"customer":"mannh",
"amount":70
}
]
}
]
}
- *update tables
api/v1/service/auth/db
{
"resource":[
{
"name":"osty",
"params":[
{
"where":"id,1",
"data":[
{"product_name": "you and i "}
]
}
]
}
]
}
- Drop and truncate tables
- api\v1\service<service_name>\db<table_name> drop params
{
"resource":[
{
"name":"orders",
"params":[
{
"delete":"true",
"where":"'id','=',1",
"truncate":"true"
}
]
}
]
}
- Script
- Scripts contain logic that manipulate
request
sent in from either the (routes)[routes], from the (views)[views] - You can work on scripts from the Service sub menu
- You can access db components from other services by using the internal api call
services($service_name,'db',$table_name,$action,$params)
this returns an array . where $action is the request verb sayPOST
- You can also access scripts from other services
services($service_name,'script',$action,$params)
- The default language for scripting is php. But as a registered developer you can have access to a sandbox of your choice (sandbox)[#sandbox]
- You can select the sandbox of your choice from within the script sub menu
- Views make it possible to provide a simple internal frontend to work with both db and scripts
- Devless creates a default view which can be access from within the respoective service tab.
- You can also access routes, hooks and request parameters from within your views.
- Views can access logic from scripts and db by triggering the service method eg:
services($service_name,'script',$action,$params)
andservices($service_name,'db',$table_name,$action,$params)
respectively - Also one can access a host of view helpers called (hooks)[#hooks]
- You can access views
Http(s)<HOST_URL>\views\<service_name>\<view_name>
- You can find the views and add more if needed from the resources folder found within the [directory not chosen yet]
- You can view all created endpoints and test them
- You can also choose whether to make these endpoints accessible to the public or closed from here
@2016 Devless inc