Road ahead for Drupal 8 contributed projects

The statistics around cyber security are alarming. Around 30,000 websites are hacked globally on a daily basis. As many as 64% of the companies across the world have faced one or more kinds of cyber attack.

Given that Drupal core version 8 series reached end of life on November 2, 2021, does that mean that you’re really left in the midst of the ocean without an anchor to secure you? What happens to contributed projects after Drupal 8’s end of life? In this blog, we discuss such concerns that you may have.

What is Drupal 8 End of life?

Drupal core version 8 was released on November 19, 2015. It’s shelf life ended on November 2, 2021, which is also known as Drupal 8 end of life. This means that the Drupal official community will not provide security support for any of the earlier releases of Drupal 8 core or contributed project releases that are compatible with only Drupal 8. So, there will neither be any further Drupal 8 releases nor any updates to previous releases or security patches even to critical threats. The dedicated security team from the Drupal community shall not actively test or review the contributed modules for Drupal 8.

Why End of Life Now?

There are three-fold reasons why Drupal 8 end of life happened. Firstly, Drupal uses multiple third-party dependencies, such as Symfony, Twig, PHPUnit, and CKEditor 4, among other components. Drupal 8 uses Symfony 3, which reached its EOL in November 2021. Security support for CK Editor 4 also ended around the same time. So, Drupal cannot support backward compatibility, and had to move on with newer versions for Drupal 9, letting go of Drupal 8.

Secondly, the Drupal community wanted to introduce more features through Drupal 9, maintaining what Drupal is known for- its uniqueness. Forking Symfony 3 and maintaining it with Drupal could’ve been an option had Drupal wanted duplication of that effort. However, the Drupal community wanted more autonomy and innovation. Also, effort duplication does not come across as an ideal practice.

Thirdly, the Drupal 9 upgrade is not as significant an architectural change as Drupal 7 to Drupal 8. And that’s the reason why the Drupal 9 adoption has been fastest among any previous versions. It took only one month for 60000 Drupal sites to migrate to Drupal 9, compared to seven months for migration to Drupal 7. In such a situation, continuing with Drupal 8 doesn't sound logical for users as well.

Switch anchor to avoid sailing solo

Do you feel you are sailing solo post Drupal 8 end of life? Well, yes and no! The real answer to this is that while you still have time to upgrade to the higher version, i.e., Drupal 9, you’re not entirely sailing solo in the rough patch. It just means that the anchor, Drupal 8, which supported your ship is no longer there. So you may still be hanging in there, but if the high tide topples your ship, there isn’t a life boat that’s coming to save you.

In business terms, it means that your site may be open to malicious attacks without security support from Drupal. With the alarming rise in web attacks, migrating to Drupal 9 or Drupal 10 just ensures a permanent security net for you.

Whether you have earlier contributed projects in Drupal 8 or are using them for your site, knowing the compatibility status of the contributed modules helps you in many ways. You can check the same from the Drupal 9 deprecation dashboard. In fact, about 88% of the top 1000 contributed modules are also compatible with Drupal 9, which means that they have usability in both Drupal 8 and 9.

Moreover, 50% of all Drupal 8 contributed modules are also compatible with the newer Drupal version, while 20% of these only require upgrade of info.yml file or/and composer.json file for them to be Drupal 9 compatible.

If your contributed project such as module or theme is compatible with Drupal 7 or 9, and has already opted for the security coverage, you shall continue to receive security advisories. Drupal 7 end of life or shelf life is until November 2022, while Drupal 9 end of life will happen in November 2023.

Upgrade is more than just security fix

Migrating to Drupal 9 helps you get enticing features of this version. Features such as richer media management, accessibility of powerful visual designing, front end facilities, intuitive designs, and improvement in further migration, can help you or your clients reap several benefits in the long run.

With such innovative features of newer Drupal versions, and ease of upgrade from Drupal 8, migrating to these higher Drupal versions is more than just a security fix. Keeping future roadmap plans in mind as an immediate action step, a thorough compatibility assessment, and Drupal 9 readiness audit for your site and contributed projects should be done.

Valuebound’s Journey to Great Place To Work Certification: Interview With Abhijit Upadhyay

Valuebound, the leading digital transformation company, recently earned Great Place to Work® certification for the year 2021-22. Abhijit Upadhyay, Valuebound’s Chief Operating Officer, shares the journey to the most prestigious “employer-of-choice” recognition in this interview. 

Taking into perspective the 10-year long history of Valuebound, what do you have to say about Valuebound’s accreditation in 2021 as a Great Place to Work® (GPTW) -certified organization at this stage?

Abhijit: Perseverance and accepting the need for change helps any individual or an organization to transform. This 10-year-long journey has given us the opportunity to learn and improve upon employee experience. The grind of 10 years has enabled us in making key policy changes, the result of which is here for you to witness.

What according to you makes an organization a great place to work? And in the context of Valuebound, what do you think are Valuebound’s unique policies or ethics that earned it GPTW certification?

Abhijit: For me a great place to work must be able to give a sense of belongingness towards the organization, so that the employees feel self-motivated towards their professional goals, and company’s objectives, on the whole.
Pace of change speeds up, when the entire team is thoroughly driven towards a common goal. And, this can only happen when each one of us has a common gene in our DNA and that is of ownership.

