InfyOm Blog

latest-post

Generally, we are using a Swagger in Laravel. it will take time if we set up swagger manually. so, In this article, I going to show you very easy steps for setup in Laravel.

You can watch the following video tutorial as well.

Steps 1:

You should download these assets from here. unzip the folder and go to the public directory. you can found the swagger directory in the side public folder. let open the swagger directory and you can see the following files.

  • jquery-2.1.4.min.js
  • style.css
  • swagger-bundle.js
  • swagger.yaml

If are you still confuse then visit this link for files.

now, Copy the swagger directory and put it in your laravel application on the same path.

Steps 2:

We need to load swagger with proper swagger UI. so, let navigate to resources/views on the downloaded source code project.

You can see the swagger directory inside the views directory. copy the swagger directory to your laravel application on the same path. I don't think you need to do anything in this view file. let's go to the next step.

Steps 3:

You need to update this swagger.yaml file. you should update the following details first. and then add APIs documentation in this file. Api document example given here. you can refer it.

info:
  description: LPT APis
  version: 1.0.0
  title: LPT Frontend API's
basePath: /api/

Steps 4:

In this step, you need to create a route for loading swagger docs. so, let's open the web.php file add the following few lines of code.

Route::get('/docs', function () {
    return view('swagger.index');
});

Now, run a command php artisan serve and open http://127.0.0.1:8000/docs or open a virtualHostDomain/docs if you have one.

You should watch this tutorial as well if you using InfyOm Generator

September 22, 20212 minutesuserShailesh Ladumor

Posts

post

Recently, I've started working on one project where we need to set up a virtual host with HTTPS because I need to run that project with expose and Shopify in my local development machine. I've wamp 3.2.3 on my local machine.

I spent a lot of time setting it. so, I thought I should write one article for a step by step guide. So, I will show you in this article how to set up HTTPS for a local machine.

Step 1 - Install Wamp

Install wamp server if not installed in your local machine. you can download the latest version of the wamp server from here. wamp server is available in 32 bit and 64 bit. make sure you select the correct version of the wamp server based on your operating system (window)'s version.

Step 2 - Install OpenSSL

OpenSSL is an open-source command-line tool that is used to generate the SSL certificate and private key. OpenSSL is available in both versions 32 and 64 bit. download the latest version of OpenSSL from here.

2021-01-29-601401f28a12b

I hope you successfully installed OpenSSL on your machine. let's take the next step

Step 3 - Create a Private key

Open your terminal as an Administrator otherwise you will get a permission denied error. Also, you can provide permission to the OpenSSL directory and run the terminal in normal mode.

Now, let go to where we installed OpenSSL

cd C:\Program Files\OpenSSL-Win64\bin

Let's create a private key which is 2048 bits encryption. fire one by one the following two commands to create it.

openssl genrsa -aes256 -out private.key 2048

openssl rsa -in private.key -out private.key

2021-01-29-60140b3530e0b

Your private.key is successfully generated here C:\Program Files\OpenSSL-Win64\bin

Step 4 - Create an SSL Certificate

Let's create a certificate using the following command,

openssl req -new -x509 -nodes -sha1 -key private.key -out certificate.crt -days 36500

You need to enter a detail that looks like

2021-01-29-60140cd318bd9

You can verify here

2021-01-29-60140d37b3a9f

Step 5 - Move both Private Key and a Certificate

Open a directory D:\wamp64\bin\apache\apache2.4.46\conf (Based on where your wamp is installed) and create a key directory.

Now, move both files to the key directory.

Step 6 - Configure Your httpd.conf File

Open your D:\wamp64\bin\apache\apache2.4.46\conf\httpd.conf (the drive should be where your wamp is installed) and un-comment the following 3 lines one by one.

LoadModule ssl_module modules/mod_ssl.so
Include conf/extra/httpd-ssl.conf
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so

Step 7 Configure Your httpd-ssl.conf File

Open your D:\wamp64\bin\apache\apache2.4.46\conf\extra\httpd-ssl.conf (the drive should be where your wamp is installed) and change the following lines.

DocumentRoot "${INSTALL_DIR}/www"
ServerName localhost:443
ServerAdmin admin@example.com
SSLCertificateKeyFile "${SRVROOT}/conf/key/private.key"
SSLCertificateFile "${SRVROOT}/conf/key/certificate.crt"

