Skip to main content
Home
Drupal life hacks

Main navigation

  • Drupal
  • React
  • WP
  • Contact
  • About
User account menu
  • Log in

Breadcrumb

  1. Home

Namespace

By admin, 20 May, 2024

Defining PSR-4 Namespace for Custom Modules in Drupal

In Drupal, PSR-4 namespaces are commonly used for organizing and autoloading custom PHP classes, including controllers. Here's how you can define a PSR-4 namespace for your custom module in Drupal:

Step 1: Module Structure

Ensure your module follows the standard Drupal module structure. Your module folder should be located in the modules/custom directory of your Drupal installation. For example, if your module is named "custom_hello", the folder structure would look like this:

Tags

  • #Drupal Planet
  • Namespace
Namespace
Powered by Drupal