Wern Ancheta

Adventures in Web Development.

Getting Started With SPBAS

| Comments

As developers we often need to sell the applications that were creating. Places like the Google Web Store, Codecanyon, Apple Store, Shopify App Store exist for that matter. These repositories are good places to start but it often requires you to upload your work and have it reviewed by other developers so they are ensured that the app that you submitted meets their criteria.

This is often a tedious process and sometimes you have to wait for a specific period of time before your app gets approved. With SPBAS you can skip that process altogether and host your own business automation software on a server of your choice. In this post I’ll be walking you through SPBAS, short for SolidPHP Business Automation Software. With SPBAS you can easily host the apps that you have created and have people who wants to buy your app pay you via the payment method of your choice. Note that I won’t be discussing about the specific features of this business automation software as the official documentation already has a plenty of that information available. Rather I’d like to focus on the developer’s perspective. Things like setting up SPBAS and how to actually get up and running with it. I’m not going to go in-depth with the concepts such as licensing and the different options that are available. Instead I’m going to stick with only the necessary parts in order to get up and running quickly with SPBAS.

Getting SPBAS

Before you can begin installation, you first have to register with SPBAS. To register simply go to the SPBAS site, click on customer area and click on the register tab.

spbas registration

Once you’re done with that simply login to the account and click on the order tab. The order page lists all the available products. For this guide were simply going to use the Free version so click on the link under the SPBAS 25 Free version.

spbas order

After that, click on the add to cart button to add the specific product into your cart.

add to cart

Then click on the checkout button.


After that you will be ask to enter your business details. Once you’re done entering your business details simply click on the continue to next step button. You will then be redirected to the order summary page just click on the ok button at this point to confirm that your order is correct. If everything went well you will see a screen similar to the following:

order complete

At that point your product license will have been emailed to you by SPBAS. You can use the product license on your SPBAS installation later on. If you didn’t receive your license details you can also access it from the customer area. To access your license details from the customer area, just click on the dashboard link and under the My Packages section click on the licenses link. This will redirect you to the ‘My Packages’ page which you will see the product that you ordered earlier. Just click on the view details link once you’re on that page to view the details for that specific package. Once you’re on the package details page just click on the licenses tab to view your license key. Copy your license key and store it somewhere safe, a password manager like keepass or lastpass will do. You will be using the license key later.

Once you’re done saving the license key, click on the downloads tab then select the current release. At the time of writing of this post the current SPBAS version is 3.2.0. If they already have anything higher than that by the time you read this simply stick with that version instead. Under the current release directory is the SPBAS zip file, download the zip file and extract it on your machine then copy it to your web directory or upload it to a server somewhere using Filezilla or other FTP clients.

Installing Ioncube

SPBAS has been encoded with Ioncube so it requires the ioncube PHP module to be installed on the server before you can make use of it. In case you don’t know what encoding is, its used to obfuscate code so that when its source file is opened it cannot be understood by a human. Its a way to protect intellectual property. Because as you already know PHP is an interpreted language so the code that you write is pretty much exposed to anyone who has access to the source files.

You can install ioncube by downloading the ioncube loader from the ioncube website. All you have to do is select the loader that’s applicable for your machine. The first step is to determine the Operating System that you’re using and the version of PHP installed. You can do that by executing the phpinfo() function:


Access the file from your browser and look at the header:


As you can see from the screenshot above I’m running PHP version 5.5.7 on Ubuntu Raring Ringtail (13.04). Looking at the loaders available from the ioncube website there’s no loader that’s specifically for Ubuntu 13.04 so the closest one that I could download is the one for Linux (x86). Under the archives I downloaded the zip file and extracted it on my machine. If you’re using Windows then all you have to do is download the one’s that are under the Windows installer column and select the one that’s applicable to your Operating System and PHP installation.

After extracting (on Ubuntu) or executing the installer file on Windows, copy the directory extracted from the ioncube loader zip file on your web directory and access the loader-wizard.php from your browser. This will give you an idea whether your installation was successful. If it wasn’t successful the loader wizard will show all the warnings and will give you an idea on what went wrong so you can fix it.

Here’s an example of an error from the loader wizard:

loader wizard

As you can see from the screenshot above it will automatically detect where the correct loader files are located and shows you where it should be installed. Simply follow the instructions and restart apache once you’re done:

sudo service apache2 restart

Common Installation Issues

Here are some of the common issues when installing ioncube:

  • PHP Fatal error The Loader must appear as the first entry in the php.ini file in Unknown on line 0 – this means that the ioncube loader must be the first module that should be loaded by PHP. In Ubuntu you can do this by going to the following directory:

And create a new file and name it 01-ioncube.ini then put the following contents:

zend_extension = /usr/lib/php5/20121212/ioncube_loader_lin_5.4.so

This ensures that the ioncube loader is first on the queue. Do note that the path here should be the same as the path that was mentioned in the loader wizard and that the loader file, in this case the loader file is the ioncube_loader_lin_5.4.so file should exist in the location specified. The loader files are stored in the directory that you extracted earlier and its stored along with the loader-wizard.php file. And don’t forget to restart apache once you’re done making the changes.

  • The installed loader is for PHP 5.4 but your server is running PHP 5.5 – this means that the loader and the PHP version isn’t compatible. To solve this problem you have to use the loader that’s specific to your PHP version. There’s really no problem with this if you’re able to access the loader wizard since it already mentions from there which loader version you have to install.

  • PHP version used for encoding the files isn’t the same as the ioncube loader version – unfortunately there’s really nothing that you can do with this one. If the PHP software that you’re trying to use was encoded with ioncube that has a lower or higher version than that of the ioncube loader that your machine has then it won’t work. The basic rule is that the encoder version should be the same as the loader version.

