Friday, September 27, 2024

Create rest API using Laravel 11

REST APIs (Representational State Transfer Application Programming Interfaces) are a crucial part of modern web applications, allowing different software systems to communicate with each other. In this tutorial, we will explore how to create a REST API using Laravel 11, the latest version of the popular PHP framework known for its elegant syntax and powerful features.

Before diving in, ensure you have the following installed on your system

  • PHP 8.2 or higher
  • Composer
  • MySQL or any other supported database
  • Laravel 11 (we will install this)

Step 1: Setting Up the Laravel Project

First, install a fresh Laravel 11 application using Composer. Run the following command:
composer create-project --prefer-dist laravel/laravel RestApiDemo

Which will install laravel latest in  RestApiDemo directory. Now navigate to the project directory with `cd RestApiDemo`

Step 2: Configuring the Database

Open the .env file in the root of your project and configure your database settings
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=restapidemo
DB_USERNAME=*****
DB_PASSWORD=*****

Now make new tables as 'customers' for save customer data as below.

php artisan make:migration create_customers_table 

Which will create new db migration file `*create_customers_table.php` in `/database/migrations/` directory. open that file and create table schema in up() function as below.

 public function up(): void

{

    Schema::create('customers', function (Blueprint $table) {

        $table->increments('id');

        $table->string('name')->comment('Customer full name');

        $table->string('gender')->length(50)->nullable();

        $table->date('date_of_birth')->nullable();

        $table->string('email')->unique();

        $table->text('notes')->nullable();

        $table->timestamps();

    });

}

Now need create that table in database run db migration as `php artisan migrate` (verify new table customers created in database).

Step 3: Creating the Controller and Model

In laravel need to create controller with resource model use below command.
php artisan make:controller CustomersController --resource --model=Customer

Which will create new `CustomersController.php` in `app/Http/Controllers` directory with basic functions and `Customer.php` model in `app\Models` directory.

Update customer controller functions as below for basic CURD operation.

class CustomersController extends Controller

{

    /**

     * Display a listing of the resource.

     */

    public function index()

    {

        $customers = Customer::latest()->paginate(10);

        return [

            "status" => 1,

            "data" => $customers

        ];

    }


    /**

     * Store a newly created resource in storage.

     */

    public function store(Request $request)

    {

        $request->validate([

            'name' => 'required',

            'email' => 'required|email',

            'date_of_birth' => 'date_format:Y-m-d',

        ]);

        $customer = Customer::create($request->all());

        return [

            "status" => 1,

            "data" => $customer

        ];

    }


    /**

     * Display the specified resource.

     */

    public function show(Customer $customer)

    {

        return [

            "status" => 1,

            "data" =>$customer

        ];

    }


    /**

     * Update the specified resource in storage.

     */

    public function update(Request $request, Customer $customer)

    {

        $request->validate([

            'name' => 'required',

            'email' => 'required|email',

            'date_of_birth' => 'date_format:Y-m-d',

        ]);

        $customer->update($request->all());

        return [

            "status" => 1,

            "data" => $customer,

            "msg" => "Customer updated successfully"

        ];

    }


    /**

     * Remove the specified resource from storage.

     */

    public function destroy(Customer $customer)

    {

        $customer->delete();

        return [

            "status" => 1,

            "data" => $customer,

            "msg" => "Customer deleted successfully"

        ];

    }

}

Update customer model with define database columns which needs to add or update as below.

class Customer extends Model

{

    /**

     * The attributes that are mass assignable.

     */

    protected $fillable = [

        'name',

        'gender',

        'date_of_birth',

        'email',

        'notes'

    ];


    use HasFactory;

Step 4: Creating the API Routes

Laravel 11 need to install the routes/api.php file for defining API routes with below command.
php artisan install:api
Open this file and define the routes for CRUD operations

use Illuminate\Support\Facades\Route;

use App\Http\Controllers\CustomersController;

Route::resource('customers', CustomersController::class);

Step 5: Testing the API 

To test the API, you can use tools like Postman or Insomnia by run `php artisan serve` (can open directly with directory URL). Here are some endpoints to test.

  • GET /api/customers - Fetch all customers.
  • POST /api/customers - Create a new customer.
  • GET /api/customers/{id} - Get a single customer.
  • PUT /api/customers/{id} - Update an existing customer.
  • DELETE /api/customers/{id} - Delete a customer.
  • For create and update customer details use below JSON format send in POST/PUT request.

    {

        "name" : "John Doe",

        "gender": "Male",

        "date_of_birth": "2000-01-01",

        "email": "john@deo.com",

        "notes": "Test comment"

    }

    Creating a REST API in Laravel 11 is straightforward, thanks to its powerful built-in features. This guide covered the basics of setting up a Laravel project, configuring the database, creating models, controllers, and defining API routes. With this foundation, you can extend your API by adding more features like authentication, validation, and error handling.

    For the complete source code of this project, you can visit the GitHub repository: Laravel API CRUD.

    Tuesday, December 31, 2019

    Top 10 Bollywood Item Songs 2019

    Bollywood films must contain song every time and the star cast of the film performs in these numbers. However, one more category of songs is item songs. It has been a trend in Bollywood since its inception that most of the films contain item song for change mood of audiance and push film ahed.
    Here below listed top 10 item songs of bollywood movies which release on currunt year.

    CHAMMA CHAMMA - FRAUD SAIYAAN

    ITEM GIRL Elli Avram
    MOVIE FRAUD SAIYAAN
    DIRECTOR Sourabh Shrivastava
    RELEASE DATE 18th January
    CAST Arshad Warsi, Sara Loren, Saurabh Shukla, Nivedita Tiwari
    SINGER Neha Kakkar, Romi, Arun, Ikka
    MUSIC Tanishk Bagchi
    MUSIC PUBLISHER Tips Official
    LYRICS Shabbir Ahmed