Make sure, these following all lines are set or not. if not, add it as well.

SSLSessionCache "shmcb:${SRVROOT}/logs/ssl_scache(512000)"
CustomLog "${SRVROOT}/logs/ssl_request.log" \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

Step 8 Configure a Virtual Host

Hope you have created a virtual host. if not, create a virtual host using the virtual host manager which is provided by wamp.

Open an D:\wamp64\bin\apache\apache2.4.46\conf\extra\httpd-vhosts.conf and update your virtual host

Change the port :80 to :443

add the following lines into the VirtualHost.

SSLEngine on
SSLCertificateFile "${SRVROOT}/conf/key/certificate.crt"
SSLCertificateKeyFile "${SRVROOT}/conf/key/private.key"

Now, the code of VirtualHost looks like,

Now, we are done. Let's restart a wamp server.

If you see a green WAMP icon everything should be right. If the icon is orange there is a problem with your syntax somewhere.

Open terminal and go to the D:\wamp64\bin\apache\apache2.4.46\bin and run httpd -t in the command prompt and if there are any syntax errors they will be listed.

if fine then open https://ladumor.test on the browser

January 30, 20213 minutesauthorShailesh Ladumor
post

In our daily life, we are going through lots of packages, and some of us don't know how to build our own package into Laravel.

We are going to perform the core steps to create your own package in laravel. In this tutorial we are going to build a zoom package, so we will perform steps related to it.

Setup Fresh Laravel Repo

Setup fresh laravel repo, and then create directories within it.

for e.g Create infyomlabs/zoom-api directory into the root.

2021-01-23-600c1615b8dc5

Now create src directory into zoom-api

Run Composer init Into src Directory

After hitting composer init it will ask for some information from you, as you can see below image I have entered some of the information. you can just hit enter if you do not want to add other information.

2021-01-23-600c1880b29e5

Add your config file (Optional)

Create a directory config into the src directory and add your config.php file there from where you can manage your env variables.

2021-01-23-600c195f8a4e3

Add Service Provider

Create your service provider from where you can do lots of actions. like you can publish config/routes/ migrations files from there. Here we are publishing the zoom config file.

2021-01-23-600c1aaf5a24d

Add your class (Which contains all functions)

Here we have added a Zoom class which will contain all zoom functions.

2021-01-23-600c1b713c011

Update Composer.json

2021-01-23-600c1cbe97ce6

Finally, Test it in your existing project

