InfyOm Blog

latest-post

Last week, we run into a problem for one of the large Gatsby + ReactJS + Laravel projects in hosting which is hosted with Apache Webserver on Amazon AWS EC2. The problem we were facing was, for some reason, when we reload the Gatsby website, it was giving a 404 error page.

If you open a home page and then a normal visit then the website will fully function, but if you reload the page then it gives an error. And we found it happens when we are using Dynamic routing of React Route in Gatsby as per show in Gatsby documentation here.

Also, what we found, if we test the website build with gatsby serve then it works fine. But while using Apache, it behaves differently and we found that this problem has been faced by lots of people over the internet.

So what we came up with is, we used gatsby serve with an apache proxy. Here is how we did it,

Step 1 - Setup Project

As a first step, clone the project on the server and run a command, gatsby build to create a gatsby build.

Step 2 - Setup PM2 for Gatsby Serve

The next step that we need to do is run gatsby serve. But as you know, we can not run this command directly via console, because as you exit from the console, the command will be terminated.

So we will be using pm2 package, a NodeJS utility that is used to run nodejs apps.

For that, we will need to install pm2 globally. Run the following command to install it,

npm install pm2 -g

You can find other installation ways here if you need.

Once the installation has been done, let's run the gatsby serve command via pm2. For that run the following command from the gatsby project folder,

pm2 start gatsby --name my-web-app -- serve

where my-web-app you can replace with the name of your app.

Once, it's running, try to test it, if it's working correctly by opening the URL http://your-ip-address:9000/. Make sure, port 9000 is opened on your server for traffic.

Step 3 - Configure Apache

Once, gatsby serve is working and tested. The next step is to configure apache to proxy all port 80 traffic to port 9000.

For that, edit your apache conf file (or virtual host conf file), and add the following lines (or configure it to something like the following),

<VirtualHost *:80>
        ServerName my-web-app.infyom.com

        ServerAdmin webmaster@infyom.com

        ProxyRequests On
        ProxyPass / http://localhost:9000/
        ProxyPassReverse / http://localhost:9000/

        ErrorLog ${APACHE_LOG_DIR}/my-web-app.infyom.com.error.log
        CustomLog ${APACHE_LOG_DIR}/my-web-app.log combined

        ......
        # any other options below as per your need
        ......
</VirtualHost>

The next step you need to do is restart your apache server by,

sudo service apache2 restart

And then you can just open the URL https://my-web-app.infyom.com and it should work fine.

Bonus

New Deployment

Whenever you deploy a new code, you again need to run gatsby build and then pm2 restart my-web-app. Then only it will take new changes.

Troubleshooting

Sometimes, we found that we need to restart apache as well after the new deployment. so if you run into any trouble, then make sure to restart apache as well and it should solve the problem.

I hope it may help you to resolve your 404 problem.

July 16, 20213 minutesuserMitul Golakiya

Posts

post

Lots of people ask me frequently, "Which are the laravel packages that you use in almost all projects?" when we meet in Meetup or any other events regardless of its online or physical events.

Let me describe today some of the packages that we almost use in all of the projects.

We are working in Laravel for almost 7+ years and in these years we have used lots of packages, some from the community and some of our own.

I am categorizing these into 2 categories.

  1. Must used packages
  2. Common Need/Functionality specific packages

Must used packages

These are the packages which are must be included in all of our projects. No Excuses.

barryvdh/laravel-ide-helper

Laravel exposes a lot of magic methods and properties. IDE Helper is a very good package when it comes to auto-complete those properties and methods. Even it does an amazing job while refactoring properties or methods of the model.

barryvdh/laravel-debugbar

The second one is from the same author, debugbar helps to debug the request in terms of the number of queries fired, time taken by each query, number models retrieved from db, time taken by each request, and much more.

imanghafoori/laravel-microscope

Laravel Microscope improves the readability of your code. Early returns, unnecessary else statements, and many more. so your code looks clean and efficient in terms of execution as well.

beyondcode/laravel-query-detector

One of the problems that we face is, missing eager loading. In ongoing development, sometimes we add relationships objects in the loops, and then laravel fires tons of queries to the database. Laravel Query Detector detects that and gives warning while development environment.

InfyOmLabs/laravel-generator