If I talk about myself, I give one third of my valuable time of the day to the organization and to ensure my other two third of the time is happy. I need to take that happiness back to my home. This can only happen when my workplace is a fun place to work for every single employee.

What would be your message to a prospective employee of Valuebound?

Abhijit: Success of a journey depends upon how you start it and with whom. I am sure together as one team we will define each others’ journey paths and be a guiding light to each others’ career.

Between people and revenue, how do you balance? The pressure of revenue, hard decisions etc. impacts the environment. How do you manage this inherent dichotomy?

Abhijit: We are in a growth stage right now, so definitely revenue is an important fuel to propel growth. However, I also strongly believe that if we invest in people  right now and always. In the short term it may feel that our margins are impacted, but the long term benefits will outweigh any counter theory. It’s important to invest in people's engagement for the enduring success of an organization.

India is at a cusp of digital literacy and digital transformation. There's extensive support for the IT industry in the present scenario. Where do you see Valuebound in the light of this scenario?

Abhijit: Traditionally we have catered to the digital needs of big enterprises, three of which happen to be fortune 500 companies. However, in the last few years we have taken a conscious decision to collaborate with start-ups and help them in translating their ideas into products and solutions. Start-up space in India is warming up and we see a great opportunity for us to play the technology partners to the young and upcoming entrepreneurs or help them improve and scale up the process. We are working with few unicorns and have enabled delivery at a faster pace. Enterprises are shifting away from traditional concepts of technology delivery. They are open to work with organisations of our scale and have been continuously giving us opportunities to deliver the goods. 

Office culture and working scenario have changed a lot after COVID. What do you think is the role of an organization to smoothen people’s journey into this new mindset while also coping with the pressure of changed working dynamics?

Abhijit: As an Organization we focus on our employee’s mental and physical wellness. Our policies and programs have consistently focused on ensuring there are no red lines crossed when it comes to having a good work-life balance. I would like to thank our employees for the agility they have shown in recalibrating their working ways due to the pandemic. There has not been any significant impact on economic dynamics. I also want to extend my gratitude to all our clients for being accommodative in these testing times.

If you were to change three things about Valuebound for the better at this stage, what would they be?

Abhijit: As stated earlier, we are in the transformation phase where we are bringing in changes. This paradigm shift is happening at all three transformation levers, namely people, process, and tools.

GPTW certification is seen as a gold standard for any organization. Now since Valuebound has been recognized as one of them, what’s next in store after GPTW certification? What are your next steps  to make Valuebound even better?

Abhijit: GPTW certification comes with the responsibility of maintaining the momentum and improving ourselves. Workplace becomes great only when we continuously work towards improving the employee engagement and experience. We are growing at a rapid pace and to extend the same experience, to wow our employees at a bigger scale is something that I am looking forward to.

In the end I would like to summarize by extending my warm gratitude to our employees, leadership team, and most importantly clients for being a part of wonderful 2021. Looking forward to 2022. Happy New Year and Happy Holidays to you all, from all of us at Valuebound.
 

Product engineer vs. full stack engineer: How are they different?

Increased demand for faster deployment of projects, continuous iteration and innovation, and reduced production cost are some of the key drivers that have led to the rise in demand for product engineering services today. In this blog, we shall discuss how product engineers are different from full stack engineers in their characteristics, roles and responsibilities.

In 2021, the product engineering market grew to $1,003.12 billion from $676.17 billion in 2016,  as per latest Market Research Report on product engineering services. There has been an increasing inclination towards new-age engineering models on the lines of digital technologies so as to develop more innovative products at a faster Time To Market (TTM). The report highlights that the increasing need for communication technologies and electronic components has led to a drastic demand for product engineering in the present times.

Product engineer vs full stack engineer: the key difference

The term product engineering comes from an engineer’s capabilities to drive the project of  organizing and running the product development  in an efficient manner. Product engineering charts an engineer’s journey through a product's lifecycle, i.e. from the conception of an idea to the entire deployment of that idea as a successful product.

Full stack engineers know not only the basic CSS and HTML languages, but also how to program a server, browser, and database.  There could be full stack front end engineers that work on client software, and full stack back end engineers that work on server software.

Full stack engineering includes skill sets like business logic, designing, managing hosting services, server, data storage, among others. It focuses on the means of a goal. Meanwhile, product engineer refers to an engineer’s ability for end goal delivery.

Rise of Product Engineering

The rise of popularity of product engineering emerged from business’ need for moving towards advanced techniques while mitigating risks. The concept levels up from the traditional methods of engineering, and calls for accelerating the pace of massive transformation with budget-friendly and faster TTM solutions. 
A Product engineer effectively builds a product and shapes it through his/her strong technical opinions and perspectives, along with the business ideas led by the company. This enables robust technical trade-off resulting in a sound product.

Phases of Product Engineering

