PHP code example of adunblock / server-tag-laravel

1. Go to this page and download the library: Download adunblock/server-tag-laravel 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/ */

    

adunblock / server-tag-laravel example snippets


<!DOCTYPE html>
<html>
<head>
  <title>My Page</title>
  {!! server_tag('https://your-remote-url.com/scripts') !!}
</head>
<body>
  <h1>My Page</h1>
</body>
</html>

{!! server_tag('https://your-remote-url.com/scripts', 300) !!}

{!!
  server_tag('https://your-remote-url.com/scripts', 300, null, [
    'data-code' => 'abc123',
    'data-source' => 'server-tag',
    'defer' => true,
  ])
!!}

{!!
  server_tag('https://your-remote-url.com/scripts', 300, function($scripts) {
    $scriptTags = array_map(function ($src) {
      return "<script src=\"{$src}\" defer></script>";
    }, $scripts);
    return implode("\n", $scriptTags);
  })
!!}

server_tag(string $url, int $cache_seconds = 300, ?callable $render_script = null, ?array $script_attributes = null): string