Microsoft Server 2012 R2, SQL Server 2016 and DreamFactory

Part 1: Running Microsoft Server 2012 and SQL Server on AWS, on my MacBook Pro

How do we get from here, hosting an AWS Microsoft SQL Server instance on my MacBook Pro?

AWS Microsoft Server 2012 R2 Desktop
AWS Microsoft Server 2012 R2 Desktop

To here using Microsoft Server, SQL Server, and DreamFactory, still on my MacBook Pro.

SQL Server Get Schema
SQL Server Get Schema

Some Background:

Let’s get to the nuts and bolts of this.  In the past, it was very difficult to create cross platform solutions.  With the advent of cloud computing, this has become increasingly easier to do.

When you have a robust piece of middleware software, such as DreamFactory which is for most intents and purposes language and platform agnostic, you really do have your choice of platforms to install it on.  Each has its advantages and disadvantages, which I am not going to go into detail in this article, but suffice it to say, there are a lot of enterprises that choose the Microsoft platform(s), and some of those advantages became apparent as I worked on this post.

First things first, make sure to grab all of the pre-requisites you need to make the install easy:

Required Software and Extensions

At a minimum, you will need the following software and extensions installed and enabled on your system in order to successfully clone and install DreamFactory 2.12.0+.

  • PHP 7+ – check and install the requirements below for your particular environment.
    • PHP required extensions: Curl, MBString, MongoDB, SQLite, and Zip. You may need to install other extensions depending upon DreamFactory usage requirements. If you don’t plan on using MongoDB, please remove the df-mongodb requirement from,composer.json or include the --ignore-platform-req option when running composer install.
  • Git
  •  Windows Git Client – Git Bash lets you run “Linux style” commands
  • A web server such as NGINX, Apache, or IIS. You may use PHP’s built-in server for development purposes.
  • One of four databases for storing configuration data: MS SQL Server, MySQL (MariaDB or Percona are also supported), PostgreSQL, or SQLite.
  • Composer – may require cURL to be installed from particular environment below.

Microsoft Server can be spun up almost anywhere now, as is evidenced by the photos above, and since DreamFactory is platform agnostic, we can install it on the Microsoft Server 2012 R2 instance with just a few bits of software installed to get up and running. There are multiple ways to grab and install PHP on a Microsoft platform, but an easy way is to utilize the Web Platform Installer (version 5.0 as of this post).

The Install:

You can download the Web Platform Installer for IIS here. Select a PHP version (7.0.x is required to run the current 2.13.0 version of DreamFactory), and different pieces of IIS, should you decide to utilize that as your production web server.  This post will not dive into the nitty-gritty of IIS, but you can see our documentation here.  We will be using PHP’s built-in development web server to just illustrate the connections.

Web Platform Installer 5.0
Web Platform Installer 5.0 Showing PHP installed

Once you have installed PHP and double checked your pre-requisites are installed, you can begin the install:

  • Perform a Git clone into this directory for Dreamfactory:
git clone https://github.com/dreamfactorysoftware/dreamfactory
Git Clone DeramFactory
Clone down the latest version

This will pull down the master branch of DreamFactory into a directory called ./dreamfactory.

  • Navigate to the dreamfactory directory and install dependencies using composer. For production environment, use --no-dev, otherwise discard that option for a development environment. If you are not running or plan to run MongoDB, add —ignore-platform-reqs:
composer update --ignore-platform-reqs --no-dev
composer update --ignore-platform-reqs --no-dev
composer update –ignore-platform-reqs –no-dev

Otherwise, run the following command to install the dependencies:

composer install --no-dev
  • Run DreamFactory setup command-line wizard. This will set up your configuration and prompt you for things like database settings, first admin user account, etc. It will also allow you to change environment settings midway and then run it again to complete the setup.
php artisan df:setup
DF:Setup
php artisan df:setup

Follow the on-screen prompts to complete the setup.

Prompts
Follow the prompts

You can then run php artisan serve and migrate over to the address and port you have set up. In this example, we are running off of http://127.0.0.1:8000

php artisan serve
php artisan serve

Part 2:  The SQL Server Reckoning

With our instance running now, we can finally delve into the “fun” part of this install.  The ease with which you can add a SQL Server instance is awesome.  It is the fastest install I have ever done from the driver install to DreamFactory connection, it was less than 5 minutes¹.

Using the Web Platform Installer, you can download a SQL Server driver package that is compatible with your PHP version and your O/S version.

SQL Server Driver Package, version 5.2
SQL Server Driver Package, version 5.2

Now you can head back over to your instance and create a SQL Server service.  Just select the service type, add in your credentials and then test it.  That’s it.  No muss, no fuss.  Take a look at the screenshots below to see the results.

Create your service
Create your service
Add your credentials
Add your credentials
SQL Server Get Schema
SQL Server Get Schema

We have now connected our SQL Server instance to our Microsoft Server 2012 R2 (both hosted on AWS) on my MacBook Pro.  Sometimes, it all falls into place.  Don’t forget to check out our wiki and community forums for more topics, information, and examples.