Put the following code to your main composer.json (in your project's root). and hit composer update

  "repositories": [
        {
            "type": "path",
            "url": "infyomlabs/zoom-api",
            "options": {
                "symlink": true
            }
        }
    ],
    "license": "MIT",
    "require": {
        "infyomlabs/zoom-api": "dev-develop"
    },
January 27, 20211 minuteauthorVishal Ribdiya
post

Today we are going to see how we can generate a data table with one of the most popular a stisla theme.

We can actually do that in minutes with the package that we Recently developed called stisla-templates .

Our team made a great effort into this package and developed it with a new feature. This template package has Jquery Datatable support. So, anyone can easily generate CRUD(scaffold) with a Data table.

Let's see step by step, how we can do that.

Install Packages

Follow the installation steps given in our official documentation of Laravel InfyOm generator and stisla-templates if not installed.

Now, you have to perform the following steps.

composer require yajra/laravel-datatables-oracle:"~9.0"

This package handles the query and frontend stuff.

Register provider and facade on your config/app.php file.

2021-01-19-600677b04753e

Now clear your cache and regenerate it using the following command,

php artisan config:cache

We are done with installation and configuration.

Use Generate Scaffold with Datatable

Now I am going to add an option jqueryDT, at last, to use JQuery Datatables while generating scaffolds. the command looks like

php artisan infyom:scaffold Post --jqueryDT

Enter all required inputs and generate a scaffold of Post.

All views are created inside the posts directory in the resource. Also, the post.js file is created inside the js directory in assets that are located inside the resource.

Fire the following command for compile and publish the post.js

npm run dev

Now, the datatable is ready for use. you can watch the video tutorial here.

January 24, 20211 minuteauthorShailesh Ladumor
post

While developing complex applications, sometimes we have to validate fields and data in a totally customized way, at that time you can use laravel's custom validations rules functionality.

In this tutorial, we are going to create our own custom validation rule to compare UUID. In our case, I have to check the UUID which is actually a binary string, whether it exists on DB or not.

Laravel doesn't provide any rule to compare that binary UUID string, so we will create our own validation rule.

So let's create our custom validation rule::

Generate Custom Validation Class

So here we have created a new class named UuidExists into App\Rules

namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
use Ramsey\Uuid\Uuid;
class UuidExists implements Rule
{

    protected $table;
    protected $column;

    public function __construct($table, $column)
    {
        $this->table = $table;
        $this->column = $column;
    }
    public function passes($attribute, $value)
    {
        $value = Uuid::fromString(strtolower($value))->getBytes();
        return \DB::table($this->table)->where($this->column, $value)->exists();
    }
    public function message()
    {
        return 'The validation error message.';
    }
}

Add Rule to AppServiceProvider

Add your rule to AppServiceProvider.php into boot() method. here I have to give the name uuid_exists to my custom rule. you can give your own name whatever you want.

\Validator::extend('uuid_exists', function ($attribute, $value, $parameters, $validator) {
    list($table, $column) = $parameters;
    return (new UuidExists($table, $column))->passes($attribute, $value);
});

How to use custom rules?

You can use your custom rule as follows. Here we have using the required and uuid_exists rule, where we are passing attributes and values to our custom rule, which will be used to passes($attribute, $value) function.

'tenant_id' => ['required', 'uuid_exists:tenant_id,uuid']

Keep connected to us for more interesting posts about Laravel.

January 21, 20211 minuteauthorVishal Ribdiya
post

In the last blog we have discussed two perspectives namely Financial Perspective and Internal Process perspective out of four perspectives of BSC. Let's look at the remaining two perspectives.

Customer Perspective

We all know that the 'Customer is the king of the market' and that's why we need to ensure that we have a satisfied customer group in the market.

Each organization serves a specific need in the market and this is done with a target group in mind. There are many points to focus like the Quality, Price, Service, and acceptable Margins on the products and/or services.

The organization always tries to meet customers' expectations in the market and that's why any organization needs to keep its eyes on the market and be ready to adapt to changes quickly.

The existence of alternatives( competitors ) has a huge influence on customers' expectations and we need to focus on overall market trends to build satisfied buyers in the market.

This perspective answer the question: "How attractive should we appear to our customers?"

In short, we need to focus on three points-

  1. Target Group in Market
  2. The expectation of the Customers
  3. Our Competitors

After focusing on these points definitely, we will be able to lure maximum potential customers in the market.

Learning and Growth Perspective

In today's competitive era, if we are not ready/capable of learning something new then it's next to impossible to survive in the market as 'nothing is constant only the change is constant.

Here knowledge is not important but advancing knowledge plays a vital role.

The organization's learning ability and innovation indicate whether an organization is capable of continuous improvement and growth in a dynamic environment or not. The dynamic environment is subject to change on a daily basis due to new laws, economical changes, technological changes, or even increasing competition.

This perspective answer the questions:

"How can we sustain our ability to achieve our chosen strategy ?"

To know more about the BSC please read my upcoming weekly Blog.

January 19, 20213 MinutesauthorMariyam Bemat
post

Here we will learn how to send real-time notifications using Pusher + Laravel.

First of all, you need to create an account in the Pusher and get API keys from there.

Setting up your Laravel application

Now we need to install Pusher SDK, you can install it by the composer using the below command,

composer require pusher/pusher-php-server

After the composer is done, we will need to configure Laravel to use Pusher as its broadcast driver, update the below variables in the .env file,

PUSHER_APP_ID=123456
BROADCAST_DRIVER=pusher

// Get the API Keys from your pusher dashboard

PUSHER_APP_ID=XXXXX
PUSHER_APP_KEY=XXXXXXX
PUSHER_APP_SECRET=XXXXXXX

Open config/app.phpand uncomment the "App\Providers\BroadcastServiceProvider::class".

Now we need an event that will be broadcast to the pusher driver. Let's create a NotificationEvent.

php artisan make:event NotificationEvent

This command will create a below file

namespace App\Events;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class NotificationEvent implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;
    public $username;
    public $message;
    public function __construct($username)
    {
        $this->username = $username;
        $this->message  = "{$username} send you a notification";
    }
    public function broadcastOn()
    {
        //it is a broadcasting channel you need to add this route in channels.php file
        return ['notification-send'];
    }
}

