Skip to main content

Posts

Showing posts from 2020

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...

Acquia BLT (Build and Launch Tool)

  To improve efficiency and collaboration across Drupal projects, Acquia BLT provides both a common suite of tools and standardized structure. The tools and structure will help developers reduce incidents of duplicated work, speed up project configuration, and onboard new developers faster. Using Acquia BLT for your Drupal projects will help you meet the following goals during your development cycles: Provide a standard project template for Drupal based projects Provide tools automating the configuration and maintenance work for projects Document and enforce Drupal standards and best practices through default configuration, automated testing, and continuous integration Features Acquia BLT offers the following features for your organization’s use: Local Git hooks : Evaluate formatting, syntax, and compliance with Drupal coding standards. Testing frameworks : Provides default configurations for Behat and PHPUnit. Project automation tasks : Includes commands for syncing environments, ...

Elastic Search

Elasticsearch  is a full-text, distributed  NoSQL  database. In other words, it uses documents rather than schema or tables. It's a free, open source tool that allows for real-time searching and analyzing of your data. Elasticsearch  is distributed, which means that indices can be divided into shards and each shard can have zero or more replicas. Kibana:  Kibana  is merely a visualization tool for data stored in  Elasticsearch .  Kibana  uses the regular  Elasticsearch  REST API to retrieve and visualize data stored in Elastic. How to Install & configure The elastic search With Lando : Ref for All the type of services in lando, https://github.com/lando/lando/tree/master/examples

Elastic Search Vs Solr search

Solr is search server for creating standard search applications, no massive indexing and no real time updates are required, but on the other hand Elasticsearch takes it to the next level with an architecture aimed at building modern real-time search applications. Percolation is an exciting and innovative feature. Elasticsearch is scalable and speedy, and if distributed indexing is needed then Elasticsearch would be the right choice. If you’ve already invested a lot of time in Solr, stick with it, unless there are specific use cases that it just doesn’t handle well. If you need a data store that can handle analytical queries in addition to text searching, Elasticsearch is a better choice. At the end, Solr and ElasticSearch are very close to each other in feature sets, and it would be really difficult to make a decision on one or the other, without really knowing the exact requirements. What is Elasticsearch? “Elasticsearch is a highly scalable open-source full-text search and analytics ...

Lando : What, How and why

Lando is for developers who want to easily specify and quickly spin up the services and tools needed to develop their projects. It is a free and open-source local development environment built on Docker container technology. What makes Lando so great? 1 - Built pn docker(no need to manage local services) 2 - simplifies container management(abstraction layer) 3 - Quick & painless setup 4 - cross-plateform support(mac,window,linux) 5 - single configuration file (that lives in git) 6 - Highly configurable How to Install the drupal8 recipe and run :  You'll need a Drupal codebase, so go somewhere on your computer and use Git to clone it: git clone --branch 8.6.x https://git.drupal.org/project/drupal.git lando-d8 Change into the Drupal directory: cd lando-d8 Run lando init, answering drupal8, ., and Lando D8. Run lando start, and wait while all the Docker containers are set up. Run lando composer install (this will use Composer/PHP inside the Docker container t...

Use meld with git as a mergetool & difftool

Git config global as a merge tool meld: 1 - You can use a function like git config global mergetool meld or directly enter these below values in .gitconfig file(located in user or home folder) [user] name = XXXX email = XXXX@YYY.com [merge] tool = meld [diff] tool = meld [mergetool] prompt = true How to use : 1 - to compare the change in files 2 - compare the whole branch git difftool -d dev_backend_changes  Now my current directory branch is alpha_hd_api so it will pick up automatically, Current branch must be the branch in which I would like to write the changes, So in the meld tool, the left would be the dev_backend_changes ---- alpha_hd_api Now simply copy the changes from left to right & merge the changes

What is docker & vagrant and how to use it

Why Need Docker :  Lets suppose we are working in a large application which needs ,Drupal 8 ,PHP7.4, Mysql 8, Redis server, Mongodb,solar server, nodejs server etc. And at the same time I also give maintenace for another project on drupal 7, But it needs some old version of php, mysql,redis etc because it is old project developed 4 year before. So it's too complicated to run both the project in same machine just because of dependencies, Proublem 2 : Lets suppose in local we work on apache & sqlite & on production nginx & mysql, So may be some issue should be raised in production, To handing this type of situation Docker & vergant is much helpfull. How is Docker Different from Vagrant?: Docker :  Docker  is often described as "lightweight," because it simply provides containers within the host machine's Linux operating system. Docker containers hold an application's components, including binaries, libraries, and configurations, as we...

Unit Test With Drupal 8

Types of tests: Writing tests All PHP-based tests for Drupal core are written using the industry-standard PHPUnit framework, with Drupal extensions. There are several categories of tests; each has its own purpose, base class, namespace, and directory: Unit tests: Purpose : Test functionality of a class if the Drupal environment (database, settings, etc.) and web browser are not needed for the test, or if the Drupal environment can be replaced by a "mock" object. Base class :   \Drupal\Tests\UnitTestCase Namespace : \Drupal\Tests\yourmodule\Unit (or a subdirectory) Directory location : yourmodule/tests/src/Unit (or a subdirectory) Kernel tests: Purpose : Test functionality of a class if the full Drupal environment and web browser are not needed for the test, but the functionality has significant Drupal dependencies that cannot easily be mocked. Kernel tests can access services, the database, and a minimal mocked file system, and they use an in-memory pseudo-installation. Howe...