No application can be ever built without few CRUDs. CRUDs are essential in almost all web applications. Also, APIs of that CRUDs are essentials while building a backend for Mobile or Frontend apps. Laravel Generator is our own developed package that we use in all of the applications to make the CRUD building process faster. It can be used with two themes right now, AdminLTE and CoreUI. But it's also frontend framework agnostic.

Common Need/Functionality specific packages

These are the packages that are used when we particularly need that kind of functionality in the application.

Will keep this list updating.

September 11, 20202 minutesauthorMitul Golakiya
post
Step 1: Selection of your Subject

select any selection tool for selection but select the Quick selection tool.
select your subject and press select and mask
1.PNG 951.63 KB
Step 2: Edit your Subject

  1. open property and select onion skin and transparency 50%
  2. refine edge brush tool and then refine edge
  3. Set contrasts 9%
  4. output setting on
  5. tick decontaminate colors amount 100%
  6. output to a new layer with layer mask then press OK
2.PNG 905.94 KB
Step 3: Crop Upper part of the subject

select layer mask and press ctrl + click for selection and new cut out the upper part to polygonal lasso tool. select perfectly then select layer and ctrl+j for duplicate layer

3.PNG 928.87 KB
Step 4: create an effect for Background

create Ctrl+G for group layer select the last layer and create color lookup effect.
then 3D lut file and select moonlight.3dl. and then Create a new effect black & white
Opacity set 50%

4.PNG 945.25 KB
Step 5: Create Effect for Main Subject

select the group layer and convert this layer to a Smart Object.
then create this layer duplicate. then create a color style to the top layer in linear Dodge(Add).
then go to the
5.PNG 946.37 KB


1.filter - blur - Gaussian blur Create radius - 5 for soft edges
2.Create a duplicate layer and double click on the smart filter and Create a radius of 100

6.PNG 765.61 KB
3.again Create a duplicate layer and double click on the smart filter and Create a radius of 250
4. again Create duplicate layer and double click on the smart filter and **Create a radius of 500

then add hue/saturation adjustment layer
and click on create clipping mask then click on colorize and increase the saturation to your perfect and choose a color

7.PNG 1.02 MB
Step 6: Create All effect in the subject

select main layer mask image and create effect curves.
and click on create effect curves and click on create clipping mask and curves per requirement select layer mask and select the brush tool. and set property
opacity 100%
flow 30%

8.PNG 994.62 KB
create duplicate hue/saturation effect layer and set this layer is bottom of the main object and select this layer and open property and click ok create a clipping mask.
and select the mask and make sure the foreground color is white.
and give shade to the object and you can also adjust the opacity.

Step 7: Add the sparkle and give effect

let's add sparkle and change the blending yo screen.

9.PNG 580.7 KB
then add a mask and convert to invert the layer and select brush tool.
set foreground color is white and creates an effect in the main object after creating effect open blending mode and create a level and click on create clipping mask and set property per requirement.
then open blending mode and select color lookup and set 3dlutfile to crisp_warm: look and set opacity as per requirement.
now finally ready to glow effect

10.png 473.57 KB
September 10, 20202 minutesauthorKishan Savaliya
post

Introduction

You can only develop products and services that are very effective if you pay attention to the needs of your customers and prospects. One way to understand exactly what your customers want is through research and surveys.

1. Understand your customers

You can only develop products and services that will be a big hit if you pay attention to the needs of your customers and prospects. One way to understand exactly what your customers want is through research and surveys. You should constantly invite them to give honest, brutal feedback.

Reviews and surveys are the best way to get into the minds of your customers. This makes it easier for you to develop products and services that are appropriate to the current demands of the market. Moreover, it helps you understand the area in which your company needs to improve.

2. Improving customer service

If you do not provide quality customer service, it will be difficult to satisfy your customers even if you have an excellent product or service. This aspect of the business is about taking extra steps to make them feel special. Let your customers know that they have value. If they have a problem, make sure you address them immediately. If they have questions, take the time to answer.

They should not feel that things are difficult for them if they raise specific issues. Social media is the best way to listen to and understand your customers. If they find customer service satisfactory, they may also recommend buying others from your business.

3. Establish loyalty

