Setting up PEAR mail on Scotch Box

You have Vagrant and Scotch Box installed. You still need to install Pear.

$ vagrant ssh
$ sudo apt-get -y install php-pear
$ sudo pear install mail_mime

In your PHP script

include_once('Mail.php');
include_once('Mail/mime.php');

Parameters to define SMTP Scotch Box

$params["host"] = "127.0.0.1";
$params["port"] = 1025;
$params["Date"] = date('r',time());
$mail = Mail::factory("smtp",$params);
...

Catch mails in Mailhog at http://192.168.33.10:8025

PHP UTF8 test-template (jQuery, Bootstrap)

This is just a webdevelopment template for PHP (all errors, xdebug), HTML, jQuery, Bootstrap (UTF8 encoding).

<?php
ini_set('display_errors' , 'On');
error_reporting(E_ALL);
session_start();
header("Content-Type:text/html;charset=utf-8");
ini_set('xdebug.var_display_max_depth', -1);
ini_set('xdebug.var_display_max_children', -1);
ini_set('xdebug.var_display_max_data', -1);
?>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Your Page Title</title>
	<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
	<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js" integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://code.jquery.com/jquery-migrate-3.3.2.min.js"></script>

</head>
<body>
	<div class="container">
		<div class="row">
			<div class="col-md-12">


			</div>
		</div>
	</div>
</body>
</html>

PHP long running script without Ajax

<?php
header("Content-Type:text/html;charset=utf-8");
session_start();
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type"  content="text/html; charset=utf-8" />
</head>
<body>
<?php

$executiontime = 5; // max time for scripting
$sleeptime = 3; // seconds to pauze after execution time limit


if(!isset($_GET["continue"])){

	$_SESSION["numbers"] = range(1,100000);
	$_SESSION["genesis"] = microtime(true); // absolute start time
	echo count($_SESSION["numbers"]);

}

$_SESSION["starttime"] = microtime(true); // 'this round' start time

foreach($_SESSION["numbers"] as $key=>$value){

		sleep(1);
		// abort and 'reload' upon exceeding execution time
		if((microtime(true) - $_SESSION["starttime"]) > $executiontime){
			echo "<p>" . count($_SESSION["numbers"]) . " items left";			
			echo "<br>This round: " . round((microtime(true) - $_SESSION["starttime"]),2) . " seconds";		
			echo "<br>Total time: " . round((microtime(true) - $_SESSION["genesis"])/60,2) . " minutes";
			echo "<p><strong>Pause script...</strong> Resume in $sleeptime seconds...</p>";
			die ('<meta http-equiv="refresh" content="'.$sleeptime.';URL='.$_SERVER['SCRIPT_URI'].'?continue=1" /></body></html>');
		}
		
		// do some stuff while execution time is still ok
	
		unset($_SESSION["numbers"][$key]);
}

echo "<br>Completed...: total time " . round((microtime(true) - $_SESSION["genesis"])/60,2) . " minutes";