Setup domain in Apache server on DigitalOcean Cloud

I am trying to set-up a domain in Apache on DigitalOcean and summaries this information after complete the task for my future reference. If this information helps other, it will be my pleasure to know that on a comment. 😉

BTW, You can host as many (multiple) domains as you want by following this steps.

 

#Step 1: go to by

cd /etc/apache2/sites-available

#Step 2: copy default configuration file, in my case I was configuring my site skpaul.me

sudo cp 000-default.conf skpaul.me.conf

#Step 3: Open the file skpaul.me.conf

sudo nano skpaul.me.conf

#Step 4: Update following information in the open file, you you can copy below configuration and update as you needed.

<VirtualHost *:80>

ServerAdmin hello@skpaul.me

DocumentRoot /var/www/html/skpaul
ServerName skpaul.me
ServerAlias http://www.skpaul.me

ErrorLog //var/www/html/skpaul/logs/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/www/html/skpaul/logs/access.log combined

</VirtualHost>

save the file

#Step 5: create a symlink to site-enable folder

sudo a2ensite skpaul.me.conf

#Step 6: restart the server

sudo service apache2 restart

You are done, now check your site from browser.

Advertisements

Send email using Gmail SMTP in Laravel 5.*

Hi there, hope you are not in trouble with your application email sending feature. I am using mailtrap.io for email testing on the development server. It is good, but one problem is all email are going mailtrap’s Demo inbox, not to users individual email. And my client wants to check all email templates and functionality on the development server, with various emails and here I need to look for an alternative solution. By the way, I am using Laravel’s default email function.

So, here is the process that I follow and hope it will help you too. Don’t worry it’s simple.

Step – 1: Update the google account permission for allowing access less secure (third party) apps.

  • Go to your Google account dashboard by clicking on this link https://myaccount.google.com/security#connectedapps  or My Account button on Gmail
  • And take a look at the Sign-in & security -> Connected apps & sites -> Allow less secure apps settings.
  • You must turn the option “Allow less secure apps” ON.

Step – 2: First open .env file and update email setting parameters

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=your-email@gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls

Look at the PORT and ENCRYPTION, I use 587 and tls (Transport Layer Security) respectively. Try to maintain this configuration, otherwise you will get the error. Though both are used as default in configuration (config/mail.php) file.

Step – 3:  If you get any exception error regarding OpenSSL certificate. Then you need to add following code to mail configuration file. Open mail.php file located in config/mail.php and add following code. In my case, I added at the bottom.

// send email locally – only for development server, do not use it on production server

‘stream’ => [
‘ssl’ => [
‘allow_self_signed’ => true,
‘verify_peer’ => false,
‘verify_peer_name’ => false,
],
],

Note: It is suggested, not to use this configuration on your production server, because of security purpose.

 

I am really glad if this information is helping anyone. So, let me know your feedback or any alternative way/solution you know for this issue.

I would glad to help you, please ping me at me[at]skpaul[dot]me if you need any support.

Install Avro (Bangla software) in ubuntu on terminal

I am using Avro since when I know about this awesome software, around 10-12 years. Maybe more than this. When I started Ubuntu, I am looking for avro for linux and here is the download link of official avro, you can download from here and install by following the instruction

OR

You can easily install Avro on Terminal buy follow below few lines of commands.

Step – 1:

Make sure you are in right directory and run these commands on your terminal

wget “https://github.com/maateen/avro/releases/download/v2.0/avro_2.0-1_all.deb&#8221;
sudo dpkg -i avro_2.0-1_all.deb

If you get any dependency error then run the following command

sudo apt-get install -f

Hope your install is done and all is well

Step – 2:
Now go to System Settings > Language Support from Unity Launcher Look at the Keyboard input method system Select IBus and close the window.

 

Now you need to restart IBus to make everything work fine. Try the following command:

ibus restart

After this a “reboot” is required. Now go to System Settings -> Keyboard -> Text Entry. Search and add Avro Phonetic as input source.

That’s all now press Super+Space to toggle the keyboard

Rapid or fast development in Sublime Text 3

We, developers like to write codes, but what if you need to write 1000000000 lines of code?
Let me know your answer on comment 😉

Here comes snippet, What is snippet?
Snippet a small piece or brief extract. it’s a brunch of code that is generate by shortcut key.

Now we know create some snippets for faster our development time. And we need function every where, so we will create a snippet, that we dont need to write same code again and again

Step-1: Open Subline
Step-2:Tools > Developer > New Snippet, Now you will get a file like this

Step-3: Update the codes with below codes

Look at the underline area the function is public and we use ${1} and ${2}. what does it mean?

Continue….

Open/Start Sublime Text in (windows) command line shortcode with a specific project

Open your Sublime Text2/3 by shortcode “subl .” on command prompt with a specific project.

 

