Skip to content
This repository was archived by the owner on May 24, 2022. It is now read-only.
Edwin Tsatsu edited this page May 10, 2016 · 31 revisions

Welcome to the DV-PHP-CORE wiki!

The concept behind the Devless php core is to provide an out of the box api generation ability as well as the ability to swap pieces of data(schema) and logic(scripts) withany Devless install Devless has six main segments

Dashboard

Provides basic analytics on :

  • service calls
  • error and info logs
  • funnel

App:

Details about the app

Fields

App Name App description Api Key Api Token

Services

Users create services from here. A service is the representation of a 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 :
  1. 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>

List of actions you can perform on a table includes

  • 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** request api\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" 
               
            }
         ]
      }
      
    ]
}        
  1. 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 say POST
  • 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
  • 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 the respective 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) and services($service_name,'db',$table_name,$action,$params) respectively
  • Also you 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]
Docs
  • 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

Request and Response

Internal Access Elements

App

Clone this wiki locally