    COCA COLA TU - LUKA CHUPPI

    ITEM GIRL Kriti Sanon
    MOVIE LUKA CHUPPI
    DIRECTOR Laxman Utekar
    RELEASE DATE 1st March
    CAST Kartik Aaryan, Kriti Sanon
    SINGER Tony Kakkar, Neha Kakkar, Young Desi
    MUSIC Tanishk Bagchi
    MUSIC PUBLISHER T-Series
    LYRICS Tony Kakkar, Mellow D


    MUNGDA - TOTAL DHAMAAL

    ITEM GIRL Sonakshi Sinha
    MOVIE TOTAL DHAMAAL
    DIRECTOR Indra Kumar
    RELEASE DATE 22nd February
    CAST Ajay Devgn, Madhuri Dixit, Anil Kapoor, Arshad Warsi, Javed Jaffrey, Riteish Deshmukh
    SINGER Jyotica Tangri, Shaan, Subhro J Ganguly
    MUSIC Gourov Roshin
    MUSIC PUBLISHER Saregama Music
    LYRICS Kunwar Juneja


    AIRA GAIRA - KALANK

    ITEM GIRL Kriti Sanon
    MOVIE KALANK
    DIRECTOR Abhishek Varman
    RELEASE DATE 17th April
    CAST Madhuri Dixit, Sonakshi Sinha, Alia Bhatt, Varun Dhawan, Sanjay Dutt
    SINGER Antara Mitra, Javed Ali, Tushar Joshi
    MUSIC Pritam
    MUSIC PUBLISHER Zee Music Company
    LYRICS Amitabh Bhattacharya


    SLOW MOTION - BHARAT

    ITEM GIRL Disha Patani
    MOVIE BHARAT
    DIRECTOR Ali Abbas Zafar
    RELEASE DATE 5th June
    CAST Salman Khan, Katrina Kaif, Tabu
    SINGER Nakash Aziz, Shreya Ghoshal
    MUSIC Shekhar Ravjiani, Vishal Dadlani
    MUSIC PUBLISHER T-Series
    LYRICS Irshad Kamil


    O SAKI SAKI - BATLA HOUSE

    ITEM GIRL Nora Fatehi
    MOVIE BATLA HOUSE
    DIRECTOR Nikhil Advani
    RELEASE DATE 15th August
    CAST John Abraham, Mrunal Thakur
    SINGER Neha Kakkar, Tulsi Kumar, B Praak
    MUSIC Tanishk Bagchi, Vishal-Shekhar
    MUSIC PUBLISHER T-Series
    LYRICS Tanishk Bagchi, Dev Kohli


    ODHANI – MADE IN CHINA

    ITEM GIRL Mouni Roy
    MOVIE MADE IN CHINA
    DIRECTOR Mikhil Musale
    RELEASE DATE 25th October
    CAST Rajkummar Rao, Mouni Roy, Boman Irani
    SINGER Neha Kakkar, Darshan Raval
    MUSIC Sachin-Jigar, Mahesh-Naresh
    MUSIC PUBLISHER Sony Music India
    LYRICS Niren Bhatt, Jigar Saraiya, Kanti Ashok


    EK TOH KUM ZINDAGANI - MARJAAVAAN

    ITEM GIRL Nora Fatehi
    MOVIE MARJAAVAAN
    DIRECTOR Milap Zaveri
    RELEASE DATE 15th November
    CAST Riteish Deshmukh, Sidharth Malhotra, Tara Sutaria, Rakul Preet Singh
    SINGER Neha Kakkar, Yash Narvekar
    MUSIC Tanishk Bagchi, Kalyanji-Anandji
    MUSIC PUBLISHER T-Series
    LYRICS Indeevar, Tanishk Bagchi, AM Turaz


    BATTIYAN BUJHAADO - MOTICHOOR CHAKNACHOOR

    ITEM GIRL Sunny Leone
    MOVIE MOTICHOOR CHAKNACHOOR
    DIRECTOR Debamitra Biswal
    RELEASE DATE 15th November
    CAST Nawazuddin Siddiqui, Athiya Shetty, Vibha Chibber, Navni Parihar
    SINGER Jyotica Tangri, Ramji Gulati
    MUSIC Ramji Gulati, Aditya Dev
    MUSIC PUBLISHER Zee Music Company
    LYRICS Kumaar


    MUNNA BADNAAM HUA - DABANGG 3

    ITEM GIRL Warina Hussain
    MOVIE DABANGG 3
    DIRECTOR Prabhu Deva
    RELEASE DATE 20th December
    CAST Salman Khan, Sonakshi Sinha
    SINGER Badshah, Kamaal Khan, Mamta Sharma
    MUSIC Sajid-Wajid
    MUSIC PUBLISHER T-Series
    LYRICS Danish Sabri

    Top 10 Bollywood Songs 2019

    Song is simple sets of words that manage according to lines with music and lyrics.In Indian movie song are most important and heart touching to peoples.Some songs are create for any special event or moment represent.
    In Bollywood there are lots of songs.Each movie has minimum one songs or music for make more entertainment.Some movies also famous for it's songs.Songs comes in public before release of that movie.for each movie event first release it's music album.Movie and it's story in peoples mind in some times or some moments but it's songs always remember.
    Here list of top 10 songs of 2019 according to movie release date.

    Apna Time Aayega - Gully Boy