It takes time to encourage customers to come and buy what you offer. But just buying them is not enough. You need to promote loyalty. Considering there are other competitors who can offer them better, you want them to stay loyal to you. Don’t be satisfied just because you already have a lot of loyal customers.

They can easily be attracted to other options and they can leave you. Provide loyalty rewards. If there are discounts and discounts, let these most loyal customers be the first to know. You must make sure your customers know they are appreciated.

4. Focus on professional development

The success of your business also depends on the quality of the employees you hire. Building an effective team is the key to making sure your business grows.

One of the best ways to motivate hardworking employees is to give them a sense of purpose. They should not feel that they have to work just to work.

5. Understand your customers

Find ways to increase the sales of your existing customers It's much cheaper than finding a new one. Even if you can't expand your product line, you can still sell more of your existing product or service to a client you already have. An easy way to do this is by volume discount.

6. Participate in networking events

Take the time to build your networks - it's not what you know but who you know. Networking allows you to build relationships with other people and encourage customers to refer to you through words.

7. Give back to your community

Creating brand awareness in your local community is a great way to attract new business. Consider participating in a sponsorship or community event to enhance your business profile.

We will see more points in our next tutorial.

September 07, 20203 minutesauthorAnkit Kalathiya
post
Most of the developers are facing select2 styles removing issue when livewire render the component.

We can resolve this issue by using a livewire javascript hook.

Here is my screen with select2 before livewire component rendering.
select2-after-renrering-livewire-component
select2-before-livewire-render.png 37.21 KB


And when the livewire component is refreshed means re-render the select2 style is gone ☹️

select2-after-renrering-livewire-component
select2-after-renrering-livewire-component.png 62.48 KB

How to Fix it ?? 🤔


Well you just need to add some JQuery code to your livewire component. here we are going to use afterDomUpdate webhook of livewire. add following code to your livewire component :


document.addEventListener('livewire:load', function (event) {
    window.livewire.hook('afterDomUpdate', () => {
        $('#select2ID').select2();
    });
});

livewire:load is listening events when livewire component is load and we can add our code within it.

And now when your livewire component is refreshed your select2 style will be still there as we are again applying it.


Other Livewire Posts :

Stay tuned to us for more interesting stuffs about livewire. 


September 03, 20201 minuteauthorVishal Ribdiya
post

Software Testing Life Cycle (STLC) identifies the test activities to perform and when to perform those test activities.  While testing differs between organizations, there is a test lifecycle.

 There are mainly eight phase of STLC






1. Test Planning And Control
3. Test Analysis
4. Test Case Development
5. Test Environment Setup
6. Test Execution
7. Exit Criteria Evaluation And Reporting
8. Test Closure

Image 0.1.jpg 127.68 KB
Requirement Analysis :-

The entry criteria for this phase is the BRS document (Business Requirements Specification).  During this phase, the test team studies and analyzes the requirements from a test perspective.  

This phase helps to identify whether the requirements are likely or not.  If any requirement is not verifiable, the test team can communicate with various stakeholders (customer, business analyst, technical leaders, system architects, etc.) during this phase so that the mitigation strategy can be planned.  
Entry criteria: BRS (Business Requirement Specification) Results
Deliverables: list of all verifiable requirements, automation feasibility report (if applicable) 

 Test Planning And Control :-

Test planning is the first step in the testing process.  At this stage typically Test Manager  Test Lead involves determining the effort and cost estimates for the entire project.  The preparation of the Test Plan will be made on the basis of the requirements' analysis.  Activities such as resource planning, determination of roles and responsibilities, selection of tools (if automation), training requirements, etc., carried out at this stage.

The deliverables of this phase are Test Plan & Effort estimation documents.

Entry Criteria: Requirements Documents
Deliverables: Test Strategy, Test Plan, and Test Effort estimation document.

Test Analysis :-

Test Analysis Is the process of analyzing the test basis (all documents from which the requirements of a component or system can be inferred) and defining test objectives. It covers WHAT is to be tested in the form of test conditions and can start as soon as the basis for testing is established for each test level.

Following Is The Document Which Is Use In Test Analysis:-


  • CRS (Customer Requirement Specification)
  • SRS (Software Requirement Specification)
  • BRS (Business Requirement Specification)
  • Functional Design Documents

Test Case Development :-