We often need to open projects in between another project for some updates/support. As I am using Sublime Text 3 for coding, so I open/drag the folder to the editor project panel. But, It is risky and time consuming to search any file from all open projects. So, I was looking for a quick solution that I can easily open the project on a new window of Sublime Text. And here is the process…

 

Step 1:
Press Menu Key/Windows Logo Key > type “This PC\My Computer”, Write click on it and click on “Properties”
Or: Control Panel > System and Security > System

 

Step 2:
Click on the “Advanced system settings” > click on the “Environment Variables” (at the bottom on the new popup window)

 

Step 3:
Now you will get another window that have 2 sections User Variables and System Variables

> Add user variable by client on the New button
Variable name – SUBLIME_HOME
Variable value – C:\Program Files\Sublime Text 3\ (it depends, when you install Sublime Text. I install in C drive and it was Sublime Text 3)

> Now in system variables list, select “Path” variable and client on edit button. Add
“;%SUBLIMETEXT%” at the end of the path variable value.

Shortcut 😀 : just paste “;C:\Program Files\Sublime Text 3\” (it depends, when you install Sublime Text. I install in C drive and it was Sublime Text 3) at the end of the Path variable value. There may be existing values, so keep in mind to add a “;” before your value as above example.

 

Step 4:
Hope you are in project folder > Press Ctrl+Shift and write client > Client on the “Open command window here” > type “subl .”/”sublime .” (remove qoutes and add a dot with a space) on command prompt > And the project will open in a new window of Sublime Text.

Or you can open command prompt any where and navigate to the specific project folder and run the “subl .”/”sublime .” code, the result will be same.
Or You can just open the command prompt and run the command “subl”/”sublime” to open the Sublime Text

 

**Check your Sublime Text installation folder (mine is C:\Program Files\Sublime Text 3\), check the name of the .exe file. It should be “subl.exe” or “sublime.exe” and use “subl”/”sublime” depends on the exe file name.

 

Check this video for a quick demonstration and let me know your feedback.

External API calling in Laravel by Guzzle Package

Recently I am working on a project that need to access some external API. And it’s a Laravel project, so I am looking for some package that can save my time and meet the deadline too.

 

I am using GuzzleHttp package for accessing external API and its really easy

 

Installation:

composer require guzzlehttp/guzzle:~6.0

Uses:
on your controller file just put before your class ClassName

use GuzzleHttp\Client;

 

Now call this Guzzle Client in your method

//create an instance of Client wiht base url of the API

$client = new Client(['base_uri' => 'http:127.0.0.1/path/to/api/']);

// Send a GET request to http:127.0.0.1/path/to/api/ 
// and method name is apiName 
// with api authentication (username and password)
$response = $client->request('GET', apiName', [
                 'auth' => ['username', 'password']
                 ]);

// check the response by

dd($response);

// Get the response status code

dd($response->getStatusCode());

// Get the response phase
dd($response->getReasonPhrase());

// Get all/full header
dd($response->getHeaders());

// Get specific specific entity of header, 
// here we retrive content-type
dd($response->getHeader('content-type'));

// Get api content. it return the main content the we need

dd($response->getBody()->getContents());

 

this post will continue as i go with this Guzzle package..

 

Repository – https://github.com/guzzle/guzzle

and here is the main document – http://docs.guzzlephp.org/en/latest/

 

Set XSRF(/CSRF) Token Globally or TokenMismatchException in Laravel 5.* (for AJAX)

Very easy (পানির লাহান) 🙂

STEP – 1:

First we have to ad a meta tag (name=”_token”) in header

<meta name=”_token” content=”{{ csrf_token() }}” />

STEP – 2:

Then add below jQuery snippet before the </body> tag. Basically here we setting up the csrf token globally for ajax request. And after this we don’t need to send the csrf token on every ajax call.

$(function () {
// SET UP CSRF TOKEN Globally for Ajax Request
$.ajaxSetup({
headers: {
‘X-XSRF-TOKEN’: $(‘meta[name=”_token”]’).attr(‘content’)
}
});
});

STEP – 3:

And finally we have to add a method on “appHttpMiddlewareVerifyCsrfToken.php” file. So, add the below method on VerifyCsrfToken.php

/**
* Determine if the session and input CSRF tokens match.
*
* @param IlluminateHttpRequest $request
* @return bool
*/
protected function tokensMatch($request)
{
$token = $request->session()->token();

$_token = $request->input(‘_token’);

$header = $request->header(‘X-XSRF-TOKEN’);

return StringUtils::equals($token, $_token) ||
($header && StringUtils::equals($token, $header));
}

Now check and let me know your comments. And I don’t mind, if you want to share this article with your friends/colleagues. Bcoz. Sharing’s Caring.  🙂