PHP code example of mosaxiv / cakephp-secure-target-blank

1. Go to this page and download the library: Download mosaxiv/cakephp-secure-target-blank 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/ */

    

mosaxiv / cakephp-secure-target-blank example snippets


// src/View/AppView.php

namespace App\View;

use Cake\View\View;
use SecureTargetBlank\View\Helper\HtmlHelper;

class AppView extends View
{
    public function initialize()
    {
        $this->loadHelper('Html', [
            'className' => HtmlHelper::class
        ]);
    }
}

$this->Html->link('test', 'http://example.com', ['target' => '_blank'])

$this->Html->link('test_title', ['controller' => 'test'], ['target' => '_blank', 'secureBlank' => false]);