    MOVIE Gully Boy
    DIRECTOR Zoya Akhtar
    RELEASE DATE 14th February
    CAST Ranveer Singh, Alia Bhatt, Siddhant Chaturvedi
    SINGER Ranveer Singh
    MUSIC Dub Sharma
    MUSIC PUBLISHER Zee Music Company
    LYRICS DIVINE, Ankur Tewari



    Teri Mitti - Kesari

    MOVIE Kesari
    DIRECTOR Anurag Singh
    RELEASE DATE 21st March
    CAST Akshay Kumar, Parineeti Chopra
    SINGER B Praak
    MUSIC Arko
    MUSIC PUBLISHER Zee Music Company
    LYRICS Manoj Muntashir



    Hook Up Song - Student Of The Year 2

    MOVIE Student Of The Year 2
    DIRECTOR Punit Malhotra
    RELEASE DATE 10th May
    CAST Tiger Shroff, Tara Sutaria, Ananya Panday
    SINGER Neha Kakkar, Shekhar Ravjiani
    MUSIC Vishal-Shekhar
    MUSIC PUBLISHER Zee Music Company
    LYRICS Kumaar



    Hauli Hauli - De De Pyaar De

    MOVIE De De Pyaar De
    DIRECTOR Akiv Ali
    RELEASE DATE 17th May
    CAST Ajay Devgn, Tabu, Rakul Preet Singh
    SINGER Garry Sandhu, Neha Kakkar, Mellow D
    MUSIC Tanishk Bagchi
    MUSIC PUBLISHER T-Series
    LYRICS Tanishk Bagchi, Garry Sandhu, Mellow D



    Bekhayali - Kabir Singh

    MOVIE Kabir Singh
    DIRECTOR Sandeep Vanga
    RELEASE DATE 21th June
    CAST Shahid Kapoor, Kiara Advani
    SINGER Sachet Tandon
    MUSIC Sachet-Parampara
    MUSIC PUBLISHER T-Series
    LYRICS Irshad Kamil



    Sheher Ki Ladki | Khandaani Shafakhana

    MOVIE Khandaani Shafakhana
    DIRECTOR Arvindr Khaira
    RELEASE DATE 2nd August
    CAST Sonakshi Sinha, Varun Sharma, Annu Kapoor, Badshah
    SINGER Badshah, Tulsi Kumar, Abhijeet, Chandra Dixit
    MUSIC Tanishk Bagchi, Anand-Milind
    MUSIC PUBLISHER T-Series
    LYRICS Tanishk Bagchi, Deepak Chaudhary



    Psycho Saiyaan - Saaho

    MOVIE Saaho
    DIRECTOR Sujeeth
    RELEASE DATE 30th August
    CAST Prabhas, Shraddha Kapoor
    SINGER Sachet Tandon, Dhvani Bhanushali
    MUSIC Tanishk Bagchi
    MUSIC PUBLISHER T-Series
    LYRICS Tanishk Bagchi



    Ik Mulaqaat - Dream Girl

    MOVIE Dream Girl
    DIRECTOR Raaj Shaandilyaa
    RELEASE DATE 13th September
    CAST Ayushmann Khurrana, Nushrat Bharucha, Annu Kapoor
    SINGER Altamash Faridi, Palak Muchhal
    MUSIC Meet Bros
    MUSIC PUBLISHER Zee Music Company
    LYRICS Shabbir Ahmed



    Jai Jai Shiv Shankar - War

    MOVIE War
    DIRECTOR Siddharth Anand
    RELEASE DATE 2nd October
    CAST Hrithik Roshan, Tiger Shroff, Vaani Kapoor
    SINGER Vishal Dadlani, Benny Dayal
    MUSIC Vishal-Shekhar
    MUSIC PUBLISHER T-Series
    LYRICS Kumaar



    Tum Hi Aana - Marjaavaan

    MOVIE Marjaavaan
    DIRECTOR Milap Zaveri
    RELEASE DATE 15t November
    CAST Riteish Deshmukh, Sidharth Malhotra, Tara Sutaria
    SINGER Jubin Nautiyal
    MUSIC Payal Dev
    MUSIC PUBLISHER T-Series
    LYRICS Kunaal Vermaa



    Top 10 Most Viewed Bollywood Movie Trailers of 2019

    In Bollywood now many peoples are waiting for movie Trailer same as movie on screen so according to movie trailer public guess move stories,cast and type. Here listed of top top Bollywood movie trailer in 2019 year so if not seen than must see.

    10. Student Of The Year 2

     
    TRAILER RELEASE 11th April (Dharma Productions)
    VIEWS 68,127,345
    LIKES 938,314
    DISLIKES 230,557
    MOVIE RELEASE DATE 10th May
    CAST Tiger Shroff, Tara Sutaria, Ananya Panday


    9. Bharat

     
    TRAILER RELEASE 22nd April (T-Series)
    VIEWS 72,623,972
    LIKES 1,282,770
    DISLIKES 152,946
    MOVIE RELEASE DATE 5th June
    CAST Salman Khan, Katrina Kaif


    8. De De Pyaar De

     
    TRAILER RELEASE 1st April (T-Series)
    VIEWS 71,029,010
    LIKES 695,178
    DISLIKES 65,467
    MOVIE RELEASE DATE 17nd May
    CAST Ajay Devgn, Tabu, Rakul Preet Singh


    7. Good Newwz

     
    TRAILER RELEASE 17th November (Dharma Productions)
    VIEWS 75,331,114
    LIKES 1,408,248
    DISLIKES 90,234
    MOVIE RELEASE DATE 27th December
    CAST Akshay Kumar, Kareena Kapoor Khan, Diljit Dosanjh, Kiara Advani


