The backend of the new SQL-Ledger will be a REST-API. The goal with the API will be making use of the existing modules inside the “SL” as much as possible as well as keeping the original database structure to keep backwards compatibility. While my goal will be using this API as the back-end for a new SQL-Ledger, anyone should be able to use the new API with any existing SQL-Ledger installation. This should also allow integrating SQL-Ledger with existing applications or workflows to be much easier.

The API is available on my github: https://github.com/HashimSaqib/Sql-Ledger-REST. API Documentation with a test server set up is also available on Swagger: https://app.swaggerhub.com/apis/HASHIM1SAQIB/SqlLedgerRest/1.


I decided to go with perl Mojolicious framework for the API, particularly with the Mojo::Lite library. Mojolicious provides us with an extremely easy to use RESTFul Routes, session management and JSON parser; it is also the most popular library on cpan and works perfectly for our need. I will be starting with developing this as a single page Mojo::Lite application for simplicity, but if needed, it should be easy enough to move this to be a complete Mojolicious application.

I also included a copy of “SL” from a RMAC installation of wordpress inside my API repo, since we will be making use of these modules. I import these inside the main API file along with some other modules.

I also create a global hash and a helper for “%myconfig”. This is needed to passed as it’s used by SQL-Ledger’s SL module and will need to be passed to them as an argument whenever called. Note here, right now I’m using a hard-coded dbname variable of “Ledger28”. This will be changed later to allow for multi-tenant installation but for now to keep things simple, we will go with this.

I also have two other functions defined here, one is a placeholder function “check client” that will be updated to be used as the authentication function later on (no authentication implemented right now to keep things simple for start), as well as one to create a database connection.

This is pretty much it for the setup. From the next post, we will start defining routes and start developing the GL modules.

Copyright © Hashim Saqib. All rights reserved.