Different phases of product engineering are:

  • Ideation phase: At this stage, product engineers estimate technical functionalities and chart out a detailed project plan. 
  • Architecture, Designing and Development phase: Creating the project architecture, designing of the project and developing a plan which is not just user friendly, but also cost effective, is an essential part of the phases of product engineering. 
  • Testing phase: Comprehensive testing before actual deployment of the product is among the crucial aspects of the product engineering process. Functionality testing, making necessary iterations and making adjustments is the role of a product engineer before actual product deployment through migration and porting. 
  • Technical support, Servicing and Sustaining engineering phase: Whether a product meets the quality requirements, analyzing feedback from users, implementation of future version updates are the last, but ongoing phase of the product engineering lifecycle.

Conclusion

The role of both full-stack engineer and product engineer are essential since the former ensures product delivery, and the latter is responsible for a strong technical voice, eye for finding the problem, and decision making. While the two roles go hand in hand, the business approach from product engineers lends them a higher seat at the table.

Creating CRUD API using NodeJS and MongoDB

While building a student management system in a project where the tech stack includes NodeJS, Express JS & MongoDB, I had to create an API to make student data available for consumption by other enterprise applications as well as mobile apps. For this, I had to create the CRUD App API and test the same in Postman. In this blog post, I am sharing my learning in a step-by-step process.

We combine CRUD APP API, ExpressJS, and MongoDB as a single architecture as shown below.

Architecture of NodeJS, MongoDB and API interaction

Prerequisites:

  • If you know the basics of Javascript it will help you to understand functions.
  • You need to have Node installed.
  • MongoDB with MongoDB Compass installed.

Now we build the CRUD APP

How do we model our app? Here I am using a standard and best practice project structure to build CRUD App.

We start by separating out logical building blocks or folders like below:

  • Config: This is used for changing ports, running projects, and other configurations.
  • Routes: To create route files for the individual route (like user-route, student-route, admin-route, etc ) and map these to Controller.
  • Controllers: Here we write logic (like user-control, student-control, etc).
  • Model:Here we define our Schemas.
  • Middlewares:Here we define some middleware like authentication check, security check, user check, etc.
  • Test: This is used while testing our node application.
Let’s start creating Schema for our CRUD API

As I am creating a CRUD app for Students, I named the folder as Students-App. You may give any related name of your project as a standard naming convention.

Folder creation for Project

Here we install the application generator tool which has preinstalled express, called express-generator, to quickly create an application skeleton. You can visit this Express application generator to know more about Express Generator.

Install express-generator using below cmd:

npx express-generator

After installing Express Generator, one must install necessary packages like,

  • Install node_modules by the following command:
        npm install
  • Install Nodemon the following command:
       npm install nodemon --save-dev
  • Install mongoose
       npm install mongoose

You can see the below code structure given by Express Generator.

Only the Models folder is newly created to write our models, while the others are created while installing Express Generator.

Express generator project folder structure

Running Node for the first time

The easy way to use a node is to run the node command, and specify a location of a file. As we are using Express Generator, it provides a script key in the package.json file to run our Express.

Script key to run our project

We use the command npm start in Command Prompt and get the result as shown below-

running the project using npm start command

Now you can open any web browser and type URL localhost:3000. Once you hit Enter, you see the following result which I get from routes/index.js. It is created by Express Generator and contains the HTTP GET method with the title: ‘Express’ which I changed to ‘Express and MongoDB Student CRUD APP’ as shown below.

the basic page of our project after running npm start command

Awesome..!! We successfully run our App.

Let’s run using Nodemon. This will run the server automatically.

Note:

We use a --save-dev while installing nodemon because --save-dev adds nodemon in a devDependency in the package.json file as shown in the image below.

Saved nodemon in package.json devDependencies after installing nodemon using --save-dev

Now, you can use the nodemon start command to run the App.
terminal screen after nodemon start command to run the App

You can see in the terminal (command prompt) like above and you don’t need to stop the server, and restart. When changes in code occur it restarts automatically, and code is saved on the auto mode. You can check output in any browser by searching the url localhost:3000/.

Let’s install the Postman App

Postman is a GUI that helps in the testing of our APIs which were developed by Express and view their responses in an organized way. Everything we perform in Postman can also be done through the command line, but Postman makes the process faster and easier by providing an interface and powerful set of tools.

Download/Installation
You can download Postman from Postman. Let’s open the POSTMAN App and enter the URL.
In our project, the starting URL will be => localhost:3000/. Don’t forget to run the project because to get data in POSTMAN you need to run the project using the command nodemon start.

After running the project, open the postman app

opening the downloaded postman app to test api's

Follow the below steps:

  1. Enter the URL of your project i.e: localhost:3000/.
  2. The default HTTP method will be GET. You can select different methods by clicking on the GET list of the POSTMAN App.
  3. Let’s see the GET method, by using URL localhost:3000/ and click Send

after running get method in postman app

Note:

  • As We can see Status: 200 OK, which means the request has succeeded. I should say you need to have basic knowledge of the Status codes so you can visit this Status Code link and understand the codes.

I think now you are able to create an API and get in POSTMAN as we have created an API as localhost:3000/, the URL is based on app.js as we can see below / (forward slash) is passed for indexRouter.

app.use( '/', indexRouter);

Creating Database using MongoDB

The image below is an image of Creating Database using MongoDB Compass which I downloaded while installing MongoDB. Here I am creating a Database named CRUDAPP for our Student management system.

creating database for our project using MongoDB Compass

Now you can use the connect database into app.js as shown below.