This phase that begins after the test planning and analysis phase is completed.  From test analysis we can understand how to test and what is the test condition.  So easily understand and develop the test case.  In This phase evaluator creates the manual / automation test scripts.  The test data is prepared in this phase the data that is used to find the defect.  The Requirement Traceability Matrix (RTM) is also ready, Because the evaluator understands tracking the test case for the particular requirement.
 
Image 1.png 236.89 KB
Activities in the Test Case Development Phase

 
Following are the three activities that are carried out in the Test Case Development phase 

 Test Scenarios Identification

1. Scenarios ease the testing and evaluation of a complex system. The following strategies help in creating good scenarios −
2. Enumerate potential users, their actions, and their goals.  
3. Evaluate Users who have a hacker mindset and listed possible scenarios for abuse of the system.
4.   List System events and how the system handles these requests. 
5.  List Benefits and create comprehensive tasks to verify. 
6.  Read about similar systems and their behavior.  
7. Studying Complaints about competitors' products and their predecessors. 
 
 
 Test Cases Writing

A test case is a document, which includes test data, preconditions, expected results and post conditions, developed for a particular test case in order to verify compliance with a specific requirement. 
 
Test Case serves as a starting point for running the test.  After a set of input values ​​is applied;  the application is final and leaves the system at an end point also known as a post execution condition. 

Test Data Preparation


Test Data is used to run the tests for test ware.  Test Data must be precise and complete in order to detect the shortcomings.  To achieve these three goals, follow a step-by-step approach as given below - 

1. Identify resources or test requirements
2.  Identify conditions / functionality to be tested
3.  Set priority test conditions
4.  Select conditions to test
5.  Determine expected result of test case processing 
6. Create Test cases
7. Document test 
8. conditions Conduct test 
9. Verify and correct test cases based on modifications 

 Activity Block Diagram


The following diagram shows the different activities that form part of Test Case Development.

image 2.png 359.61 KB
 Test Environment Setup :-

A test environment is a software and hardware configuration that allows test teams to run test cases.  In other words, it supports running tests with configured hardware, software, and network.  Test the test bed or environment is configured as needed Application Under Test. On some occasions, the test may be the combination of the test environment and the test data that  it operates.  Setting a good test environment guarantees successful software testing.  Any Loopholes in this process can result in additional costs and time for the customer. 

 Process of Software Test environment setup

Tests are limited to what can be tested and what not should be tested.
 Following people are involved in test environment setup

  •  System Admins,
  • Developers
  • Testers
  • Sometimes users or techies with an affinity for testing.
The test environment requires setting up of various number of distinct areas like,

Setup of Test Server

Test Every may not be performed on a local machine.  It may need to create a test server that can support applications. 
For example, Fedora configuration for PHP, Java-based applications with or without mail server, cron configuration, Java-based applications and so on.

 Network

Network set up as per the test requirement. It includes,

  • Internet setup
  •  LAN Wi-Fi setup
  • Private network setup

It ensures that the congestion that occurs during testing doesn't affect other members. (Developers, designers, content writers, etc.)

Test PC setup

For web testing, you may need to set up different browsers for different testers. For desktop applications, you need various types of OS for different testers PCs.

For example, windows of phone app testing may require.

  • Visual Studio installation
  •  Windows phone emulator
  • Alternatively, assigning a Windows phone to the tester.

Bug Reporting


Bug reporting tools should be provided to testers.

Creating Test Data for the Test Environment

Many companies use a separate test environment to test the software product. The common approach used is to copy production data to test. This helps the tester, to detect the same issues as a live production server, without corrupting the production data.

The approach for copying production data to test data includes,

  •  Set up production jobs to copy the data to a common test environment
  • All PII (Personally Identifiable Information) is modified along with other sensitive data. The PII is replaced with logically correct, but non-personal data.
  • Remove data that is irrelevant to your test.

Testers or developers can copy this to their individual test environment. They can modify it as per their requirement.

Privacy is the main issue in copy production data. To overcome privacy issues you should look into obfuscated and anonymized test data.

For Anonymization of data two approaches can be used,

  •  Blacklist: In this approach, all the data fields are left unchanged. Except those fields specified by the users.
  • Whitelist: By default, this approach, anonymizes all data fields. Except for a list of fields which are allowed to be copied. A whitelisted field implies that it is okay to copy the data as it is and anonymization is not required.

