ServiceTypes

From DreamFactory
Jump to: navigation, search

Overview

In DreamFactory 2.0 (DF 2.0), Service Types are dynamic. What this means is you can easily add/remove a Service Type without altering any code. You can also create a new Service Type of your own and add it to the DF 2.0 platform. Service Types are primarily driven by the system Database. DF 2.0 is highly modular in design. Service Types are broken into individual packages. You can add/remove a package via Composer followed by running any Database migration that the package may have.

Architecture of Service Types

Each Service Type is broken into two parts - Service Type Definition and Service Type Config.

Service Type Definition is stored in the service_type table. It consists of basic service information such as name, label, description etc. It also stores the class name of the Service Type handler class as well as the Service Config handler class.

Service Type Configs differ from Service Type to Service Type depending on the Service Type itself. For example a SQL DB Service Type Config will have fields/options like dsn, username, password to connect to the SQL Database server where an AWS S3 Service Type Config will have fields/options like access key, secret, region to connect to AWS API endpoints. Service Type Config for each Service Type is stored in it's own table.

When a Service Type is added it populates the service_type table with its definition and adds any necessary Service Type Config table(s). When the Service Type definition is added in service_type table it becomes available as a Service Type to choose from on the Admin app.

Removing a Service Type

Let's say you don't need one of the Service Types - 'Active Directory LDAP' in your DF 2.0 instance and you want to rather not show this Service Type as an option when creating a new service. You can remove an existing service type following the steps below.

  • Make sure there are no existing services in your instance with Service Type 'Active Directory LDAP'. If there are then

delete them.

  • Edit the composer.json file in the DF 2.0 installation root and remove the following line.
"dreamfactory/df-adldap":     "0.1.*"
  • Run
    composer update
  • Log into your DF 2.0 system database and remove two records from the service_type table where the 'name' is 'adldap' and 'ldap'.
  • To clear system cache run
    sudo php artisan dreamfactory cache:clear

Login to your admin app and now you will see that the 'Active Directory LDAP' service type is no longer showing.

Adding a Service Type

You can follow the steps below to add any DF 2.0 Service Type to your DF 2.0 instance. Here we will show how to add the 'Active Directory LDAP' Service Type back in.

  • Edit the composer.json file and add the following line at the end of the "require":{...} section.
"dreamfactory/df-adldap":     "0.1.*"
  • Run
    composer update
  • Run
    php artisan migrate --seed
  • To clear system cache run
    sudo php artisan dreamfactory cache:clear

That's it! Now you should see a new Service Type - 'Active Directory LDAP' in your instance when creating a new service.