Let’s Create our models, open a folder named model in the Students-App folder and also have a new file named student.model.js. I am creating the CRUD API for Student-APP and writing the code for creating Schema with export. We can also use it in other files where we need that model, as shown below,

Note:

  • mongoose.model(“collection_name”, SchemaName)
  • Collection_name, nothing but table name to be saved for creating Student Schema in Database.
  • In the screenshot shown above, I used Student as collection_name which will be created in database CRUDAPP in MongoDB by name “students”.

Now you can import the created model into app.js or any file by following the code shown below.

Great..! We created our first Schema.

Let’s start creating routes for Student-app. For this, we need to open folder routes and create a new file in the routes folder named student.route.js. Once this step is done, start writing the below code for HTTP methods.

Note:

  • After creating the routes, it is mandatory to import or require in app.js as below,

As we can see above we are using StudentController for writing the logic of HTTP methods. For this, we need to create a new folder named controller and inside that folder create a new file named student.controller.js, which contains the code shown below.

creating controller folder to create our controllers for routes

The student.controller.js contains below logic code to perform HTTP methods.

Testing APIs with POSTMAN

Once again run the server using, nodemon start command and open the POSTMAN App to test our APIs as below:

1. GET method:

Reading data or documents from MongoDB. We get documents when we run GET method in postman using GET URL - localhost:3000/students/get-all-students We get resultFound = 0 as student collection with no data or documents as shown below,

postman result after running the GET method

In the above image, we can find that Status: 200 OK means route successful but as in Body we can see that the resultFound=0, as no data is shown in the collection. In headers it will take Content-Type: application/json as our MongoDB deals with JSON data.

2. POST method:

Our next step requires adding documents to the MongoDB student collection.
Here we going to add one document to our student collection as in json format in Body as raw data using POST URL- localhost:3000/students/add-student as shown below.postman result after running the POST method

In the above image, we can see that the data in Body - raw is data to be stored in the student collection, and below is the result that data has been added successfully with Status: 200 OK.

If we run the GET URL once, we get the following result. As we can see now, resultFound is 1 as shown belowpostman result after adding document or data to Database and running the GET method

3. PUT method:

In our next step, we shall be updating documents in the MongoDB student collection.
Here we are going to update one document by ID in our student collection as json format in Body as raw data using PUT URL-localhost:3000/students/update-student? _id=616e84911ecc7cb39a4cfbcc And, as below using _id as in URL.postman result after running the PUT which is update method

In the above image, we can see the firstName and age initially were Ram and 22, respectively. But in the GET and POST method, now I am updating it to Ramesh and 24, respectively. You can see the response in Body below Status: 200 OK. You can run the GET URL to see changes in the student collection.

4. DELETE method:

Deleting one document in MongoDB student collection using its ID.
Here you are going to delete one document by ID in our student collection using DELETE URL - localhost:3000/students/delete_student?_id=616e84911ecc7cb39a4cfbcc as shown below using ID in params.postman result after running the DELETE method

 As you can see the result is that the data which is having _id=616e84911ecc7cb39a4cfbcc has been deleted. You can see it running the GET URL once again, which gives resultFound=0 as below.postman result after deleting document and running the GET method

 
Given below are the POSTMAN App links  

  1. CREATE: POST method
    localhost:3000/students/add-student
     
  2.  READ: GET method
    •  GET all students list
          localhost:3000/students/get-all-students
    • GET student by First Name        localhost:3000/students/getStudentByFirstName?fisrtName=Harpreet
       
  3. UPDATE: PUT method
     localhost:3000/students/update-student?_id=616d87940152a10f30df9ce8
     
  4. DELETE: DELETE method
    localhost:3000/students/delete_student?_id=616e7216d0bf5739dda22b86
     

    We learned a lot in this tutorial. Here’s a list of things we worked together:

    • Understood how to create, read, update and delete documents from MongoDB.

    • Created a Database in MongoDB.

    • Save, read, update, and delete from MongoDB.

    • Tested our CRUD APIs in the POSTMAN App.

    You may now start trying to explore new things like using different data types while creating Schema, validation, and authenticating your routes using jwt, etc. Now you know about creating a simple CRUD API with Node, Express, and MongoDB. Here’s wishing you luck in order to start creating more applications.

     

How to navigate between screens in a React Native application

Navigation is very important in any kind of application e.g. in Whatsapp we have to switch between different screens frequently, like coming back to the Chats screen from the settings screen or checking Status screen from Calls list screen. In this blog post I would explain how can we add navigation system between screens using the React navigation library.

For demonstration purpose we will build two screens, HomeScreen and AboutScreen. We’ll add this button to navigate between these two screens.

Prerequisites -

Step 1:

(a) At first, Create a new React Native app using below steps

  • In your terminal change the path to the directory/folder where you want to create your project.
  • Run command :

    npx react-native init my_first_rn_app
            command to create new project in react native
            

After installation, the terminal of the newly created React-native app will look like the image shown below.

This screenshot shows the status when project has been created

Step 2:

Open project in VS code (Or in any editor) and then open terminal.

(a) At first Install @react-navigation/native

npm install @react-navigation/native

(b) Install @react-navigation/stack

npm install @react-navigation/stack

(c) Now Install all the peer dependencies one by one

