SDKs overview

Drupal, as an open-source content management system (CMS), does not provide a conventional Software Development Kit (SDK) in the same manner as a proprietary API service might. Instead, Drupal itself functions as a development framework, offering a set of APIs, libraries, and tools primarily in PHP for building and extending web applications. Developers interact directly with Drupal's core APIs, which are extensively documented on the Drupal.org API reference. The ecosystem includes modules and themes that extend functionality and presentation, many of which are developed and maintained by the community.

The core philosophy of Drupal development revolves around hooks, plugins, and services, which allow developers to alter or add to Drupal's behavior without modifying core files. This approach ensures upgradeability and maintainability. Key components like the routing system, database abstraction layer, and entity system are exposed through well-defined interfaces and APIs, facilitating custom development. For managing dependencies, Drupal heavily relies on Composer, the de facto standard package manager for PHP, which simplifies the inclusion of both Drupal-specific and third-party PHP libraries.

Official SDKs by language

Drupal's core is written in PHP, and therefore, its primary 'SDK' consists of the PHP APIs and libraries that comprise the CMS itself. There are no officially maintained SDKs for other programming languages directly provided by Drupal.org for interacting with a Drupal instance as a client application. Instead, client applications typically interact with Drupal via its RESTful APIs or GraphQL endpoints, which can be exposed through modules like JSON:API or GraphQL.

The following table outlines the core 'SDK' components for PHP development within Drupal.

Language Package/Component Description Maturity
PHP Drupal Core APIs The foundational set of PHP classes, interfaces, and functions that define Drupal's architecture, including the Entity API, Form API, Database API, and Routing API. Stable, actively developed
PHP Symfony Components Drupal integrates several components from the Symfony framework (e.g., HTTPKernel, DependencyInjection, EventDispatcher) for structured application development. Learn more about Symfony Components. Stable, actively developed
PHP Twig Templating Engine Used for theme development, providing a flexible and secure templating language. Stable, actively developed
PHP Composer Dependencies Manages third-party PHP libraries and Drupal modules. Stable, actively developed

Installation

Installing Drupal involves setting up the core CMS and then adding modules and themes as needed. The recommended method for managing Drupal projects and their dependencies is via Composer. This ensures that all required libraries are correctly installed and managed.

Prerequisites

  • PHP (version 8.1 or higher recommended for Drupal 10)
  • Web server (Apache, Nginx)
  • Database (MySQL/MariaDB, PostgreSQL, SQLite)
  • Composer

Installing Drupal Core with Composer

To start a new Drupal project, use Composer to download the recommended project template:

composer create-project drupal/recommended-project my_drupal_site
cd my_drupal_site

This command downloads Drupal core and its dependencies into a my_drupal_site directory. After this, you will typically configure your web server to point to the web subdirectory within your project and complete the installation via the web-based installer or Drush.

Installing Modules and Themes

Modules and themes are also installed using Composer. For example, to install the popular Paragraphs module:

composer require 'drupal/paragraphs:^1.15'

After requiring a module with Composer, you need to enable it within your Drupal installation, either through the administrative interface (/admin/modules) or using Drush:

drush en paragraphs

Quickstart example

This quickstart demonstrates how to create a custom module in Drupal to define a simple block that displays a custom message. This illustrates the fundamental process of extending Drupal's functionality using its PHP APIs.

1. Create a module directory

Inside your Drupal project's web/modules/custom directory, create a new folder for your module, e.g., hello_world.

mkdir -p web/modules/custom/hello_world

2. Create the .info.yml file

Every Drupal module requires an .info.yml file that provides metadata about the module. Create web/modules/custom/hello_world/hello_world.info.yml with the following content:

name: Hello World Block
type: module
description: 'A simple block that says hello.'
core_version_requirement: ^9 || ^10
package: Custom

3. Create the block plugin

Drupal 8 and later use the Plugin API for blocks. Create web/modules/custom/hello_world/src/Plugin/Block/HelloWorldBlock.php:

<?php

namespace Drupal\hello_world\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\Core\Block\Annotation\Block;
use Drupal\Core\Annotation\Translation;

/**
 * Provides a 'Hello World' Block.
 *
 * @Block(
 *   id = "hello_world_block",
 *   admin_label = @Translation("Hello World block"),
 *   category = @Translation("Custom")
 * )
 */
class HelloWorldBlock extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function build() {
    return [
      '#markup' => $this->t('Hello, Drupal World!'),
    ];
  }

}

4. Enable the module

Once the files are in place, enable your new module using Drush or through the Drupal admin interface:

drush en hello_world

5. Place the block

Navigate to /admin/structure/block in your Drupal site, click 'Place block' for your desired region (e.g., 'Sidebar first'), find 'Hello World block', and save it. The block will now appear on your site.

Community libraries

The Drupal ecosystem is supported by a large and active community that contributes thousands of modules and themes, effectively serving as an extensive collection of community-developed libraries. These contributions extend Drupal's functionality in virtually every domain, from e-commerce (e.g., Drupal Commerce) to complex media management (e.g., Media module) and API integrations.

  • Drupal.org Project Page: The main repository for community-contributed modules and themes is the Drupal.org project page. Developers can search, download, and contribute to these projects. Each project typically includes its own documentation, issue queue, and development roadmap.
  • Contributed Modules: These modules provide specific functionalities, such as advanced caching, search integration, user management enhancements, or integrations with third-party services (e.g., social media APIs, payment gateways like Stripe Payments, or CRM systems like Salesforce Developer Docs). They are often structured to integrate seamlessly with Drupal's plugin and hook systems.
  • Contributed Themes: Themes define the visual presentation of a Drupal site. They leverage Twig for templating and often integrate front-end libraries and frameworks (e.g., Bootstrap, React, Vue.js) to provide rich user experiences.
  • Drush: While not a library in the traditional sense, Drush (Drupal Shell) is a command-line interface (CLI) tool that is indispensable for Drupal development and administration. It extends Drupal's capabilities by providing commands for installing modules, clearing caches, performing database updates, and more, significantly streamlining workflows. Drush itself can be extended with custom commands.
  • PHP Libraries via Composer: Beyond Drupal-specific modules, developers frequently integrate general-purpose PHP libraries managed via Composer. This includes libraries for tasks like image manipulation, PDF generation, or advanced data processing, leveraging the broader PHP ecosystem within Drupal projects.

When selecting community libraries, it is advisable to check their maintenance status, compatibility with the target Drupal version, and community support by reviewing their issue queues and recent activity on Drupal.org.