PHP code example of tomkirsch / bootstrap

1. Go to this page and download the library: Download tomkirsch/bootstrap library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tomkirsch / bootstrap example snippets


class Resize extends BaseController{
	public function index(){
		$file = $this->request->getGet('f');
		$width = $this->request->getGet('w');
		$resource = service('image')
			->withFile($file)
			->resize($width, $width, TRUE, 'width')
			->getResource()
		;
		ob_end_flush();
		header('Content-Type: image/jpeg');
		imagejpeg($resource, NULL, 75);
		imagedestroy($resource);
		exit;
	}
}

<?= \Config\Services::bootstrap()->staticImage()->renderSources([
	"prettyPrint" => TRUE,
	"imgAttr" => ["class" => "img-fluid"], // optional - creates the <img>
	"widths" => [2080, 1040, 520, 260],
	"file" => function ($width, $resolution) {
		return "kitten-$width.jpg";
	},
])