npm install @react-native-community/masked-view
npm install react-native-screens
npm install react-native-safe-area-context
npm install react-native-gesture-handler

Step 3:

Open the App.js file and replace your code by the below code:

Step 4:

(a) Create Home screen

  • Create a HomeScreen.js file and place the below code in this file

(b) Create About Screen

  • Create AboutScreen.js file and add the below code in this file

Step 5:

Running our app
Command:

npx react-native run-android

After running your app, the screen below will appear.
This screenshot shows the home screen

Now Click on the ABOUT PAGE button and the screen shown below may appear.

This screenshot shows the about screen

You can click on BACK TO HOME to navigate on the home screen or by clicking on the back icon at the left top.

Conclusion:

We built an app with two screens i.e home and about. We have used the React navigation library. We learnt about this.props.navigation which is used to inherit props from the navigation object. There are more ways like i.e. React Native Router Flux, React Router Native, etc to achieve routing in react native. I will be covering these in future articles. Stay tuned.

Best Techniques to Optimize Angular Application for Website Speed and Performance

Poorly performing web applications can delay the opening of pages, and hence annoy the end-users. For instance, while purchasing an item on the app if a user faces a delay or a glitch at the checkout, it may refrain a consumer from using the app. Any website that offers more delayed time, slow loading of pages and runtime errors, tends to lose consumers. In order to avoid such issues one must improve application performance and reduce the load time of apps. 

There are some methods to fix, speed & performance issues of the application. We can follow certain tips and techniques to overcome speed and performance issues of an app.

After completing the application build process, we can check the performance and speed with the help of a google GT Metrix website.

GTmetrix website will help us to check your website performance.

 

There are good default features in Angular CLI so we can do required optimizations to the sites while developing. 

Mentioned below are some of the best methods which are useful for speeding up the web sites and reducing the load timing. All these methods can in turn speed up the website performance. The methods which we are going to elaborate further in this blog include-

  • AOT (Ahead -of-Time Compilation)
  • Lazy Loading
  • Minification
  • Optimize Images 
  • Enable Gzip Compression
  • Leverage Browser Caching

1. AOT (Ahead-of-Time Compilation)

Before running the code, AOT Compiler will convert your Angular HTML and Typescript code to the efficient Javascript Code. By using Ahead of Time Compiler, compilation only happens once, while you build your project.

The purpose of using AOT Compiler.

It can minimize the size of the application. The browser doesn't need to compile the code in run time, it can directly render the application immediately without waiting to compile the app first. So it provides immediate component rendering. The Ahead of time compiler will detect any of the template errors before time. It detects and reports template binding errors during the build steps itself before users can see them.
You can compile using CLI commands with the -- AOT switch to take advantage of AOT optimizations:

AOT - CLI Commands for Build And Serve Compile.

2. Lazy Loading

The main purpose of using Lazy Loading is to reduce the load time. Lazy Loading allows loading JavaScript components when a specific route is activated. It will improve application load time speed by splitting the application into many bundles. When the user navigates by the app, bundles are loaded as needed. Lazy loading helps to keep the bundle size small. It loads JavaScript components asynchronously when a specific route is activated.

3. Minification

Minification will reduce our code's file size and allow us to code without impacting load time. It removes all unwanted whitespace and Comments Unwanted Variables from the file in order to make our files as small as possible. It can be helpful in reducing the js files for faster downloading. 

Example:

Before Minification:

var app = angular. Module ('mainApp', []);    
app.Controller ('First Controller', function ($scope) {
    $scope. Name= 'Hello World!';});

After Minification:

Var app=angular.module("mainApp",[]);app.controller("FirstController",function(e){e.name= 'Hello World!'})

4. Optimize Images

Optimizing images could be the main source for improving site speed. Before uploading images on site, maximum tries to upload the images in KB size rather than uploading it in MB. It’s always preferable to convert a large file into a smaller size. It is also one of the best techniques for reducing the load time of applications.

5. Enable Gzip Compression

According to Google statistics if the page load time increases from one to three seconds, then website bounce rate will be above 30%. By using the Gzip compression process, we can reduce the big file sizes into small sizes. In a simple way we can say it is the lossless data compression method on the web. It will reduce the size of your site’s HTML pages, stylesheets, and scripts.

6. Leverage Browser Caching

The leverage caching mechanism will keep users' website data information for specific time intervals. The most important cache mechanism for page speed is browser caching. Most of the static files that are used on web pages can be saved on the computer for future access. For Example, if a user visits the same website multiple times these files will be accessed from your computer instead of getting from the server-side. It is a good technique for speeding up the page load timing. 

There are a few more techniques for increasing your website speed and performance, which include:

    1. Use a Content Delivery Network (CDN) to minimize the distance between the visitors and your website’s server. A CDN stores a cached version of its content in multiple geographical locations.
    2. Reduce the number of HTTP requests if possible.
    3. Remove Unwanted/ Unused Plug-ins and try to reduce the use of Third-party plugins.
    4. Specify a character set in the HTTP headers so that the browser will know which character set you are using and doesn't spend extra time.
    5. Remove all unwanted code and commented code.
    6. Remove unwanted files from the library.

Conclusion:

