1. Go to this page and download the library: Download asinfotrack/yii2-toolbox 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/ */
asinfotrack / yii2-toolbox example snippets
// ...
'urlManager'=>[
'class'=>'\asinfotrack\yii2\toolbox\components\MemoryUrlManager',
'memoryMap'=>[
//the controller
'mycontroller'=>[
//the action
'myindexaction'=>[
//regex rules...if a param matches a rule it will be memorized
'/^SearchForm/',
//if a rule is specified like this, the regex is only enabled if the callback returns true
'page'=>function() {
return rand(0,1) == 1;
},
],
],
//modules work the same, except they have one level more
'mymodule'=>[
'mymodulecontroller'=>[
//the action
'mymoduleaction'=>[
//regex rules...if a param matches a rule it will be memorized
'/^MyForm/',
],
],
],
],
],
// ...
public function actionPdf()
{
//create pdf with some library (eg FPDF)
$pdf = new FPDF();
// ...
$response = Yii::$app->response;
$response->data = $pdf->Output();
$response->format = 'pdf';
}