Skip to main content

Posts

Showing posts from 2020

How deploy your angular project on GitHub Pages

Step 1:- Create Repository on github Note :- Open terminal and goto your project direcoty then run following command which you got after created repository. Step 2:- git init Step 3:- git add . Step 4:- git commit -m "first commit" Step 5:- git branch -M main Step 6:- git remote add origin https://github.com/rahuldrupal5788/DevR9angular.git Step 7:- git push -u origin main Step 8:- We need to build our code in production mode for that we will create deployment files that will be deployed on GitHub Pages. By default, this deployment code is generated in the /dist/<ProdectName> folder under the angular project folder, but we need to generate this in the "docs" folder under the angular project folder. So, we need to make a small change in the angular.json file and change the outputpath value to "docs/". Step 9:- Run the following command with the baseHref  option in the git bash window to generate deployment files in the docs folder. ng build --prod --b...

How to Install Angular 10 CLI and Setup an Angular 10 Project in Window 10?

In this blog, we will install Angular CLI and setup a new Angular 10 project. There are following steps :- Step-1 Here, We should check some prerequisites before setup angular project. System requirements Windows 10 OS 4 GB RAM 10 GB free space Step -2 Before install angular cli we will need nodejs and npm. What is Nodejs and why we need for angular development ? Node.js is an open-source, cross-platform JavaScript run-time environment that executes JavaScript code outside of a browser. we use javascript to develop angular web application. Download Node Js from below url and run setup ( https://nodejs.org/en/download/?utm_source=blog ) Test Installation Open command line interface then run below command   node -v Step -3 What is npm and why we need for angular development ? Npm stands for node package manager, it is a dependency management tool for javascript applications. This tool will help to install the libraries and other tools to support angular development. Step -4  Ins...

How to install & enable the drupal commerce modules using composer in drupal 8

There are following steps that how to install & enable the drupal commerce modules using composer in drupal 8.9.6 Download Modules and Dependencies Step 1 :- composer require 'drupal/commerce:^2.21' Step 2:- composer require 'drupal/rules:^3.0' Step 3:- composer require 'drupal/ludwig:^1.0' Step 4:- Address Packages URL: /admin/reports/packages Install Modules and Dependencies Step 1:- vendor/bin/drush en address rules ludwig Step 2:- vendor/bin/drush en inline_entity_form entity_reference_revisions state_machine profile Step 3:- vendor/bin/drush en commerce commerce_cart commerce_checkout commerce_log commerce_number_pattern commerce_order commerce_payment commerce_price commerce_product commerce_promotion commerce_store commerce_tax Step 4:- Enable the trusted_host_patterns setting in the settings.php file $settings['trusted_host_patterns'] = [   '^www\.example\.com$',   '^localhost$', ]; Step 5:- Now navigate to the drupal commerce...

How to fix TRUSTED HOST SETTINGS Not enabled Error on localhost

Trusted host setting for XAMPP Server To enable the trusted host setting, we need to enable our hosts in $settings['trusted_host_patterns']. Open the "settings.php" file and update the below code to enable the trusted host setting: $settings['trusted_host_patterns'] = [      '^localhost$',      '^192\.151\.3\.101$',      '^127\.0\.0\.1$', ]; Here, '^localhost$',: This will allow the site to only run from localhost. '^192\.151\.3\.101$', : This will allow the site to only run from system IP '^127\.0\.0\.1$', : This will allow the site to only run from 127.0.0.1 instead of localhost. Note: When we are running multisite then we will define all host patterns that are allowed by the site.

Event Subscriber Instead of Hooks

drupal_hook_events.info.yml name: 'Drupal hook events' description: 'Events Subscriber instead of hooks' type: module core: 8.x dependencies:   - 'drupal:hook_event_dispatcher'  drupal_hook_events.services.yml services:   preprocess.hook_entity_view:     class: 'Drupal\drupal_hook_events\EventSubscriber\EntityViewSubScriber'     tags:       - { name: 'event_subscriber' } drupal_hook_events/src/EventSubscriber/EntityViewSubScriber.php <?php namespace Drupal\drupal_hook_events\EventSubscriber; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Drupal\hook_event_dispatcher\HookEventDispatcherInterface; /**  * Class EntityViewModeAlterEventSubScriber.  */ class EntityViewSubScriber implements EventSubscriberInterface {   /**    * {@inheritdoc}    */   public static function getSubscribedEvents() {     return [       HookEventDispatcherInterface::ENTITY_VIEW ...

Install PHP & MySQL on Amazon Linux 2

Install PHP sudo yum update -y sudo amazon-linux-extras install -y php7.3 sudo yum install -y httpd sudo systemctl start httpd sudo systemctl enable httpd sudo systemctl is-enabled httpd sudo systemctl restart httpd echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php Install MYSQL 5.7 1. sudo yum update -y 2. sudo wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm 3. sudo yum localinstall mysql57-community-release-el7-11.noarch.rpm  4. sudo yum install mysql-community-server 5. sudo systemctl start mysqld.service     or    sudo service mysqld start    or    sudo service mysqld status   6. To get the default password    sudo grep 'temporary password' /var/log/mysqld.log  7. mysql -u root -p 8. Change the password    mysql_secure_installation Remove anonymous users? (Press y|Y for Yes, any other key for No) : y Success. Normally, root should only be allowed to con...

How to create store and reducer in redux

The whole state of your app is stored in an object tree inside a single store. The only way to change the state tree is to emit an action, an object describing what happened. To specify how the actions transform the state tree, you write pure reducers. import  { createStore, combineReducers }  from   "redux" ; /** * This is reducer, a pure function with (state,action) => state signature. * It describes how an action transforms the state into the next state. * * The shape of the state is up to you: it can be a primitive, an array, an object, * or even an Immutable.js data structure. The only important part is that you should * not mutate the state object, but return a new object if the state changes. * * In this example, we use a `switch` statement and strings, but you can use a helper that * follows a different convention (such as function maps) if it makes sense for your * project. */ // User operation reduc...

How to Configure Virtual Host on Windows 10 and Drupal 8 Multisite on localhost

The following guide will highlight the virtual host configuration in window 10 and manual set up a Drupal 8 multisite.  Overview of Druapl 8 Multisite Setup : 1. First Install a Drupal 8 site that will act as the main site for our multisite. Exp : the main site will be called d8multisite, will be reachable at localhost which setting present in virtual host, and will be installed at C:\xampp\htdocs\d8multisite 2. Set up two site within the multisite called site1 which is reachable at site1.localhost and site2 which is reachable at site2.localhost 3. Site1 and Site2 have its own modules outside of the root site. Step 1: Install the main drupal site 1.1) Download and extract drupal 8 site setup from drupal.org into xampp directory(C:\xampp\htdocs\d8multisite) 1.2) Create a database for the main multisite, exp: d8multisite. 1.3) Configure virtual host for the main site(d8multisite).    (1.3.1) Got to following path of xampp C:/xamp...