    6. The Accidental Prime Minister

     
    TRAILER RELEASE 27th December (Pen Movies)
    VIEWS 77,938,991
    LIKES 756,594
    DISLIKES 78,099
    MOVIE RELEASE DATE 11th January
    CAST Anupam Kher, Akshaye Khanna


    5. Total Dhamaal

     
    TRAILER RELEASE 21st January (FoxStarHindi)
    VIEWS 82,867,943
    LIKES 1,087,128
    DISLIKES 94,590
    MOVIE RELEASE DATE 22nd February
    CAST Ajay Devgn, Madhuri Dixit, Anil Kapoor, Arshad Warsi, Javed Jaffrey, Riteish Deshmukh


    4. Saaho

     
    TRAILER RELEASE 10th August (T-Series)
    VIEWS 90,672,173
    LIKES 1,116,935
    DISLIKES 65,749
    MOVIE RELEASE DATE 30th August
    CAST Prabhas, Shraddha Kapoor, Jackie Shroff, Vennela Kishore


    3. Kabir Singh

     
    TRAILER RELEASE 13th May(T-Series)
    VIEWS 95,669,702
    LIKES 1,397,810
    DISLIKES 71,922
    MOVIE RELEASE DATE 21st June
    CAST Shahid Kapoor, Kiara Advani


    2. Housefull 4

     
    TRAILER RELEASE 27th September (FoxStarHindi)
    VIEWS 97,699,982
    LIKES 1,786,669
    DISLIKES 128,964
    MOVIE RELEASE DATE 25th October
    CAST Akshay Kumar, Riteish Deshmukh, Bobby Deol, Kriti Sanon, Pooja Hegde, Kriti Kharbanda


    1. War

     
    TRAILER RELEASE 26th August (YRF)
    VIEWS 110,387,233
    LIKES 1,707,521
    DISLIKES 70,308
    MOVIE RELEASE DATE 2nd October
    CAST Hrithik Roshan, Tiger Shroff, Vaani Kapoor

    Sunday, August 18, 2019

    Stop all updates in Windows 10