Also, if you are using production data, you need to be smart about how to source data. Querying the database using SQL script is an effective approach.
Every test may not be executed on a local machine. It may need establishing a test server, which can support applications.
For example, Fedora set up for PHP, Java-based applications with or without mail servers, cron set up, Java-based applications, etc.
 
Network


Network set up as per the test requirement. It includes,

  •  Internet setup
  • LAN Wi-Fi setup
  • Private network setup

It ensures that the congestion that occurs during testing doesn't affect other members. (Developers, designers, content writers, etc.)

Test Execution :-

After The test plan, the development of the test case, and the configuration of the test environment are complete, and then the execution phase of the test is executed.

In This manual test / automation script phase is executed.  If any defect is detected during the execution of the test case, it will be reported to the developer through the bug tracking system. 
If any test case result is a failure than this particular test case marked as fail.

If any test case result is matched to the expected result then a particular test case marked as Pass.

If all modules  dependent are tested and any fault is detected, the particular module test case is marked as blocked, first corrects the main module fault, and then runs the associated module test case.  For example, B the module depends on the module A.

If any fault found in the module A, the test case of the module B is not executed.  First correct the fault of the module A then rerun the module A test case, If module A result of the test case is Pass then run the module B execution of the test case.

Blocked Test noticed cases are executed after the fault is corrected by the developer.

Image 3.png 299.79 KB
 Exit Criteria Evaluation And Reporting :-


In this phase if the exit criteria match the test result.  In Termination Criteria There is one condition that is predefined.  At this stage The test summary report is generated.  A Document containing a summary of testing activities and final test results is called Test Summary Report. 
 
Test Closure :-


The final stage where we prepare Test Closure Report, Test Metrics.
The testing team will be called out for a meeting to evaluate cycle completion criteria based on Test coverage, Quality, Time, Cost, Software, Business objectives.

The test team analyses the test artifacts (such as Test cases, defect reports, etc.,) to identify strategies that have to be implemented in the future, which will help to remove process bottlenecks in the upcoming projects.

Test metrics and Test closure report will be prepared based on the above criteria.

Entry Criteria:  Test Case Execution report (make sure there are no high severity defects opened), Defect report
Deliverables:  Test Closure report, Test metrics


August 31, 20208 minutesauthorBhumi Khimani
post

You must be thinking what is a webhook? Where it is used? What is the usage of it? And the most important why it’s used?

Webhooks are automated services, it is a way that the app can send automated messages or information to our system.

When something happens in the system then this service is fire and our system caches those services and can do according to changes in our system.

Let’s take an example of a stripe webhook

We have integrated Stripe payment gateway, we have according to payment fields in our system’s database. When our system user do the payment in stripe at that time payment is done in stripe, but now how will our system get to know about the customer has do payment or not?

When customer complete payment in stripe, it will send service(webhook) to our system which has information about customer payment detail, our system will cache this service, then our system will find that user in our system and if found then we can do payment changes in our customer detail.

August 28, 20201 MinutesauthorMonika Vaghasiya
post

Recently, we were working in a laravel app where we have a status column in multiple models. We have multiple processes going on for which we have different jobs.

Initially job status will be "Pending", then each job will take one record, change the status to "Running" and process that record, and update the status to either "Completed" or "Failed".

We have constants for each status. Something like below,

static $STATUS_PENDING = 0;
static $STATUS_RUNNING = 1;
static $STATUS_COMPLETED = 2;
static $STATUS_FAILED = 3;

And the problem is, we need to go and define the status in every model that we have (around 10+ models).

Then we have functions to update status and check the status in each model like,

public function markRunning($saveRecord = true)
{
    $this->status = static::$STATUS_RUNNING;

    if ($saveRecord) {
        $this->save();
    }
}

public function isRunning()
{
    return $this->status === static::$STATUS_RUNNING;
}

And above functions existed for each 4 status. so what we did is, we created a common StatusTrait which can be used across multiple models.

Here is the code of StatusTrait that you can find for that.

Then in each model, we use this trait. For e.g.,

class SavePdf extends Model
{
    use StatusTrait;

    .....
}

