Categories
Laravel

Whats new in Laravel 5.7.15 ?

Laravel 5.7.15 is available with a new Eloquent relationship getters and validation rules

Eloquent relationship getters:

  • BelongsToMany::getParentKeyName
  • BelongsToMany::getRelatedKeyName
  • HasManyThrough::getFirstKeyName
  • HasManyThrough::getForeignKeyName
  • HasManyThrough::getSecondLocalKeyName
  • HasOneOrMany::getLocalKeyName
  • MorphToMany::getInverse

Validation Rules:

  • starts_with – allows you to validate start of input strings

For example:

$request->validate([   

   ‘greeting’ =>’starts_with:hello,hi;

]);

And date_equals validation rule is now translatable

For example:

‘date_equals’ => ‘The :attribute must be a date equal to :date.’,

Categories
Angular AngularJS ES6 General JavaScript TypeScript

CKEditor – Rich Text Editor

CKEditor permits you to directly add the JavaScript based codes within online applications or web pages, it is coming under commercial and open source licenses. If you want to give a more flexible area to user for write any content then CKEditor is better way over adding textarea. In CKEditor three types of preset are given full, minimal and default, these preset are responsible for defining the appearance of your CKEditor. Styles, tags, source etc. are in toolbar to use.

Why CKEditor ?

  • Easy Images : 
  • Insert images which are automatically rescaled, optimized, responsive and delivered through a blazing-fast CDN. All this with virtually zero server setup.
  • CKFinder : Enrich CKEditor with image and file uploads.
  • Spell Checker : Spell checking abilities with additional languages.
  • Full control over content: HTML filtering, view source mode, Long-term support (LTS) until 2023, and many more…

Reference:  https://ckeditor.com

Categories
General Laravel

Deep Diving with Laravel – Queue System

It’s a detail information of Laravel queue system with step by step working,  

Queue System  : – Laravel is shipped with a built-in queue system that helps you run tasks in the background & configure how the system should react in different situation using a very simple API.

Check out the full documentation for more information.

Laravel Queue ,   Queue system 

Monitoring Queue (Laravel Horizon) :-  Laravel Horizon is a queue manager that gives you full control over your queues. It provides means to configure how your jobs are processed, generate analytics, and perform different queue-related tasks from within a nice dashboard

Check out the full documentation for more information.

Laravel Horizon,   The Horizon

Categories
Laravel PHP

Laravel Paytm Integration

Paytm is a very popular Indian payment gateway. Pay money via paytm is very easy. They provides easy way for the shopping and manage your money in your paytm wallet. In this post i will explains you, how to integrate Paytm payment gateway in our Laravel application online using Paytm_Web_Sample_Kit_PHP  example available on github.  

How to install the sample kit on a web server:

  1. First, download Paytm_Web_Sample_Kit_PHP  folder available on github..
  2. Copy PaytmKit folder in document root of your server (like /var/www/html)
  3. Open config_paytm.php file from the PaytmKit/lib folder and update the below constant values
    • PAYTM_MERCHANT_KEY – Provided by Paytm
    • PAYTM_MERCHANT_MID – Provided by Paytm
    • PAYTM_MERCHANT_WEBSITE – Provided by Paytm
  4. PaytmKit folder is having following files:
    • TxnTest.php – Testing transaction through Paytm gateway.
    • pgRedirect.php – This file has the logic of checksum generation and passing all required parameters to Paytm PG.
    • pgResponse.php – This file has the logic for processing PG response after the transaction processing.
    • TxnStatus.php – Testing Status Query API

For Offline(Wallet Api) Checksum Utility below are the methods:

  1. getChecksumFromString : For generating the checksum
  2. verifychecksum_eFromStr : For verifing the checksum

To generate refund checksum in PHP :

  1. Create an array with key value pair of following paytm parameters (MID, ORDERID, TXNTYPE, REFUNDAMOUNT, TXNID, REFID)
  2. To generate checksum, call the following method. This function returns the checksum as a string. getRefundChecksumFromArray($arrayList, $key, $sort=1)

Start Building with Paytm

  1. Create account or login using your existing Paytm account.
  2. Generate your staging account credentials from the dashboard. These are required to explore Paytm integration solutions.
  3. When you are ready to go live, activate your account in the dashboard to get production account credentials

Account credentials are available in your dashboard for both staging and production environment. These credentials consist of –

  1. MID (Merchant ID) – This is a unique identifier provided to every merchant by Paytm. MID is part of your account credentials and is different on staging and production environment. Your staging MID is available here and production MID will be available once your activation is complete.
  2. Merchant Key – This is a unique secret key used for secure encryption of every request. This needs to be kept on server side and should not be shared with anyone.

Note : Paytm Payment Gateway provides a secure, PCI-compliant way to accept Debit/Credit card, Net-Banking, UPI and Paytm wallet payments from your customers.

Categories
Laravel PHP

Razorpay Payment Gateway Integration for Laravel 5+

Currently several payment gateways are available for online payments like Paypal, Stripe, CCAvenue and many more. For Indian market,  Razorpay is best for make online payment due its simplicity.

Follow the given steps for easy Integration,

Create Razorpay Account

To create Razorpay account , click this link Razorpay Account,and get your razor_key and razor_secret from the account.


 Install package : Razorpay

Next, we need to install razorpay/razorpay laravel package in our application by running following command using composer.

composer require razorpay/razorpay:2.*