    When you are working with any windows operating system, then you must fetch with window update features in their update some window system programmer & improve security & performance. For windows update, you must restart your PC & sometime it's failed to install all things so need to rollback.
    So if you want to stop that update (If you haven't any problem with existing operating system features) than here describe some methods for that which is easy to set.

    Disable automatic updates using 'Group Policy'

    1. Navigate to desktop then press the Windows logo key + R at the same time to invoke the Run box & type `gpedit.msc` and press Enter.
    2. Navigate to the following path: `Computer Configuration\Administrative Templates\Windows Components\Windows Update`
    3. Double-click the Configure Automatic Updates policy on the right side.
    4. Check the Disabled option to turn off the policy.
    5. Then click "Apply" and "OK" to save the settings.

    Disable automatic updates using 'Registry'

    1. Navigate to desktop then press the Windows logo key + R at the same time to invoke the Run box & type `regedit` and press Enter.
    2. Navigate to the following path: `HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows`
    3. Right-click the Windows (folder) key, select New, and then click on Key.
    4. Name the new key WindowsUpdate and press Enter.
    5. Right-click the newly created key, select New, and click on Key.
    6. Name the new key AU and press Enter.
    7. Right-click on the right side, select New, and click on DWORD (32-bit) Value.
    8. Name the new key NoAutoUpdate and press Enter.
    9. Double-click the newly created key and change its value from 0 to 1.
    10. Click on "OK" for save & Restart.

    Disable Windows Update Service

    1. Navigate to desktop then press the Windows logo key + R at the same time to invoke the Run box & type `services.msc` and press Enter.
    2. Scroll down to Windows Update, and double-click it.
    3. In Startup type, select "Disabled". Then click "Apply" and "OK" to save the settings.

    Wednesday, January 2, 2019

    Top 10 Most Viewed Bollywood Movie Trailers of 2018

    Current year 2018 is a good year in the Bollywood industry and gives many movies with action, thriller, drama, biopic and romance. Some of them are most viewed and some movie famous for its casts, music, adventure or any other reason.
    For any movie trailer is a new trend in Bollywood and so every producer or director, release movie trailer before launch movie to attract people and will come them to the box office and make a new record of box office collection.
    Here below list of top 10 movie trailer, which are most viewed and liked on YouTube. Have you missed seeing it then must watch here.

    10. Stree

     
    TRAILER RELEASE 26th July 2018(Maddock Films)
    VIEWS 47,748,929
    LIKES 374,370
    DISLIKES 9,643
    MOVIE RELEASE DATE 31st August 2018
    CAST Rajkummar Rao, Shraddha Kapoor, Aparshakti Khurana, Pankaj Tripathi


    9. Satyameva Jayate

     
    TRAILER RELEASE 8th June 2018(T-Series)
    VIEWS 48,757,399
    LIKES 552,046
    DISLIKES 36,636
    MOVIE RELEASE DATE 15th August 2018
    CAST John Abraham, Manoj Bajpayee, Aisha Sharma, Amruta Khanvilkar


    8. Race 3

     
    TRAILER RELEASE 15th May 2018(Salman Khan Films)
    VIEWS 58,191,672
    LIKES 656,845
    DISLIKES 226,277
    MOVIE RELEASE DATE 15th June 2018
    CAST Anil Kapoor, Salman Khan, Jacqueline Fernandez, Bobby Deol, Daisy Shah


    7. Padmaavat

     
    TRAILER RELEASE 9th October 2017(Viacom18 Motion Pictures)
    VIEWS 58,217,370
    LIKES 568,440
    DISLIKES 67,327
    MOVIE RELEASE DATE 25th January 2018
    CAST Deepika Padukone, Shahid Kapoor, Ranveer Singh


    6. Simmba

     
    TRAILER RELEASE 2th December 2018(Reliance Entertainment)
    VIEWS 59,239,131
    LIKES 568,394
    DISLIKES 66,450
    MOVIE RELEASE DATE 28th December 2018
    CAST Ranveer Singh, Sara Ali Khan, Sonu Sood


    5. Dhadak

     
    TRAILER RELEASE 10th January 2018(Dharma Productions)
    VIEWS 60,173,561
    LIKES 654,167
    DISLIKES 81,329
    MOVIE RELEASE DATE 20th July 2018
    CAST Ishaan Khatter, Jhanvi Kapoor


    4. Sanju

     
    TRAILER RELEASE 24th April 2018(FoxStarHindi)
    VIEWS 62,285,491
    LIKES 865,707
    DISLIKES 39,338
    MOVIE RELEASE DATE 29th June 2018
    CAST Ranbir Kapoor, Sonam Kapoor, Dia Mirza


    3. Baaghi 2

     
    TRAILER RELEASE 21st February 2018(FoxStarHindi)
    VIEWS 84,207,397
    LIKES 677,772
    DISLIKES 45,971
    MOVIE RELEASE DATE 30th March 2018
    CAST Tiger Shroff, Disha Patani


    2. Thugs Of Hindostan

     
    TRAILER RELEASE 26th September 2018(YRF)
    VIEWS 104,489,462
    LIKES 1,428,624
    DISLIKES 141,884
    MOVIE RELEASE DATE 8th November 2018
    CAST Amitabh Bachchan, Aamir Khan, Fatima Sana Shaikh, Katrina Kaif


    1. Zero

     
    TRAILER RELEASE 2nd November 2018(Red Chillies Entertainment)
    VIEWS 116,242,827
    LIKES 2,027,556
    DISLIKES 161,061
    MOVIE RELEASE DATE 21st December 2018
    CAST Shah Rukh Khan, Katrina Kaif, Anushka Sharma, Tigmanshu Dhulia

    Tuesday, January 1, 2019

    Create zebra language code in php

    Zebra Programming Language (ZPL) is a page description language from Zebra Technologies, which is used for label printing. It is a command based language used by the printer as instructions for creating the images printed on the labels. Zebra language commands always start with a caret sign (^) Currently, many command exits for new version of ZPL II. In this language each format has to start with the command `^XA` and end with `^XZ` which is ANSI BASIC oriented.
    So when you are working with printing application in PHP or some label printing than must use ZPL code to send to zebra printer. For FedEx, USPS, DHL and other other courier services use ZPL language for own label printing software. So when you want to work with label printing for eCommerce use than must need ZPL code for the printer.
    Here you can write direct text to ZPL using start with `^XA` & end with `^XZ`. Here below example to create ZPL language from image.
    For that create `Image.php` file as below
    
    class Image
    {
        protected $width;
        protected $height;
        public function __construct($image)
        {
            if (!$this->isGdResource($image)) {
                throw new InvalidArgumentException('Invalid resource');
            }
            if (!imageistruecolor($image)) {
                imagepalettetotruecolor($image);
            }
            imagefilter($image, IMG_FILTER_GRAYSCALE);
            $this->image = $image;
            $this->width = imagesx($this->image);
            $this->height = imagesy($this->image);
        }
        public function __destruct()
        {
            imagedestroy($this->image);
        }
        public function isGdResource($image)
        {
            if (is_resource($image)) {
                return get_resource_type($image) === 'gd';
            }
            return false;
        }
        public function width()
        {
            return (int)ceil($this->width / 8);
        }
        public function height()
        {
            return $this->height;
        }
        public function toAscii()
        {
            return $this->encoded ?: $this->encoded = $this->encode();
        }
        protected function encode()
        {
            $bitmap = null;
            $lastRow = null;
            for ($y = 0; $y < $this->height; $y++) {
                $bits = null;
                for ($x = 0; $x < $this->width; $x++) {
                    $bits .= (imagecolorat($this->image, $x, $y) & 0xFF) < 127 ? 1 : 0;
                }
                $bytes = str_split($bits, 8);
                $bytes[] = str_pad(array_pop($bytes), 8, '0');
                $row = null;
                foreach ($bytes as $byte) {
                    $row .= sprintf('%02X', bindec($byte));
                }
                $bitmap .= $this->compress($row, $lastRow);
                $lastRow = $row;
            }
            return $bitmap;
        }
        protected function compress(string $row, ?string $lastRow): string
        {
            if ($row === $lastRow) {
                return ':';
            }
            $row = $this->compressTrailingZerosOrOnes($row);
            $row = $this->compressRepeatingCharacters($row);
            return $row;
        }
        protected function compressTrailingZerosOrOnes(string $row): string
        {
            return preg_replace(['/0+$/', '/F+$/'], [',', '!'], $row);
        }
        protected function compressRepeatingCharacters(string $row): string
        {
            $callback = function ($matches) {
                $original = $matches[0];
                $repeat = strlen($original);
                $count = null;
                if ($repeat > 400) {
                    $count .= str_repeat('z', floor($repeat / 400));
                    $repeat %= 400;
                }
                if ($repeat > 19) {
                    $count .= chr(ord('f') + floor($repeat / 20));
                    $repeat %= 20;
                }
                if ($repeat > 0) {
                    $count .= chr(ord('F') + $repeat);
                }
                return $count . substr($original, 1, 1);
            };
            return preg_replace_callback('/(.)(\1{2,})/', $callback, $row);
        }
    }
    

    Now create `Builder.php` file from convert image to zpl as below
    
    class Builder
    {
        protected $zpl = [];
        public function command()
        {
            $parameters = func_get_args();
            $command = strtoupper(array_shift($parameters));
            $parameters = array_map([$this, 'parameter'], $parameters);
            $this->zpl[] = '^' . $command . implode(',', $parameters);
            return $this;
        }
        protected function parameter($parameter)
        {
            if (is_bool($parameter)) {
                return $parameter ? 'Y' : 'N';
            }
            return $parameter;
        }
        public function __call($method, $arguments)
        {
            array_unshift($arguments, $method);
            return call_user_func_array([$this, 'command'], $arguments);
        }
        public function gf()
        {
            $arguments = func_get_args();
            if (func_num_args() === 1 && ($image = $arguments[0])) {
                $bytesPerRow = $image->width();
                $byteCount = $fieldCount = $bytesPerRow * $image->height();
                return $this->command('GF', 'A', $byteCount, $fieldCount, $bytesPerRow, $image->toAscii());
            }
            array_unshift($arguments, 'GF');
            return call_user_func_array([$this, 'command'], $arguments);
        }
        public function toZpl($newlines = false, $top = null, $shift = null)
        {
            $start = '^XA';
            if($top) {
                $start .= '^LT'.$top;
            }
            if($shift) {
                $start .= '^LS'.$shift;
            }
            return implode($newlines ? "\n" : '', array_merge([$start], $this->zpl, ['^XZ']));
        }
        public function __toString()
        {
            return $this->toZpl();
        }
    }
    

    After create below files convert your image file to zpl code by including both files as below.
    
    include 'Image.php';
    include 'Builder.php';
    $image = new Image(imagecreatefrompng('test.png')); //You can also use imagecreatefromjpeg for jpg image
    $zpl = new Builder();
    echo $zpl->gf($image)->toZpl(false, 10, -10); // toZpl(Newline, Top Margin, Left Shift)
    

    Install Radis Server on Windows (WAMP Server)


    Radius (Remote Dictionary Server) is an open-source advanced key-value database storage system like NoSQL. Redis supports different kinds of abstract data structures, such as strings, lists, maps, sets, sorted sets, bitmaps and spatial indexes. radius is used for caching to speed up a web application.
    If you want to install radios on Linux system than it's easy to install using command line and configure auto in any programming language. when you want to install in window server than manually make some changes for works perfectly.
    Process below steps for installing & work redis on a window server.
    • Download redis setup file for window (32bit & 64bit) here. (You can also download files from here)
    • Install/Put redis in any location you want.
    • Run `redis-server.exe` file from instillation files for start radis server.
    • Now check your php version by running phpinfo(); command in any file.
    • Find redis version match your PHP version from PECL package here.
    • Download radis as php extension according to radis version from https://pecl.php.net/package/redis/RADISVERSION(from below point)/windows. (Ex. https://pecl.php.net/package/redis/4.1.1/windows)
    • Here download DLL files list accoring to your PHP version and Thread Safe / Non Thread Safe.
    • Copy the `php_redis.dll` and paste to following folder in Wamp Server `wamp\bin\php\phpVERSION\ext\`.
    • Open php.ini file add redis extension to extensions list as below `extension=php_redis.dll`
    • Restart wamp server & check phpinfo() which shows redis to confirm radis install successfully.
    • Here you can check radis using php code as below.
      
      try {
          $redis = new Redis();
          $redis->connect('localhost', 6379); //connect redis server
          $redis->set('variable', 'Redis Test'); //save data in server
          $redis->get('variable');  //get data from server
      } catch (Exception $e) {
          echo $e->getMessage();
      }
      
      
    • Here for radis connection you must open redis-server.exe file which installed first(don't close radis server window).

    Top 10 Bollywood Item Songs 2018

    Item song is one type of dance with music as musical performance. now these days, many movies known for it's item songs and it's conman in a Bollywood movie. Currently, all top actress plays the role as item girl instead of the main role in the movie and become that song hits with her best performance. The concept of item song is old in Bollywood industry. This year 2018 Bollywood gives many item songs with any item girls in many movies here list of top 10 item songs of 2018.

    HAT JA TAU - VEEREY KI WEDDING

    ITEM GIRL Sapna Chaudhary
    MOVIE VEEREY KI WEDDING
    DIRECTOR Ashu Trikha
    RELEASE DATE 2nd March
    CAST Pulkit Samrat, Kriti Kharbanda, Jimmy Sheirgill
    SINGER Sunidhi Chauhan
    MUSIC Jaidev Kumar
    MUSIC PUBLISHER T-Series
    LYRICS Dr. Devendra Kafir



    AASHIQ BANAYA AAPNE - HATE STORY 4

    ITEM GIRL Urvashi Rautela
    MOVIE HATE STORY 4
    DIRECTOR Vishal Pandya
    RELEASE DATE 9th March
    CAST Urvashi Rautela, Vivan Bhatena, Karan Wahi, Gulshan Grover
    SINGER Himesh Reshammiya, Neha Kakkar
    MUSIC Himesh Reshammiya
    MUSIC PUBLISHER T-Series
    LYRICS Sameer



    EK DO TEEN - BAAGHI 2

    ITEM GIRL Jacqueline Fernandez
    MOVIE BAAGHI 2
    DIRECTOR Ahmed Khan
    RELEASE DATE 30th March
    CAST Tiger Shroff, Disha Patani
    SINGER Shreya Ghoshal
    MUSIC Laxmikant, Pyarelal
    MUSIC PUBLISHER T-Series
    LYRICS Javed Akhtar



    BEWAFA BEAUTY - BLACKMAIL

    ITEM GIRL Urmila Matondkar
    MOVIE BLACKMAIL
    DIRECTOR Abhinay Deo
    RELEASE DATE 6th April
    CAST Irrfan Khan, Kirti Kulhari, Divya Dutta
    SINGER Pawni Pandey
    MUSIC Amit Trivedi
    MUSIC PUBLISHER T-Series
    LYRICS Amitabh Bhattacharya



    DILBAR - SATYAMEVA JAYATE

    ITEM GIRL Nora Fatehi
    MOVIE SATYAMEVA JAYATE
    DIRECTOR Milap Milan Zaveri
    RELEASE DATE 15th August
    CAST John Abraham, Manoj Bajpayee, Aisha Sharma, Amruta Khanvilkar
    SINGER Dhvani Bhanushali, Ikka Singh, Neha Kakkar
    MUSIC Tanishk Bagchi
    MUSIC PUBLISHER T-Series
    LYRICS Ikka, Shabbir Ahmed





    KAMARIYA - STREE

    ITEM GIRL Nora Fatehi
    MOVIE STREE
    DIRECTOR Amar Kaushik
    RELEASE DATE 31st August
    CAST Raj Kumar Rao, Shraddha Kapoor
    SINGER Aastha Gill, Sachin Sanghvi, Jigar Saraiya, Divya Kumar
    MUSIC Sachin-Jigar
    MUSIC PUBLISHER T-Series
    LYRICS Vayu

    HELLO HELLO - PATAAKHA

    ITEM GIRL Malaika Arora
    MOVIE PATAAKHA
    DIRECTOR Vishal Bhardwaj
    RELEASE DATE 28th September
    CAST Radhika Madan, Sanya Malhotra, Sunil Grover, Vijay Raaz
    SINGER Rekha Bhardwaj
    MUSIC Vishal Bhardwaj
    MUSIC PUBLISHER Zee Music Company
    LYRICS Gulzar



    SURAIYYA - THUGS OF HINDOSTAN

    ITEM GIRL Katrina Kaif
    MOVIE THUGS OF HINDOSTAN
    DIRECTOR Vijay Krishna Acharya
    RELEASE DATE 8th November
    CAST Amitabh Bachchan, Aamir Khan, Fatima Sana Shaikh, Katrina Kaif
    SINGER Vishal Dadlani, Shreya Ghoshal
    MUSIC Ajay – Atul
    MUSIC PUBLISHER YRF
    LYRICS Amitabh Bhattacharya



    GALI GALI - KGF

    ITEM GIRL Mouni Roy
    MOVIE KGF
    DIRECTOR Prashanth Neel
    RELEASE DATE 20st December
    CAST Yash Srinidhi Shetty
    SINGER Neha Kakkar
    MUSIC Tanishk Bagchi
    MUSIC PUBLISHER T-Series
    LYRICS Rashmi Virag



    HUSN PARCHAM - ZERO

    ITEM GIRL Katrina Kaif
    MOVIE ZERO
    DIRECTOR Aanand L. Rai
    RELEASE DATE 21st December
    CAST Shah Rukh Khan, Anushka Sharma, Katrina Kaif
    SINGER Bhoomi Trivedi, Raja Kumari
    MUSIC Ajay – Atul
    MUSIC PUBLISHER T-Series
    LYRICS Irshad Kamil

    Friday, August 25, 2017

    Top 20 Bollywood Movies by Running Time

    Bollywood movies are most entertaining part of everyone's life because of some action, drama, thriller, romance or music. So every person wants to watch movie in cinema or mobile & television.
    When you watch some movies that it's much interesting like you never want to end that and watch and watch again according to own hobby or interest and although some are much boring that you want to leave to see it.
    Here below list of top 20 Bollywood movies according to its running time, which are listed at longest running screen time till now.


    20. M.S. Dhoni: The Untold Story (3h 10m)

     
    RELEASE DATE 30 September 2016
    DIRECTOR Neeraj Pandey
    PRODUCER Arun Pandey
    CAST Sushant Singh Rajput, Disha Patani, Kiara Advani, Anupam Kher, Bhumika Chawla
    RUNNING TIME 190 Minutes


    19. Sholay (3h 24m)

     
    RELEASE DATE 15 August 1975
    DIRECTOR Ramesh Sippy
    PRODUCER G. P. Sippy
    CAST Dharmendra, Amitabh Bachchan, Hema Malini, Jaya Bhaduri, Sanjeev Kumar, Amjad Khan
    RUNNING TIME 204 minutes


    18. Hum Aapke Hain Koun (3h 26m)

     
    RELEASE DATE 5 August 1994
    DIRECTOR Sooraj R. Barjatya
    PRODUCER Ajit Kumar Barjatya, Kamal Kumar Barjatya, Rajkumar Barjatya
    CAST Salman Khan, Madhuri Dixit, Mohnish Bahl, Anupam Kher, Renuka Shahane, Reema Lagoo, Alok Nath
    RUNNING TIME 206 minutes


    17. Waqt (3h 26m)

     
    RELEASE DATE 1965
    DIRECTOR Yash Chopra
    PRODUCER B. R. Chopra
    CAST Raaj Kumar, Shashi Kapoor, Sharmila Tagore, Balraj Sahni, Sunil Dutt, Sadhana
    RUNNING TIME 206 Minutes


    16. Netaji Subhas Chandra Bose: The Forgotten Hero (3h 28m)

     
    RELEASE DATE 13 May 2005
    DIRECTOR Shyam Benegal
    PRODUCER Raj Pius, Barbara von Wrangell
    CAST Sachin Khedekar, Kulbhushan Kharbanda, Rajit Kapur, Divya Dutta
    RUNNING TIME 208 Minutes


    15. Swades (3h 30m)

     
    RELEASE DATE 17 December 2004
    DIRECTOR Ashutosh Gowariker
    PRODUCER Ronnie Screwvala
    CAST Shah Rukh Khan, Gayatri Joshi, Kishori Balal
    RUNNING TIME 210 Minutes


    14. Kabhi Khushi Kabhie Gham (3h 30m)

     
    RELEASE DATE 14 December 2001
    DIRECTOR Karan Johar
    PRODUCER Yash Johar
    CAST Amitabh Bachchan, Jaya Bachchan, Shah Rukh Khan, Kajol, Hrithik Roshan, Kareena Kapoor
    RUNNING TIME 210 Minutes


    13. Khoon Pasina (3h 30m)

     
    RELEASE DATE 21 January 1977
    DIRECTOR Rakesh Kumar
    PRODUCER Babboo Mehra
    CAST Amitabh Bachchan, Vinod Khanna, Rekha, Nirupa Roy
    RUNNING TIME 210 Minutes


    12. Indrasabha (3h 31m)

     
    RELEASE DATE 1932
    DIRECTOR J.J. Madan
    PRODUCER Sayed Aga Hasan Amanat
    CAST Nissar, Jehanara Kajjan, Abdul Rehman Kabuli
    RUNNING TIME 211 Minutes


    11. Saudagar (3h 33m)

     
    RELEASE DATE 9 August 1991
    DIRECTOR Subhash Ghai
    PRODUCER Ashok Ghai
    CAST Dilip Kumar, Raaj Kumar, Manisha Koirala, Vivek Mushran, Amrish Puri, Gulshan Grover, Anupam Kher, Jackie Shroff
    RUNNING TIME 213 Minutes


    10. Jodhaa Akbar (3h 34m)

     
    RELEASE DATE 15 February 2008
    DIRECTOR Ashutosh Gowariker
    PRODUCER Ronnie Screwvala
    CAST Hrithik Roshan, Aishwarya Rai, Sonu Sood
    RUNNING TIME 214 Minutes


    09. Narsimha (3h 34m)

     
    RELEASE DATE 5 July 1991
    DIRECTOR N. Chandra
    PRODUCER N. Chandra
    CAST Sunny Deol, Dimple Kapadia, Urmila Matondkar
    RUNNING TIME 214 Minutes


    08. Kabhi Alvida Naa Kehna (3h 35m)

     
    RELEASE DATE 11 August 2006
    DIRECTOR Karan Johar
    PRODUCER Karan Johar
    CAST Amitabh Bachchan, Shah Rukh Khan, Abhishek Bachchan, Rani Mukerji, Preity Zinta, Kirron Kher
    RUNNING TIME 215 Minutes


    07. Salaam-E-Ishq (3h 36m)

     
    RELEASE DATE 26 January 2007
    DIRECTOR Nikhil Advani
    PRODUCER Sunil Manchanda
    CAST Salman Khan, Anil Kapoor, Govinda, John Abraham, Sohail Khan, Akshaye Khanna, Priyanka Chopra, Vidya Balan, Juhi Chawla, Shannon Esra, Ayesha Takia, Ishaa Koppikar
    RUNNING TIME 216 Minutes


    06. Mohabbatein (3h 36m)

     
    RELEASE DATE 27 October 2000
    DIRECTOR Aditya Chopra
    PRODUCER Yash Chopra
    CAST Amitabh Bachchan, Shah Rukh Khan, Aishwarya Rai, Uday Chopra, Jugal Hansraj, Jimmy Shergill, Shamita Shetty, Kim Sharma, Preeti Jhangianim Anupam Kher
    RUNNING TIME 216 Minutes


    05. Khatarnaak (3h 43m)

     
    RELEASE DATE 19 January 1990
    DIRECTOR Bharat Rangachary
    PRODUCER Raam Shetty
    CAST Sanjay Dutt, Farha Naaz, Anita Raj, Anupam Kher, Kiran Kumar
    RUNNING TIME 223 Minutes


    04. Lagaan (3h 44m)

     
    RELEASE DATE 15 June 2001
    DIRECTOR Ashutosh Gowariker
    PRODUCER Aamir Khan, Mansoor Khan
    CAST Aamir Khan, Gracy Singh, Rachel Shelley, Paul Blackthorne
    RUNNING TIME 224 Minutes


    03. Sangam (3h 58m)

     
    RELEASE DATE 18 June 1964
    DIRECTOR Raj Kapoor
    PRODUCER Raj Kapoor
    CAST Vyjayanthimala, Raj Kapoor, Rajendra Kumar
    RUNNING TIME 238 Minutes


    02. Mera Naam Joker (4h 4m)

     
    RELEASE DATE 18 December 1970
    DIRECTOR Raj Kapoor
    PRODUCER Raj Kapoor
    CAST Raj Kapoor, Simi Garewal, Manoj Kumar, Rishi Kapoor, Dharmendra
    RUNNING TIME 244 Minutes


    01. LOC Kargil (4h 6m)

     
    RELEASE DATE 25 December 2003
    DIRECTOR J.P. Dutta
    PRODUCER J.P. Dutta
    CAST Sanjay Dutt, Ajay Devgan, Karan Nath, Saif Ali Khan, Sunil Shetty, Abhishek Bachchan, Rani Mukerji, Kareena Kapoor, Esha Deol, Raveena Tandon, Preeti Jhangiani
    RUNNING TIME 246 Minutes