Add broadcasting route in channels.php file

Broadcast::channel('notification-send', function ($user) {
    return true;
}); 

Cache Event at Javascript Side

// Initiate the Pusher JS library

var pusher = new Pusher('YOUR_API_KEY', {
    encrypted: true
});

// Subscribe to the channel we used in our Laravel Event

var channel = pusher.subscribe('notification-send');
channel.bind('App\\Events\\NotificationEvent', function(data) {
    // this is called when the event notification is received...
});

Testing and Setup

Using the below route we can send a notification.

Route::get('test', function () {
    event(new App\Events\NotificationEvent('Monika'));
    return "Event has been sent!";
});
January 16, 20211 minuteauthorMonika Vaghasiya
post

Dear, Friend in this blog we discussion google ad integration. Many companies work in client base & product base. Product based company in very very important ad integration in the app. Multiple types of AD are available like a Facebook ad, start-up ad, google ad, etc. Today we learning google ad integration.

Type of Google AD:

  • Banner AD
  • Interstitial Ad
  • Rewarded Video Ad
  • Native Ad

1.Banner Ad

Banner Ads occupy only a portion of the screen depending on the ad size that is created. It comes in multiple sizes Standard, Medium, Large, Full-Size, Leaderboard, and Smart Banner. Smart banners are very useful when you target multiple device sizes and fit the same ad depending on the screen size.

2.Interstitial Ads

Interstitial ads occupy the full screen of the app. Basically, they will show on a timely basis, between screen transition or when the user is done with a task.

3.Rewarded Video Ad

This ad shows a video-type ad.

4.Native Ad

In this app in full description ad showing.

Create a new project

Create a new project in Android Studio from File ⇒ New Project.

Open build. Gradle and add play services dependency as AdMob requires it.

compile ‘com.google.android.gms:play-services-ads:11.8.0’

build.gradle
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:design:26.1.0'

    compile 'ccom.google.android.gms:play-services-ads:11.8.0'
}

Add the App ID and Ad unit IDs to your strings.xml.

    AdMob
    Interstitial
    Welcome to Admob. Click on the below button to launch the Interstitial ad.
    Show Interstitial Ad
    Show Rewarded Video Ad

    ca-app-pub-XXXXXXXX~XXXXXXXXXXX
    ca-app-pub-XXXXXXXX~XXXXXXXXXXX
    ca-app-pub-XXXXXXXX~XXXXXXXXXXX
    ca-app-pub-XXXXXXXX~XXXXXXXXXXX

Create a class named MyApplication.java and extend the class from Application. In this application class, we have to globally initialize the AdMob App Id. Here we use MobileAds.initialize()

MyApplication.java

public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
         MobileAds.initialize(this, getString(R.string.admob_app_id));
    }
}

Open AndroidManifest.xml and add MyApplication to tag.

<meta-data
    android:name="com.google.android.gms.ads.APPLICATION_ID"
    android:value="ca-app-pub-3940256099942544/6300978111"/>
January 13, 20212 minutesauthorPankaj Valani
post

What is Performance Testing?

Performance testing, which is a non-functional testing method performed to determine system parameters in terms of responsiveness and stability under various workloads. Performance testing measures the quality characteristics of a system, such as a scalability, reliability, and resource use.

Types of Performance Testing

2021-07-01-60dd6e2e103a8

There are mainly six types of performance testing Let's see in detail.

Load Testing

It is the simplest form of testing conducted to understand the behavior of the system under a specific load. The load tests will determine the measurement of important business-critical transactions and will also monitor the load on the database, application server, etc.

Stress Testing

It is performed to find the upper limit capacity of the system and also to determine how the system is operating if the current load greatly exceeds the expected maximum.

Spike Testing

The Spike test is performed by suddenly increasing the number of users by a very large amount and measuring system performance. The main objective is to determine whether the system will be able to carry the workload.

Scalability testing

It Measures performance based on the software's ability to increase or decrease performance measurement attributes. For example, a scalability test could be performed based on the number of user requests.

Volume Testing

Under large test volume no. From. The data is filled in a database and the overall behavior of the program system is monitored. The goal is to check the performance of the software application under different database sizes.

Endurance Testing

It is done to make sure the software can handle the expected load over a long period of time.

We will see full performance testing process points in our next article, to continue...

January 11, 20211 minuteauthorBhumi Khimani