While developing the application it’s not necessary to utilize all techniques together. Depending upon your application requirement you can implement the technique that best suits you. So these are some of the best techniques you can follow while developing the sites to reduce loading time of your website and to increase the website performance. 

How to add icons to react-native app

In this blog, we are going to learn how to add a launcher icon to react native apps. Launcher icon or app icon is used to represent apps. This icon will appear in your phone’s home screen app list.

There are multiple ways to do it like using android studio or manually adding the images in the src folder. In this blog we will focus on the method that uses android studio.

Prerequisites : -

Here is your step by step guide to add icon to react native app: -

 

Method 1 : (Using Android Studio)

Step 1 :- (You can skip this step if you are working on an existing project)

Create new React Native Project by following the below steps -

  • Open terminal
  • Change the directory/folder where you want to create your project.
  • Run command :

    npx react-native init my_first_rn_app

    command to create new project in react native

After installation, the new React Native project will look like the image shown below.

After installation view of command prompt

Step 2 : - 

(a) Open android studio
(b) Open android folder of newly created project in android studio

project structure in android studio

(c) Wait till completion of Gradle build
(d) Open Image asset : - 

  • Open app folder
  • Right click on res folder
  • Click on new
  • Click on Image Asset
    image asset path in android studio

Image Asset will look like below image

image asset configuration

(e) Configure Image asset
There are multiple options to configure image asset but we are going with the default configuration.

  • Choose your icon image path and click next (After path selection, you can see your icon preview in different shapes)
  • Click finish ( It will generate a drawable folder in src. It contains xml file)
    drawable folder after image asset configuration

Step 3: -
(a) Open project in VS code (or in any editor)
(b) Open terminal
(c) Start project
Command : -

npx react-native run-android

(d) Now you can see Icon in your app

icon output

Method 2 : (Without Android Studio)

Step 1 :-

  • Choose any icon which you want to add.
    For this blog, we are choosing the icon shown in the screenshot below-
    icon, we are going to use
  • Open Below Url and Upload your Icon.
    Launcher Icon generator

    User interface of launcher icon generator
  • Download the zip folder and extract it. You can customize your icon from left toolbar.

    first icon toollbar at left
    second icon toollbar at left

Step 2 :-

  • Copy all mipmap folder from the extracted zip file
    extracted icon folder which we have to copy and paste at res folder
  • Now open scr folder of your react-native project. Follow below path

    Your_project  -> android -> app -> src -> main -> res
  • Paste the copied file in res folder
    res folder after pasting the extracted icon folder

Step 3 :-

Run your Project and you will be able to see the newly added icon on the screen.

output of second method

The aforementioned methods can be used effectively to add an icon to the app using android studio. At first we created a react-native app. We opened the android folder of our project in android studio, and finally configured the image asset for the icon where we are able to see icons in different shapes. In the final step, you may check the icon in the running app.

Creating a Custom Form in Drupal 9

Forms can be used in collecting data through any source, for example, site or application. They are based on the structure of nested arrays. Drupal 9 Form API is used to create and process forms in custom modules. They are similar to the Form APIs of Drupal 7 and Drupal 8. There are two types of forms:-

  1. Config Forms - They can be defined as administrator forms.
  2. Custom Forms - It allows us to create custom fields and methods.

\Drupal\Core\Form\FormInterface” is implemented by form classes. Form API workflow is dependent on four main methods i.e. getFormId, buildForm, validateForm, and submitForm. While requesting any form, we can define it using a nested array “$form” which is easily renderable. We can use different abstract classes to provide a base class to form. Those classes are: FormBase, ConfigFormBase, and ConfirmFormBase.

To learn how to create a custom form in Drupal 9, we would create a custom module exposing a custom form that is used as a student registration form.

Step 1: Creating a custom module in the custom folder.

Follow path “\web\modules\custom”. “student_registration” is the module name here.

Folder structure to be followed while creating a custom module in Drupal 8/9

Step 2: Creating an info.yml file followed by a .module file.

In our case, it will be “student_registration.info.yml” and “student_registration.module”.

After adding info and module file, the folder structure will look like the following snapshot:



Folder structure after adding info.yml and module file to a module in Drupal 8/9

Step 3: Creating a routing.yml file

For learning process, In this blog we would create, “student_registration.routing.yml”.

A route can be defined as a path where we return some content. A routing file contains the path by which our module can be accessed. A route path can also be called a path alias. Using the path alias defined in the routing file we can execute the callback function.

A routing file is divided into four basic parts:-

  1. {name} - It is a path parameter or element which is used as $name in the controller. Here, “student_registration.form”.
  2. {path_name} - It is an alias that is used to access the page. Here, “/student-registration”.
  3. {title} - It can be defined as the title of the page. Here, “Student Registration Form”.
  4. {module_name} - It is the name of a custom module. Here, “student_registration”.

Step 4: Creating Form folder in custom module. Follow the folder structure shown in the snapshot below.

Folder structure to be followed after creating subfolders for custom form in Drupal 8/9

Step 5: Creating Custom Form “RegistrationForm” and adding namespace along with use cases in custom form.

Folder structure to be followed after adding custom form file in Drupal 8/9

A “namespace” is used to organize form classes into virtual folders and make sure that these classes do not conflict with one another.

A “use” is used to bring the dependency of core classes to our custom class.

