Available Frameworks
Laravel
Blade helper function with built-in caching and auto-discovery
Symfony
Twig extension with dependency injection and bundle structure
Expected Remote Response Format
All PHP packages expect the remote URL to return JSON in this format:Laravel Integration
A Laravel package to fetch and render scripts from a remote URL with caching support.Installation
Install the package via Composer:Basic Usage
In your Blade template, you can now use theserver_tag function:
Custom Rendering
You can provide a custom closure to therender_script argument to render the script tags in a different way:
Laravel Features
- Blade Helper Function: Easy-to-use function for templates
- Built-in Caching: Automatic caching with configurable TTL
- Auto-discovery: Automatic service provider registration
- Error Handling: Graceful fallback to empty arrays
- Security: XSS protection with proper HTML escaping
Laravel Requirements
- PHP 7.4 or higher
- Laravel 8/9/10/11
Symfony Integration
A Symfony bundle to fetch and render scripts from a remote URL with Twig integration and caching support.Installation
Install the bundle via Composer:config/bundles.php:
Basic Usage
In your Twig template, you can now use theserver_tag function:
Custom Rendering
You can provide a custom callable to therender_script parameter to customize how script tags are rendered:
Symfony Features
- Twig Integration: Easy-to-use Twig function for templates
- HTTP Client: Uses Symfony’s HTTP client for reliable requests
- Caching: Built-in caching support with configurable TTL
- Error Handling: Graceful error handling with fallback to empty arrays
- Security: XSS protection with proper HTML escaping
- Bundle Structure: Proper Symfony bundle with dependency injection
Symfony Requirements
- PHP 7.4 or higher
- Symfony 5.0, 6.0, or 7.0
- Twig 2.0 or 3.0
Common Features
All PHP packages provide:- ✅ Remote Script Fetching: Fetch JavaScript files from external URLs
- ✅ Caching Support: Built-in caching with configurable TTL
- ✅ Error Handling: Graceful fallback when remote URLs are unavailable
- ✅ Security: XSS protection with proper HTML escaping
- ✅ Custom Rendering: Support for custom script tag rendering
Security Considerations
- URL Validation: Only HTTP and HTTPS URLs are allowed
- XSS Protection: All output is properly escaped
- Error Handling: Failed requests don’t break page rendering
- Caching: Reduces load on remote servers
Performance Tips
- Use Caching: Configure appropriate cache intervals for your use case
- Error Handling: Implement proper fallbacks for failed requests
- CDN Usage: Use CDN URLs for better performance
- Cache Warming: Pre-warm caches during deployment