¹ I had my credentials on hand in a notepad text file for copy/paste quickness, but still, very fast 🙂

Running DreamFactory as a Docker Container

large_h-dark 

Note: We have updated the instructions here to match our DF-Docker repo instructions.  This will pull the latest GitHub repo now.

DreamFactory can be run as a Docker container, which makes it easier than ever to get the backend for your apps up and running. The DreamFactory Docker image is available on Docker Hub, or you can build your own image from the GitHub repo. Using these two methods, I’ll show you how to use Docker to fire up your own DreamFactory instance in just a few steps. This setup uses MySQL for the system database and Redis for the system cache. The basic idea is that you first start the containers for MySQL and Redis, then a container for DreamFactory which links to the others. 

Continue reading “Running DreamFactory as a Docker Container”

Why We Moved to Oracle Cloud

Over the years, we have used a few different cloud providers to host DreamFactory Developer Sandboxes. Every single cloud provider uses different terms and concepts for basically the same thing – compute, storage, transfer, gateways, and DNS routing, just to name a few. Having recently made the switch to the Oracle Bare Metal platform for our API Automation Portal, our team was immediately impressed by cost, performance, and ease of use.

Continue reading “Why We Moved to Oracle Cloud”

PHP 7 doubles performance for DreamFactory

speed-increase.png DreamFactory is a high performance request/response engine for REST API Services. You can hook up any SQL or NoSQL database and instantly get a comprehensive REST API for that data source. A big part of our platform is the support for JSON Web Tokens. JWT is an open standard for representing session information that is transferred between the client and server. JWT allows DreamFactory to run in a completely stateless manner, which makes the platform very easy to scale vertically with additional server capabilities or horizontally with multiple instances between a load balancer. Continue reading “PHP 7 doubles performance for DreamFactory”

How to integrate the Twilio API with DreamFactory to enable SMS for your app

twilio.png Twilio has a superb API for integrating SMS messages into your applications. It’s easy to add Twilio as a remote HTTP service to any application you’re building with DreamFactory. DreamFactory lets you securely store your Twilio authentication credentials, call the Twilio API directly from a DreamFactory session, and easily add role-based access control to any Twilio API endpoint. This brief tutorial shows you how to add Twilio to DreamFactory in five minutes.

Continue reading “How to integrate the Twilio API with DreamFactory to enable SMS for your app”

DreamFactory Cache Supports Redis, Memcached, and local storage

Redis
DreamFactory Redis
One of the most powerful features of DreamFactory is the ability to write server-side script in pre- and post-process events and use as a custom scripting service. This provides the ultimate flexibility and allows the platform to support all sorts of complex backend business logics. However, DreamFactory server-side scripts are stateless and their scope is gone once the original process is completed.

Supported Cache Services

To allow for more flexibility in server-side scripts as well as to add a quick way of storing key-value pair data, DreamFactory 2.3 introduces the ‘Cache’ service. The Cache service supports three different types of cache backends.

  • Local file based cache
  • Redis cache
  • Memcached cache
Once the services are configured, all three types of cache backends use the same REST API interface to read, write, update, and delete the key-value pair data. Cache Services are native services of DreamFactory and are supported by features like role-service-access, lookup usage, live API documentation etc.

You can configure and use a cache service in a standalone way to store any number of key-value pair and retrieve them as needed. This allows you to easily implement a server-side caching system for your client apps. But the real benefit of cache service can be realized in server-side scripting. In your DreamFactory server-side script, you can make API calls to your cache service just like you do that for any other services. This will allow you to temporarily or permanently store any data related to your script. This can later be used in another script/process or even inside your client application.

Configuring Your First Cache Service

Let’s take a closer look at this new Cache service and it’s usage. You can configure/provision a Cache service just like any other services using the DreamFactory Admin console -> Services tab.

To learn more about the configuration, please see the wiki page.

Once you configure a DreamFactory Cache service, head over to the swagger API Docs by selecting the ‘API Docs’ tab on the Admin console. Your newly provisioned Cache service should now show up on the list of services there. Select your cache service to expand it. This will show you all the available APIs for your service. You can expand each of this API to get further details on their usage.

Redis service in Swagger

Cache for Performance

If you are interested in getting your API calls in a timely manner you can leverage Redis for consistent speeds. To do so you just have to follow a few simple steps.

First you will want to enable Caching for the Service you would like cached and set the amount of time each cached response is allowed to last.

Redis

Then you will want to edit the Cache Settings section in your .env file. You will want to uncomment the following.

  • CACHE_DRIVER=redis
  • CACHE_DEFAULT_TTL=Cache TTL in minutes
  • CACHE_HOST=
  • CACHE_PORT=6379
  • CACHE_PASSWORD=LEAVE COMMENTED OUT IF YOU ARE NOT USING A PASSWORD
  • CACHE_DATABASE=2
  • REDIS_CLIENT=Which Redis client to use: predis or phpredis

Believe it or not, that Service is now being Cached. Confirm it in your Redis environment and never worry about slow response times again! Chat with an expert today or try out a free instance to see how easy it is yourself.