Step 6: Implementing getFormId() to define a unique id for the form.

Step 7: Implementing buildForm() to build and process the form using a given unique id.

Step 8: Implementing validateForm() to validate the values of the form via the controller.

Step 9: Implementing submitForm() to process the form submission, only if the form has passed all validation checks.

A complete form will look like this:

Step 10: Enabling our custom module in the Drupal 9 site.

Enabling our custom module for implementation of custom form

Step 11: Visit the path we have defined in the routing file to access our form. Here it shall be “/student-registration”.

Custom_form_displaying_student_registration_form

Fill the form and hit “Register”.

Step 12: After submitting the form we can view the result as a message.

Form submission values are displayed as a result of successful form registration

By evolving through Drupal 7, Drupal 8, and now to Drupal 9, we learned how we left some hooks [hook_menu()] behind and got a replacement in the form of controllers, routes/aliases defined in yml or yaml files. We can use Form API to build forms with extended inputs, complex forms, and so on using minimal code.



FORM ASSISTANCE – DRUPAL 9 EXPIRES SOON

 

How to setup React-native in windows using Android Studio and NodeJS

I started working on React Native recently. The very first roadblock I came across was configuring React Native on my machine. Since I had minimal working knowledge of Android studio as well as Node JS it took me a few days to figure this out. I am sharing my learning in this blog post to help you fast track your initial setup.

There are multiple ways to set up a react native environment, such as using Expo CLI or React native CLI. However, this blog gives a glimpse into setting up  React native CLI. The development operating system that we shall be using is Windows; meanwhile the Target Operating System will be Android.



For this we need a Code editor like VS code and dependencies (JDK, Node, React native command line interface and android studio).

Here’s your step-by-step guide to set up React Native in Windows using Android Studio and Node.

Step 1:

(a) Install Java JDK 15

Use the below link to download Windows x64 installer-

https://www.oracle.com/java/technologies/javase/jdk15-archive-downloads.html

Here’s a screenshot of how this may appear.

jdk installer for windows

(b) Install downloaded JDK by following instructions.

(c) Next we are going to set environmental variable. Press windows key and search “Edit environment variables,” and open it.

Edit environmental variable for your account in search bar

(d) In the User variable section, click new, as shown in the screenshot below.

user variables of your system

After clicking New, You will get screen like this-

New user variable creation form

Fill variable name as ‘JAVA_HOME’ (Without single quote).For Variable value, open your C drive -> Program files -> Java -> jdk-15.0.2  and copy that path as shown below.

Variable value : - ‘C:\Program Files\Java\jdk-15.0.2’ (Without Single quote)

Filled form for new user variable for jdk

Once you press OK, you can see your variable in the user variable section (Refer to the image shown below).

final view of jdk variable in user variable section

Step 2 : 

(a) Install NodeJs (if not already installed)

Use the link given below to download the LTS version of Node(Recommended).

https://nodejs.org/en/

Node js installer for windows

(b) Install downloaded NodeJs by following instructions.

 

Step 3:

(a) Install React Native CLI

To do so, follow the below mentioned set of instructions-

  • Open Windows Terminal
  • Run command : - node -v
  • Check whether node is installed correctly or not by running command : - node -v 



    Command to check node version

     
  • Run Command : - npm install -g react-native-cli (To install React native CLI)



    react native installation command

     
  • Close the terminal

 

Step 4:

(a) Install Android studio

Use the link given below to download Android Studio-

https://developer.android.com/studio

Android studio installer

 

(b) Install android studio by following below mentioned set of instructions:

  • Open android studio and click ‘tools’



    android studio tools

     
  • Now click on SDK Manager



    SDK manager tab in android studio

     
  • Install your required android version



    List of android versions in android studio

     
  • Again click on Tools and open AVD  Manager



    Create virtual device
  • Click on ‘Create Virtual Device’
  • Choose Device definition and click next
  • Choose system image and click next
  • Verify configuration and click finish.

Once you’re done with the installation, you will be able to see your device in Android Virtual Device Manager as shown in the image below.

List of virtual devices

In the next step,  we are going to set environmental variable. For that, press windows key and search “Edit environment variables” and open it.

environmental variable for your account in search bar

Follow the below set of instructions to continue further: In the User variable section, click new as shown in the screenshot below.

user variables of your system

After you’ve clicked  New, a screen like the image shown below appears on your screen.

New user variable creation form

  • Fill variable name as ‘ANDROID_HOME’ (Without single quote)
  • For Variable value, open your C drive -> Users -> {Your_pc_name} -> AppData -> Local -> Android -> Sdk  and copy that path.
  • Variable value shall be - ‘C:\Users\HP\AppData\Local\Android\Sdk’ (Without Single quote)



    Filled form for new user variable for android
  • After you click Ok, you shall be able to see your variable in the user variable section.

    final view of android variable in user variable section

 

Step 5:

(a) Create new React Native Project

Follow the steps as mentioned below-

  • Open terminal
  • Change the directory/folder where you want to create your project.
  • Run command : npx react-native init my_first_rn_app

    Note: - my_first_rn_app is the project name. You can give any name.



    command to create new project in react native

After installation, the new React Native project will look like the image shown below.

After installation view of command prompt

