Download the PHP package adunblock/server-tag-laravel without Composer
On this page you can find all versions of the php package adunblock/server-tag-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download adunblock/server-tag-laravel
More information about adunblock/server-tag-laravel
Files in adunblock/server-tag-laravel
Package server-tag-laravel
Short Description A Laravel package to fetch and render scripts from a remote URL with caching support.
License ISC
Homepage https://github.com/adunblock/adunblock-server-tag
Informations about the package server-tag-laravel
Server Tag Laravel Package
A Laravel package to fetch and render scripts from a remote URL with caching support. Perfect for server-side script loading and integration with third-party services.
Features
- Server-side script fetching from remote URLs
- Built-in caching support to reduce external requests
- Customizable rendering with closures
- Automatic Laravel service provider registration
- Works seamlessly with Blade templates
- Support for Laravel 8, 9, 10, 11, and 12
Requirements
- PHP 7.4 or higher
- Laravel 8.x, 9.x, 10.x, 11.x, or 12.x
Installation
Install the package via Composer:
The package will be automatically registered via Laravel's package auto-discovery feature.
Usage
Basic Usage
In your Blade template, use the server_tag() helper function to fetch and render scripts from a remote URL:
With Caching
Specify a cache duration (in seconds) as the second parameter:
This will cache the fetched scripts for 5 minutes (300 seconds), reducing external requests.
Custom Script Attributes
Pass an associative array as the fourth parameter to render extra attributes (including data-*) on every generated <script> tag:
Rendering rules:
true→ bare attribute (e.g.defer)false/null→ omitted- any other value →
key="value"(HTML-escaped)
By default every rendered script includes async. Set 'async' => false to disable it.
Custom Rendering
You can provide a custom closure as the third parameter to control how script tags are rendered:
Function Signature
Parameters:
$url(string): The remote URL to fetch scripts from$cache_seconds(int, optional): Cache duration in seconds. Default is 300$render_script(callable, optional): Custom rendering function. Receives an array of script URLs and returns an HTML string$script_attributes(array, optional): Associative array of attributes to render on every<script>tag (e.g.['data-code' => 'abc']). Defaults to['async' => true]
How It Works
- The helper fetches content from the specified remote URL using Laravel's HTTP client
- If caching is enabled, the response is stored in Laravel's cache for the specified duration
- The fetched scripts are rendered as
<script>tags (or using your custom renderer) - The HTML is returned and can be used directly in your Blade templates
License
ISC
Support
- Issues: GitHub Issues
- Homepage: https://github.com/adunblock/adunblock-server-tag
Author
AdUnblock - [email protected]
All versions of server-tag-laravel with dependencies
illuminate/support Version ^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/http Version ^8.0|^9.0|^10.0|^11.0|^12.0