Installing SPBAS

Once you have successfully installed Ioncube you can now install SPBAS. You can do that by extracting the SPBAS zip file that you downloaded earlier into your web directory. The default file name of the extracted directory is rename_upload_me so you have to rename the directory to something like spbas so its easily recognizable. When accessing SPBAS from your browser for the first time you have to access the install path:


Once you’re in the install page simply follow the installation instructions to install SPBAS.


After installing SPBAS you’re now ready for configuration. Configuring SPBAS can be done by logging into your administrator account and accessing specific areas that you want to configure. In this section I’ll be walking you through some of the most common configurations to get you up and running with SPBAS.


To add products all you have to do is click on the following links in order: settings –> storefronts & products –> products –> add product

Once you’re in the add product page simply enter the details for the application that you’re trying to sell:

add product

Pricing Tier

After adding a product you have to add a pricing tier. Things such as the minimum quantity, maximum quantity and price can be added here. You can add a price tier by going to: settings –> storefronts & products –> products –> find the product that you want –> manage –> product price tier –> add price tier

add pricing tier

System Configuration

After adding the pricing tier for a specific product you may also want to configure the overall system settings. Things such as the date format, time format, default upload path and your SPBAS license key can be added from here. The system configuration page can be accessed by going to: admin –> system –> application –> system configuration

If you still remember that license key that you got from the SPBAS website earlier that’s the one that you should supply in the SPBAS license key field. Another important configuration is the media upload path. This is where the product files are going to be uploaded.

system configuration

Licensing Method

Next is the optional licensing method. I said optional because not all products requires a license in order to work. If the application that you’re trying to sell is a one-time payment only then there’s no need to setup a licensing method. But if you’re application requires a license in order to work then read on. The licensing method is the type of licensing that you want to use for the products that you’re selling. A licensing method can be added by going to: settings –> licensing –> licensing methods –> add a new method

Note that the SPBAS is the recommended licensing method as its the only licensing method that’s actively developed.

licensing method

Once you’re done selecting the licensing method and giving it an easily recognizable name you can now add the details for that specific licensing method. Things such as the license prefix, license validation options and max instances of each issued license can be set from this page. Here’s an example configuration for a licensing method:

licensing method details

As I have said earlier I’m only going to discuss about the necessary parts in order to easily get up and running with SPBAS. If you want to dive in deeper with the licensing options available and what each of the options mean, you can check the documentation on licensing.

Download Category

Next is the download category. Download categories is part of the group of settings for setting up downloads for your products. To add a new download category go to: settings –> media –> downloads –> new category

From there you can create a new download category. Simply click on the add category button once you’re done giving the download category a name.

add download category

Once you’re done with that you can now add a specific media or the archive version of the product that you’re trying to sell to that download category. You can do that by going to: settings –> media –> downloads –> media

Then simply supply the display name and the actual file name. Note that the file should exist in the media upload path that you supplied earlier in the system configuration page. If this doesn’t work, simply use the web upload feature in which you can manually upload the files. After that click on the add media to category button to add the files to a specific download category.

add media to download category

Media Set

Media sets are categories of downloads that can be assigned to product price tiers as assets. In simple terms they are used to link pricing tiers to the files for a specific product. You can add a media set by going to: settings –> media –> media sets –> add media set

Give the media set a name that can be easily recognized as part of a specific price tier and click on the add new button.

add media set

Once you’re done with that simply assign the media set to a specific product price tier by checking the checkbox beside the product pricing tier. You can access the following page by clicking on the manage link beside the media set that you created:

assign asset to media set

After that you can now assign a media category to the media set. You can do this by going to: settings –> media –> media sets –> assign media to sets

assign media category to media set

Assigning License Method as an Asset

In order to create new license keys you must first assign the licensing method to a product price tier. After you do this customers can order the product, or you as an admin can manually add a package, which will result in a license key asset being issued to the customer account. The customer can then enter the license key into your application to activate it. To assign a licensing method click the Assign as Asset menu link and check the box beside each relevant product price tier.

assign asset to licensing method

Assigning Product Order to Form

Finally you can now assign a specific product to the order form. This will allow customers to see your product listed on the order page of your SPBAS installation. You can do that by going to: settings –> storefronts & products –> order forms

Once you are there simply check the checkbox beside the Products to assign your products to your order form.

assign product order to form

Licensing Implementation

You can implement licensing by including the SPBAS.class.php somewhere in your app. And include a code that’s similar to the code below:

include 'SPBAS.class.php'
$license_key = trim($_POST['lickey']); //license key inputted by the user

$spbas = new spbas(); //initialize spbas

  $spbas->license_key = trim($license_key);

  $spbas->api_server = 'http://localhost/spbas/api/index.php'; //the URL in which SPBAS is hosted 
  $spbas->secret_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';  //the secret key from the licensing method

  $spbas->validate(); //check if the license key is valid

  $response = array();

      $db->query("INSERT INTO tbl_settings SET license = '$license_key'"); //save license into the database

     some code here to activate the application

      //setup success response
      $response = array(
          'type' => 'success',
          'text' => 'You have successfully Activated the plugin!'
      //setup error response
      $response = array(
          'type' => 'error',
          'text' => $spbas->errors

  echo json_encode($response);

You may want to encode this specific part of the code using something like Ioncube so the implementation details are protected. One final thing to note is that the ioncube loader should also be installed on the server where you plan to deploy.