The Project structure will look like below image (Open project in VS code)

React native project folder structure

 

Step 6 :

(a) Start Emulator

Following steps must be followed for this process.

  • Open Terminal at location : -

    C:\Users\HP\AppData\Local\Android\Sdk\emulator



    Path of emulators
  • Run Command :   emulator -list-avds

    It will show the list of devices (emulator)



    Command to show all available emulators

     
  • Copy emulator name.
  • Run command: emulator -avd Pixel_3a_API_29 to start Emulator

    Note : - Pixel_3a_API_29 is the emulator name



    Command to start emulator

     
  • Now our running emulator will look like the below image



    Running emulator

 

Step 7:

After we’ve followed all the aforementioned steps, we’re almost ready to run  our first app.

  • Open terminal in vs code (after opening the project in vs code)
  • Run command : npx react-native run-android



    Command to run react native app

     
  • It will start metro and emulator as well.

    Note: - Do not close opened window by run-android command

     
  • Emulator output looks like the below image



    Running app on emulator

 

And we’ve finally completed the process of React Native setup in Windows using Android studio and Node. We have successfully created an  up and running react native environment. We started with downloading jdk and setting environmental variable for it. We Installed Node js, react native CLI, android studio and android SDK; and finally set up the environmental variable for android sdk to create a fresh react native project.



 

 

Did you find our guide on "How to Set Up React Native in Windows using Android Studio and NodeJS" useful? Are you ready to develop your first React Native application? Now that you're all set up, your journey into the world of React Native has only just begun. Keep exploring, keep coding, and remember, we're here to help if you hit any roadblocks along the way. Have any questions or feedback? Let us know in the comments section below! Happy Coding!





 

Creating a custom RESTful Web Service in Drupal 9

The web is progressing and it has become quite intense for interaction between clients and websites or apps, multiple sites, databases and devices. For that the internet was demanding a new technology. One such technology which can handle this type of interaction is REST.

Before creating our own custom REST API in Drupal, we need to know what REST API actually is? It is an application programming interface (API or web API) that allows interaction with RESTful web services. Where, REST is known as REpresentational State Transfer, which was defined by Computer Scientist “Roy Fielding”.

While designing APIs, there is always a need to specify which HTTP method will be used for performing CRUD operations on data. Here, it can be made possible by using several HTTP requests like POST (Create the data), GET (Retrieve/Read the data), DELETE (Delete the data) or PATCH/PUT (Update the data). To learn how to create custom web services, we would create a custom module exposing RESTful API which can display a list of taxonomy terms from our Drupal 9 site.

Step 1: Create a custom module in the “\web\modules\custom” folder.

 

Folder structure to be followed while creating a custom module in Drupal 8/9

Step 2: Create an info.yml file as “sample_rest_resource.info.yml” along with a blank module file as "sample_rest_resource.module"

Now the folder structure will look like this:

Folder structure after adding info.yml and module file to a module in Drupal 8/9

We are now moving forward towards implementation of a rest resource using the GET method. By GET method, we need to fetch the list of taxonomy term “vb”.

Step 3: Create a folder structure in the custom module as “src\Plugin\rest\resource”.

The folder structure will look like this:

Folder_structure_after_adding_subfolder.jpg

Step 4: We will implement our resource file. For that, create a php file as “SampleGetRestResource.php” and place the file in the “resource” folder.

We’re using the “GET” method in the template, in which we define our logic in the form of code to define what output is required. As an example- we require all the existing terms title with their respective IDs for “vb (machine name of Vb Test)” taxonomy for currently logged user.

Step 5: We have created a “Vb Test” taxonomy and added two terms in that.

Taxonomy added in our site which terms we will be listing using our custom resource Taxonomy terms are added to the vocabulary

Step 6: Now let's first enable Drupal REST API which is provided by core itself.

Our module will be dependent upon the Rest and Rest UI module. The Rest UI module can be installed using this command:

“composer require 'drupal/restui:^1.20'”

After installing the RestUI module, enable both the modules and follow the snapshots attached to configure REST API.

Enable RestUI and Restful Web Service module for implementing our custom rest resource

Step 7: Let’s enable our custom module now.

Enabling our custom module for implementation of custom rest resource

Step 8: After enabling the custom module, enable custom rest resource.

For enabling custom rest resource, follow these steps:-



1. Go to “/admin/config/services/rest”.

2. Search for our custom rest resource using the id that we have created in the resource file. Here it is “Custom Get Rest Resource

Enable our custom rest resource in configuration

3. Enable the custom rest resource and do the following configuration. Hit “Save Configuration”.

Follow these changes to get your rest resource start working

Rest Resource is enabled and now ready to fetch data

4. Now go to “/vb-rest?_format=json” and the URL will result in a Taxonomy term list containing Term ID and title.

Output of custom rest resource shows the list of taxonomy terms

So we have seen REST can be used as a type of data transfer which is built, based on the architecture of the HTTP protocols. It helps us to easily send and retrieve data between two or more different services using XML or JSON. RESTful web services are loosely coupled and are lightweight web services. These are particularly used for creating APIs for clients spread across the web.



Future-Proof with Drupal 10: Migrate Today!

 

Download the Drupal Guide
Enter your email address to receive the guide.
get in touch