Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.
eddymens edited this page May 8, 2016 · 31 revisions

Welcome to the DV-PHP-CORE wiki!

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 structures(schema) and logic(scripts) within the a devless
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 Token

Service

Users create services from here. A service is a modular 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 system db) 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 is created with the db core
  • Table schemas can be created from the table tab or via a post call to api\v1\schema<service_name> Below is a sample schema
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 only the table content is returned

NB: by default without specifing the number of records to return a query returns a max of 100 records

*Inserting 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":"kwesi",
               "amount":70
            }
         ]
      }
      
    ]
}        

http://localhost:8000/api/v1/service/db_service?table=orders&order=amount,desc&size=20&where=customer,kwesi&where=amount,70&relation=products

{  
   "resource":[  
      {  
         "name":"orders",
         "field":[  
            
            {  
               "customer":"kofi",
               "amount":40
            }
         ]
      },
       {  
         "name":"orders",
         "field":[  
            
            {  
               "customer":"micheal",
               "amount":70
            }
         ]
      }
    ]
}        
  • Inserting 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
            }
         ]
      }
      
    ]
}        
Drop table
{  
   "resource":[  
      {  
         "name":"orders",
         "params":[  
            {  
               "delete":"true",         
               "where":"'id','=',1"
               
            }
         ]
      }
      
    ]
}        
Script
  • Scripts contain logic that manipulate request sent in from either the (routes)[routes] or 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 response. where $action is the rewuest 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 a sandbox of your choice (sandbox)[#sandbox]
  • You can select the sandbox of your choice from within the script sub menu
views
  • Views makes 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 ther service tab.
  • You can also access routes, hooks and reuqest parameters from within your views.
  • Views can access logic from scripts and db by triggering the services($service_name,'script',$action,$params) and services($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 withn the home folder
Docs
  • You can view all created endpoints and try them out
  • You can also choose whether to make these endpoints accessible to the public or closed from here

Request and Response

Internal Access

App

Clone this wiki locally