PHP

php -S 0.0.0.0:<PORT_NUMBER>

// Where PORT_NUMBER is an integer from 1024 to 49151
// Well-known ports reserved for priviledged services range from 0 through 1023.
// Registered ports are 1024 to 49151.
// Dynamic ports (also called private ports) are 49152 to 65535.

// -S means "Run with built-in web server

// If you use localhost (the host name for IP address 121.0.0.1 which is the loopback address to your computer) rather than 0.0.0.0 you may hit a connection refused error. 
// Loopback addresses range from 127.0.0.1 ~ 127.255.255.254 but using 121.0.0.1 is common practice.
// Listening on 0.0.0.0 means listening from anywhere that has network access to "this" computer (all interfaces) including the loopback address. To make the web server accessible to any interface, use 0.0.0.0 as opposed to 121.0.0.1 (localhost).
// 0.0.0.0 means all IPv4 addresses on the local machine. If a host has two IP addresses, 192.168.1.1 and 10.1.2.1, and a server running on the host listens on 0.0.0.0, it will be reachable at both of those IPs.

// Run the command from a folder containing either an index.php or index.html otherwise specify a file in the URI request. E.g.:

php -S 0.0.0.0:8000 router.php

// then navigate in your browser to http://localhost:8000/ 
// Route code

Route::get('/test/excel', function() {
    $zip_file = 'invoices.zip'; // Name of our archive to download

    // Initializing PHP class
    $zip = new \ZipArchive();
    $zip->open($zip_file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);

    $invoice_file = 'app/exports/file.xls'; // This is a storage file path - as in, storage/app/exports/file.xls

    // Adding file: second parameter is what will the path inside of the archive
    // So it will create another folder called "storage/" inside ZIP, and put the file there.
    $zip->addFile(storage_path($invoice_file), $invoice_file);
    $zip->close();

    // We return the file immediately after download
    event(new TestExcel($zip_file));

    flash()->success('test');

    return redirect('/contacts');
});

// Event code

<?php

namespace App\Events;

use App\Events\Event;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class TestExcel extends Event
{
    use SerializesModels;

    /*
     * get the require info for sending email
     */
    public $contact;
    public $errors;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct($zip_file)
    {
        $this->zip_file = $zip_file;
    }

    /**
     * Get the channels the event should be broadcast on.
     *
     * @return array
     */
    public function broadcastOn()
    {
        return [];
    }
}

// Listener code

<?php

namespace App\Listeners;

use App\Events\Interactions\InteractionsEmailError;
use App\Events\TestExcel;
use App\Mail\Mailers\ComplexMailable;
use App\Mail\Mailers\SimpleMailable;
use Illuminate\Support\Facades\Mail;

class WhenTestExcel
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  InteractionsEmailError $event
     * @return void
     */
    public function handle(TestExcel $event)
    {
        $this->sendInteractionsEmail($event->zip_file);
    }

    public function sendInteractionsEmail($zip_file)
    {
        $data = [
            'view' => 'emails.leads.referrals.referrers_to_be_contacted',
            'subject' => 'CRM Lead Referrers Report',
            'attachments' => $zip_file,
            'content' => 'Find attached details of the referrers who requested to be contacted.',
            'to' => 'clientservice@cytonn.com',
        ];

        Mail::send(new ComplexMailable($data));
    }
}

Similiar Collections

Python strftime reference pandas.Period.strftime python - Formatting Quarter time in pandas columns - Stack Overflow python - Pandas: Change day - Stack Overflow python - Check if multiple columns exist in a df - Stack Overflow Pandas DataFrame apply() - sending arguments examples python - How to filter a dataframe of dates by a particular month/day? - Stack Overflow python - replace a value in the entire pandas data frame - Stack Overflow python - Replacing blank values (white space) with NaN in pandas - Stack Overflow python - get list from pandas dataframe column - Stack Overflow python - How to drop rows of Pandas DataFrame whose value in a certain column is NaN - Stack Overflow python - How to drop rows of Pandas DataFrame whose value in a certain column is NaN - Stack Overflow python - How to lowercase a pandas dataframe string column if it has missing values? - Stack Overflow How to Convert Integers to Strings in Pandas DataFrame - Data to Fish How to Convert Integers to Strings in Pandas DataFrame - Data to Fish create a dictionary of two pandas Dataframe columns? - Stack Overflow python - ValueError: No axis named node2 for object type <class 'pandas.core.frame.DataFrame'> - Stack Overflow Python Pandas iterate over rows and access column names - Stack Overflow python - Creating dataframe from a dictionary where entries have different lengths - Stack Overflow python - Deleting DataFrame row in Pandas based on column value - Stack Overflow python - How to check if a column exists in Pandas - Stack Overflow python - Import pandas dataframe column as string not int - Stack Overflow