And then can use any method of trait in all the models,

...
$savePdf = new SavePdf();
$savePdf->markRunning();
...

Or we can check if the status of the model is running or not. For e.g.,

...
if ($savePdf->isRunning()) {
    // logic here
}
...

This is how we have saved tons of writing code and optimized the code. Another advantage is, we can just update the value of any status from one single place.

You can also check this kind of pattern and do something like this.

August 26, 20201 minuteauthorMitul Golakiya
post
After doing all the right things to boost productivity and still employees' productivity plunging or not increasing, we need to look at the Employee Morale. employee Morale is a decisive factor in an Organisation whether it is the Service sector or Manufacturing unit. It is one of the cornerstones of the business, only a few organizations pay attention to morale among employees in their organization and this is the major mistake from their side as it affects productivity which ultimately reflects in Organizational Growth & Productivity.

Let’s Discuss:

  • What’s Employee Morale?
  • Characteristics of Employee Morale.
  • Relation between Morale & Productivity.
What is Employee Morale ?

In simple terms employee morale is the standard of behavior of an employee which directly affects the productivity of the organization but it is a complex concept as there are ample factors that affect employee morale.

Definition :

Edwin Flippo : “ Morale is a mental condition or attitude of individual and groups which determines their willingness to cooperate”

Characteristics :

  • Psychological concept
  • Dynamic Nature
  • Group phenomenon
  • Reflect others
Psychological Concept:

Morale is the psychological phenomenon, it is the internal feeling of confidence, attitude, Zest, enthusiasm, satisfaction, etc. Moreover, it is the state of mind and emotions affecting the attitude and willingness to work that affect individual and organizational objectives.

Dynamic Nature:

Morale is Dynamic in nature; we cannot develop it overnight. Management has to make continuous efforts to build and maintain high morale among employees in the organization. It is a long term concept.

Group Phenomenon:

Morale is not an individual phenomenon but it's the sum of the total employee’s attitude, feelings, and sentiments.

Reflect others:

We cannot measure morale directly but it is reflected in productivity, discipline, turnover, etc. To measure morale we need to look at other factors.

Relations between Morale and Productivity:

Davis Designed that there is not always a positive link between Productivity and Employee morale. There can be four combinations of Morale and Productivity

1. High morale-High productivity

This situation is likely to occur when the employees are fully motivated to achieve high performance not only this but satisfied with all financial & nonfinancial rewards & highly satisfied with their job role. Feeling proud to be part of the organization/team.

2. High morale-low productivity

This situation occurs when the employees waste their time in the workplace or use the time to satisfy their personal goals. They don't care about organizational goals. There are many factors responsible for this kind of Employee Attitude in the workplace such as-

  1. lack of proper training,
  2. Lack of support by co-workers or leader,
  3. leaders/Superior behavior with him,
  4. Irresponsible Management (If we talk about It or another small service sector Irresponsible HR )
  5. Ineffective Supervision
  6. Restrictive norms of the informal group
  7. Outdated Technology & Methods
3.Low morale-High productivity

In a short period, it may be possible that with low morale Employee's productivity seems high but it is for a temporary or short span of time. Low Morale can not result in high productivity for a long time. this situation occurs when

  1. fear of losing a job,
  2. less availability of alternatives
  3. Strict Supervision, Rules & Regulations
  4. Punishment
  5. Policies and strategies focus on high productivity only.
4. Low morale-Low productivity

This situation occurs when the organizational & individual both goals are not satisfied & other factors like

  1. Lack of motivation
  2. Unclear Job role
  3. Lack of harmonious Superior-Subordinate relationship
These all factors result in frustration, tension and grievances develop against managers which reflect low productivity To pen down, morale is the paramount factor that gives a direct impact on productivity, Productivity impact on profitability, profitability impact on organizational growth. If the Morale is high then it will be possible to gain more fruits in the future but if it's low than it's Red Signal for any organization even the productivity is high but it will be for a short period of time only

I am not going to end the topic of Morale but will continue in the next blog with -

  1. Factor determining morale
  2. Significance of high morale
  3. Impact of low morale
  4. Measurement of morale
To know about these please read my upcoming blogs of Human Resource…..

August 25, 20203 minutesauthorMariyam Bemat