And visit this link for its usage.

Categories
Angular ES6 TypeScript

NG-ZORRO – UI Library for Angular

Ng-Zorro is a UI library for angular which contains high quality components and demos for building rich and interactive user interfaces. Currently most stable version of ng-zorro is 1.8.0.  It provides good development experience to developers, it contains number of component to use and have a good documentations.

Features :

  • An enterprise-class UI design language for web applications.
  • A set of high-quality Angular components out of the box.
  • Written in TypeScript with complete defined types

Installation :

ng-zorro recommend using @angular/cli to install.

You can also install ng-zorro-antd using npm or yarn.

For more information visit at –

https://ng.ant.design/docs/introduce/en

github : https://github.com/NG-ZORRO/ng-zorro-antd

Categories
Laravel PHP

PHP Library to write XLSX files

Excel is used to store large amount of information in the form of a spreadsheet. Which is easy to manage accounts information and other information. Now a day’s we save large amount of information online in database but some times we need to convert that information into excel spreadsheet and provides to user. In this post i will explains you, how to create excel file online using PHP_XLSXWriter library available on github. You can download this from the link : https://github.com/mk-j/PHP_XLSXWriter

This library is designed to be lightweight, and have minimal memory usage.

It is designed to output an Excel compatible spreadsheet in (Office 2007+) xlsx format, with just basic features supported:

  • Supports PHP 5.2.1+
  • Takes UTF-8 encoded input
  • Multiple worksheets
  • Supports currency/date/numeric cell formatting and simple formulas
  • Supports basic cell styling
  • Supports writing huge 100K+ row spreadsheets

Below are a few test cases, writing large xlsx spreadsheet files with PHPExcel and PHP_XLSXWriter for comparison.

Case

PHP_Excel

PHP_XLSXWriter

10 columns, 10,000 rows in 4 sheets (400,000 cells)

File size : 458MB

Execution time : 101.55s

File size : 11MB

Execution time : 7.56s

10 columns, 10,000 rows in 6 sheets (600,000 cells)

File size : 658MB

Execution time : 202.72s

File size : 15MB

Execution time : 11.31s

10 columns, 20,000 rows in 4 sheets (800,000 cells) File size : 912MB

Execution time : 301.31s

File size : 22MB

Execution time : 14.94s

 

In a few simple tests, PHP_XLSXWriter shows a 98% savings on memory and 95% savings on time when compared to PHP_Excel for writing large files. Though PHP_Excel may have more features, it doesn’t compare with PHP_XLSXWriter when it comes to performance.

Simple PHP CLI example:

$data = array(
    array('year','month','amount'),
    array('2003','1','220'),
    array('2003','2','153.5'),
);

$writer = new XLSXWriter();
$writer->writeSheet($data);
$writer->writeToFile('output.xlsx');

Note : PHP_XLSXWriter is simple to create lightweight excel spreadsheet using PHP library.
Categories
PHP

Whats new in PHP 7.3 ?

The PHP team announced the release of the first PHP 7.3 version RC5 with added following features, syntax updates and deprecations.

Syntax

  • Flexible Heredoc and Nowdoc syntax
  • Allow a Trailing Comma in Function Calls
  • list() reference assignment

New features

  • Option to make json_encode and json_decode throw exceptions on errors
  • Introduced is_countable() function
  • Introduced array_key_first() and array_key_last() functions

Deprecations

  • Deprecated image2wbmp() function
  • Deprecated FILTER_FLAG_SCHEME_REQUIRED and FILTER_FLAG_HOST_REQUIRED flags used with FILTER_VALIDATE_URL
  • Deprecated case-insensitive constants

 

The next release would be RC6, planned for November 22nd 2018.

Categories
Laravel

YesAuthority – Laravel Routes Authorization Library

If you want to add a permission on the basis of Laravel routes then YesAuthority authorization library is very useful to do so. Spatie, Bouncer and other many more libraries are available for Laravel authorization, but these libraries uses Laravel Eloquent models to set up permissions and ability. In YesAuthority you can allow / deny permission from single file, you can statically define your rules in yes-authority.php or you can define your rules in Database for dynamic permissions. You can simply add following syntax to check the route is accessible or not.

Syntax :

canAccess(‘test.route.name’);

// true

 

For more information visit at –

https://livelyworks.github.io/YesAuthority/,

https://github.com/livelyworks/YesAuthority

Categories
General

Hey!! Have you visited ServePHP.com?

 

It’s a service to manage your servers with number of the elegant features, either you can create new server with any server provider as per your choice (Currently providing DigitalOcean) or you can build your custom server using any VPS.

ServePHP is the SaaS application for creating, provisioning and managing simple PHP server and Website/Applications. It helps in performing many important tasks like Attaching Domains, Applications, Cron Jobs, Firewall Rules, Auto Deployments and many more without writing single line in Terminal, these tasks are just a click away using simple interface.

It provides you the seamless integration with LetsEncrypt to install Free SSL Certificates for your applications.

Many Advance features like Auto Deployments using Git Push requests, these deployment can be configured conditionally to avoid unnecessary commands executions.

You can add provide access of your account to your team members

You have choice of different subscription plan Monthly/Yearly as per your needs.

It provides you the 15 days free trial without any credit card information and you can quick sign up via the Google, GitHub, Bitbucket, DigitalOcean, Slack, Gitlab to get hassle free ride to functions & features of site.