Skip to main content

Posts

Welcome to the Drupal Playground!

Hey there, Drupal enthusiasts! 🎉

We’re thrilled to welcome you to Drupal Playground, where creativity, innovation, and the power of Drupal come together. This is your space to explore, learn, and build amazing things using one of the most flexible CMS platforms out there.

Happy Drupaling!
— The Drupal Playground Team

How to Install Multiple PHP Versions on Ubuntu

I’ve shared the commands I used to install different PHP versions on my system. Currently, I have two versions of PHP installed and have now added the latest PHP 7.4 version. To check the PHP versions already installed on your system, follow these steps. sudo update-alternatives --list php The output of the above command shows the PHP versions installed on your system: /usr/bin/php5.6 /usr/bin/php7.3       (or) sudo update-alternatives --config php The output of the above command shows the PHP versions installed on your system: There are 2 choices for the alternative php (providing /usr/bin/php).   Selection    Path             Priority   Status --- ---------------------------------------------------------   0            /usr/bin/php7.3   73        auto mode * 1         ...

Drush Commands

 The " drush cim" and " drush cex" commands are used for importing and exporting configuration changes from one environment to another environment. drush cim (Configuration Import) The drush cim command is used to import configuration changes from the configuration synchronization directory ( sync folder). This will import all configuration files from the default sync directory. drush cex (Configuration Export) The drush cex command is used to export the current configuration of your Drupal site into the configuration synchronization directory . This Drush command is used to transfer configuration changes seamlessly, ensuring that no details are missed. It allows us to track all configuration changes at each stage of the process.

Integrating NLP Processing into Elasticsearch

  Natural Language Processing (NLP) and Elasticsearch are powerful technologies in their own right. When combined, they can elevate search functionality to new levels, enabling capabilities like semantic search, intent detection, and sentiment analysis. In this post, we’ll explore how to integrate NLP processing into Elasticsearch to enhance search results, with technical insights and practical examples. In my Elasticsearch setup, I have implemented a specific configuration to enhance functionality. While Elasticsearch offers several other options, I am currently utilizing this particular approach to meet my requirements I followed these steps to include a specific model for supporting NLP processing: Open the Kibana tool and navigate to the  Machine Learning  menu in the left sidebar under the  Analytics  section.  Select the  Trained Models  option.  On the trained model listing page, download the  Elser model  (in my system, it s...

Drupal 9 Trusted host patterns

  Error :   The trusted_host_patterns setting is not configured in settings.php. This can lead to security vulnerabilities. It is highly recommended that you configure this. See Protecting against HTTP HOST Header attacks for more information. Solution :  Open the  settings.php  file and insert the following code snippets based on your application requirements: a. For Localhost Setup: If your application is running on a local server (e.g., XAMPP or WAMP), and the URL starts with  http://localhost/project , include the localhost configuration in the settings. b. Multiple URLs Support: Users can define and include any number of URLs as needed for their setup. c. Subdomain Handling: If your application uses multiple subdomains, you can enable support for all subdomains under a specific domain (e.g.,  dev.com ) using a regular expression like  ^.+\.dev\.com . This configuration ensures that all subdomains under  dev.com  are accepted. d...

Set Custom Header Variables for API in Drupal 9

Create and Install a Custom Module Create an Event Subscriber in the Custom Module . Place the Event Subscriber file in the src/EventSubscriber folder of the custom module. <?php // In your_module/src/EventSubscriber/CustomHeaderSubscriber.php namespace Drupal\custom\EventSubscriber ; use Symfony\Component\EventDispatcher\ EventSubscriberInterface ; use Symfony\Component\HttpKernel\Event\ RequestEvent ; use Symfony\Component\HttpKernel\ KernelEvents ; use Symfony\Component\HttpKernel\Exception\ AccessDeniedHttpException ; use Symfony\Component\HttpFoundation\ Response ; /**  * Event subscriber to check for a custom header in incoming requests.  */ class CustomHeaderSubscriber implements EventSubscriberInterface {   /**    * { @inheritdoc }    */   public static function getSubscribedEvents () {     // Subscribe to the request event, with a priority of 30     $ events [ KernelEvents:: REQUEST ][] = [ 'checkCusto...

Drupal "No plugin ID specified issue" in custom block

Issue While Assigning Custom Block to Block Layout or Layout Builder Error Message: Drupal\Component\Plugin\Exception\PluginException: No plugin ID specified for component with "XXXXXX" UUID in Drupal\layout_builder\SectionComponent->getPluginId() (line 218 of D:\xamp\htdocs\coin\web\core\modules\layout_builder\src\SectionComponent.php). This error occurs because the plugin ID and definition for the custom block are not properly specified. Plugin IDs are unique identifiers used in Drupal to define new components like block types, field types, menu items, and more. Solution: To resolve this issue, ensure that the plugin ID and definition are correctly added to the __construct() function of your custom block code. Ex :  namespace Drupal\module_name\Plugin\Block ; use Drupal\Core\Block\ BlockBase ; /**  * Description  *  * @Block(  *   id = "Id of the block",  *   admin_label = @Translation("Block Name"),  * )  */ class block_class e...

MySQL Shutdown Unexpectedly (Blocked Port Issue) in XAMPP

Sometimes MySQL in XAMPP shuts down unexpectedly, often due to a blocked port or corrupted data files. Below is a simple method that worked successfully on my local machine. ⚠️ Important Note Before making any changes, always take a backup of your MySQL data to avoid accidental data loss. Steps to Resolve the Issue Navigate to your XAMPP installation directory. Open the following path:   xampp > mysql > data Inside the data folder: Select all files Delete only the files , do not delete the folder itself For safety, you can copy these files to another location as a backup Once the files are removed, restart XAMPP. Try starting the MySQL server again. In my case, MySQL started successfully after following these steps. Why This Works Sometimes MySQL fails to start due to corrupted temporary or log files. Removing these files forces MySQL to recreate them when the server starts, which can resolve the issue.