Blog / Development

Say Hello to the New Kentico Cloud SDKs


by Bryan Soltis

Feb 1, 2018

We get pretty excited every time we release a new SDK for Kentico Cloud. With each new version, we open the platform up to a new group of developers, allowing them to work in their native language and systems easier. This means more applications built on the platform and a lot of amazing integrations and solutions. 

Recently, our Community team has been hard at work on some great new SDKs for you to check out. Covering PHP, Android, and NodeJS, these new development kits are aimed at providing developers with resources for some of the most popular programming languages around. Each SDK covers creating a DeliveryClient, querying your Kentico Cloud projects, and working with content types and models.

Let’s check them out!

PHP

First up is the new PHP SDK. Released in 1994, this CGI-powered architecture has been used by developers around the world on nearly every type of project. For CMS’s, PHP has been the choice of many developers, due to its long history in the community.

With the new Kentico Cloud PHP SDK, these developers can now leverage our scalable, cloud-based content in their favorite language. For the installation, developers can use the Composer dependency manager to get up and running quickly. The SDK has support for querying single items and collections, working with taxonomies, and localization. Developing on Windows? No problem! The SDK documentation has some great tutorials on how to get up and running fast.

See it in action

To test the PHP SDK, I first had to set up PHP on my Windows machine. This included installing PHP, Composer, and other settings. Luckily, the SDK documentation contains a great tutorial to help you get going.

I used the magic phpInfo() call to test the installation.

phpinfo();



Next, I used composer to add the Kentico Delivery SDK.


Next, I made sure my index was properly loading the SDK.


require_once __DIR__ . '/vendor/autoload.php'; // the path from the current directory

use KenticoCloud\Delivery\DeliveryClient;


Lastly, I added code to query my Kentico Cloud project and display the results.
 

// Initializes an instance of the DeliveryClient client
$client = new DeliveryClient('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

$items = $client->getItems()->items;

foreach ($items as $item) {
    echo("<table>");
    echo("<tr>");
    echo("<td>");
    echo("<img height=100 src='" . $item->productimage[0]->url . "' />" );
    echo("</td>");
    echo("<td>");
    echo("<strong>" . $item->productname . "</strong>");
    echo("<br />");
    echo($item->productdescription);
    echo("</td>");
    echo("</tr>");
    echo("</table>");
}


Here’s the equally exciting home page of my PHP site.



If you want to get the PHP running on your site, check out the PHP SDK documentation.

Android

Next, I’d like to introduce the Android SDK. Even with the popularity of “universal” mobile platforms like Xamarin, a lot of developers still like to use native code for their mobile projects. With enough Android devices to power XXX, creating the Kentico Cloud Android SDK was a must! By offering this new development kit, any developer working with the Android OS can quickly create their Kentico Cloud applications. 

The Kentico Cloud Android SDK is a full -featured kit, allow developers to interact with the API in nearly every way. Combined with our Java SDK, these kits allow you to develop native applications for your Lava and mobile devices, using a streamlined API. 

See it in action

To retrieve the content, I added the new Android SDK to my compile dependencies in my build.gradle file.


dependencies {
    ….
    compile 'com.kenticocloud:delivery-android:2.0.1'
}


Then, in my MainActivity.java file, I set up my DeliveryClient and associated objects.


private static final String projectId = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
private List<TypeResolver<?>> typeResolvers = new ArrayList<>();
private IDeliveryService deliveryService;
private DeliveryConfig config;
private List<Product> products;


In my OnCreate function, I created my service and queried the Kentico Cloud API.

// Prepare configuration object (note there are other parameters for e.g. preview API key)
config = new DeliveryConfig(projectId, typeResolvers);

deliveryService = new DeliveryAndroidService(config);

DeliveryItemListingResponse<Product> response = this.deliveryService.<Product>items()
        .type(Product.TYPE)
        .get();

products = response.getItems();


Lastly, I mapped the results to my ListView.

// Set up adapter
ArrayAdapter<Product> itemsAdapter = new ArrayAdapter<Product>(this, android.R.layout.simple_list_item_2, android.R.id.text1, products)
{
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = super.getView(position, convertView, parent);
        TextView text1 = (TextView) view.findViewById(android.R.id.text1);
        TextView text2 = (TextView) view.findViewById(android.R.id.text2);
        text1.setText(products.get(position).getProductName());
        text2.setText(products.get(position).getProductDescription());
        return view;
    }
};
//
ListView lv = (ListView)findViewById(R.id.lstProducts);
lv.setAdapter(itemsAdapter);


Here’s what the super awesome app looks like:



If you want to set up your own app, check out the Kentico Cloud Android SDK.

Note

In this example, I am using sample Android code to display my content. In UI heavy applications, a reactive approach would work much better to handle the display. In a later deep dive article, I'll show you how the Kentico Cloud Android SDK can support both techniques for building your applications. 

NodeJS

Lastly, I’d like to let you know about our new NodeJS SDK. Built on our existing TypeScript SDK, this new development kit provides the ability to keep all your NodeJS clean and consistent. If you haven’t seen the TypeScript SDK, check out the documentation and sample sites to get up and running in no time. 

Moving forward

Kentico Cloud is all about integration and microservices. As you can see, we are constantly working to improve the platform and help you build solutions using any technology. With the new PHP, Android, and NodeJS flavors, developers from any stack can now use Kentico Cloud easily, in their native programming languages.  I hope you get a chance to check out these new additions and use them in your projects. And because they’re all open source, we’d love for you to contribute! Good luck, friends!

Check out all the Kentico Cloud SDKs and samples