Skip to main content

Posts

Drupal Coding standard check

  Installing and checking Drupal coding standards using PHP CodeSniffer consists of the following steps at high level. Install PHP CodeSniffer Install Coder Register Drupal standards in PHP Codesniffer Run the sniffs Installing PHP code sniffer :  1-  composer global require drupal / coder You can check the location of the installation path by below command composer global show -P if you are in a windows machine then you need to update the below path in environment variable as a PATH key, PATH : C:\Users\dharmendra.singh\AppData\Roaming\Composer\vendor\bin and reopen the terminal to apply changes. Install the below composer global require drupal/coder dealerdirect/phpcodesniffer-composer-installer And Manually set installed paths : phpcs --config-set installed_paths C:/Users/dharmendra.singh/AppData/Roaming/Composer/vendor/drupal/coder/coder_sniffer Installation is Done You can verify this has worked or not phpcs -i The above command should include DrupalPractice ...

Drupal Caching Part 2

 Redis :  Redis is an open source, advanced key-value store and an apt solution for building highperformance, scalable web applications. Redis holds its database entirely in the memory, using the disk only for persistence. Command to connect to remote server :  $ redis-cli -h host -p port -a password get,set,del are the command commands of redis, redis 127.0.0.1:6379> ping Where 6379 is the default port of the redis

Logical Interview Question

 1. How to Swap two variables, With or without the third variable & inbuild function. This method will work for any variable type: $a = 5 ; $b = 6 ; list ($a, $b) = array ($b, $a); print $a . ',' . $b; // 6,5 Another simple way (which only works for numbers, not strings/arrays/etc) is $a = $a + $b; // 5 + 6 = 11 $b = $a - $b; // 11 - 6 = 5 $a = $a - $b; // 11 - 5 = 6 print $a . ',' . $b; // 6,5

How to Enable/Disable module Manually

Execute this code Anyhow on the server to uninstall module  // Read the configuration. $module_data = \Drupal::config('core.extension')->get('module'); // Unset the modules you do not need. unset($module_data['MODULE_NAME']); // Write the configuration. \Drupal::configFactory()->getEditable('core.extension')->set('module', $module_data)->save(); Another Way: <?php   \Drupal::service('module_installer')->install(['admin_toolbar']); ?> <?php   \Drupal::service('module_installer')->uninstall(['admin_toolbar']); ?> Delete config: \Drupal::configFactory()->getEditable('contact.form.personal')->delete();

Deign Pattern in Drupal

 What are Design Patterns in General: Description of communicating objects and classes that are customized to solve a general problem in a particular way. Why design pattern required: 1 - Design pattern help to speed up the development, 2 - The templates are proven and from the developer's position, the Only implementation is required 3- Encapsulate big ideas in a simpler way 4 -  Each pattern describes a problem which occurs over & over again, Design Pattern Inforces SOLID Principles: SOLID is an acronym that stands for the following: S ingle responsibility principle O pen/closed principle L iskov substitution principle I nterface segregation principle D ependency inversion principle Categorization of GOF(Gang of Four Design Patterns) - Creation - Used to construct objects such that they can be decoupled from their implementation system. i.e in one class, we put business logic & in another class create the instance of it. - Structural - Used to form large object str...

Acquia BLT setup With Lando

 Install the latest version of Lando. navigate to directory & create a project directory. 1 - mkdir lando-d8 & cd lando-d8 2 - lando init (choose anything later we will change the config) One lando.yml file will be create in the directory change the config as below, name : lando - lightning recipe : drupal8 config : webroot : lightning/docroot tooling : blt : service : appserver cmd : /usr/bin/blt Can change the name, lando start lando composer create-project --no-interaction acquia/blt-project lightning cd lightning Follow the Document :  https://thinktandem.io/blog/2017/12/09/lando-blt-acquia/ After the drupal install & can login in drupal: Now the Basic Processudre is to deployment in git & acquia, Before you can either connect to your Git code repository or use SSH to sign in to your web server, you must have an SSH private/public key pairGenerate keys in system by following URL: https://docs.acquia.com/cloud-platform/manage/ssh/genera...