PHPackages                             schnoop/laravel-remote-template - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. schnoop/laravel-remote-template

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

schnoop/laravel-remote-template
===============================

A Laravel package to fetch templates from a remote URL.

v1.0.1(6y ago)14.4k↓77.8%[1 PRs](https://github.com/Schnoop/laravel-remote-template/pulls)MITPHPPHP ^7.1CI failing

Since Aug 31Pushed 11mo ago3 watchersCompare

[ Source](https://github.com/Schnoop/laravel-remote-template)[ Packagist](https://packagist.org/packages/schnoop/laravel-remote-template)[ Docs](https://github.com/schnoop/laravel-remote-template)[ RSS](/packages/schnoop-laravel-remote-template/feed)WikiDiscussions develop Synced 3w ago

READMEChangelog (1)Dependencies (4)Versions (15)Used By (0)

Laravel Remote Template
=======================

[](#laravel-remote-template)

[![Latest Version](https://camo.githubusercontent.com/d13b039ffe29c8e9aee1652f7f91e45c4970e14b57d84aaa666a6eeacf4145b5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f7363686e6f6f702f6c61726176656c2d72656d6f74652d74656d706c6174652e7376673f7374796c653d666c61742d737175617265)](https://github.com/schnoop/laravel-remote-template/releases)[![Build Status](https://camo.githubusercontent.com/3ed56d38a6f251c76b64f3bb56efc9cc777822c916a80488fdad1797b50ece78/68747470733a2f2f7472617669732d63692e6f72672f5363686e6f6f702f6c61726176656c2d72656d6f74652d74656d706c6174652e7376673f6272616e63683d646576656c6f70)](https://travis-ci.org/Schnoop/laravel-remote-template)[![Quality Score](https://camo.githubusercontent.com/c5ea8cd8eb45fe0a893ca99dc0de4e32f1d77bc9154c00f6633304559bccd0ab/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7363686e6f6f702f6c61726176656c2d72656d6f74652d74656d706c6174652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/schnoop/laravel-remote-template)[![StyleCI](https://camo.githubusercontent.com/d08d2ab343a1329b39003ed434a8a18e3a3fcdccbd2e25dbab10c28445a83fc8/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3230353433393037322f736869656c643f6272616e63683d646576656c6f70)](https://github.styleci.io/repos/205439072)[![Total Downloads](https://camo.githubusercontent.com/b5f424d16f349862ac61a6186ca1f14c022e1c375de44c994bed41f98ce0a545/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7363686e6f6f702f6c61726176656c2d72656d6f74652d74656d706c6174652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/schnoop/laravel-remote-template)

`laravel-remote-template` is a package for fetching blade templates from a remote URL.

What is the use case for fetching content from a remote url?
------------------------------------------------------------

[](#what-is-the-use-case-for-fetching-content-from-a-remote-url)

Imagine your customer wants you to build a fully flexible application but also would like to manage the content by themself. Laravel is great for building applications - but managing content is not the focus. Maybe you have expirences in Content Management System - but hey, those aren't as flexible as Laravel in building applications. Why not use both? A CMS for the content and Laravel for the application. This package helps you to use content that is remote available for rendering in Laravel applications.

- [Installation](#installation)
- [Configuration](#configuration)
    - [Configuring the remote delimiter](#configuring-the-remote-delimiter)
    - [Configuring the view folder](#configuring-the-view-folder)
    - [Configuring the remote host](#configuring-the-remote-host)
    - [Configuring the URL mappings](#configuring-the-url-mappings)
    - [Configuring remote URls that should be ignored](#configuring-remote-urls-that-should-be-ignored)
    - [Configuring remote URls suffixes that should be ignored](#configuring-remote-urls-suffixes-that-should-be-ignored)
    - [Other configuration options](#other-configuration-options)
- [Using a fallback route](#using-a-fallback-route)
- [Modify remote URL before call is executed](#modify-remote-url-before-call-is-executed)
- [Push response handlers](#push-response-handlers)

Installation
------------

[](#installation)

Simply install the package with composer:

```
composer require schnoop/laravel-remote-template
```

If you are using an older version of Laravel (&lt; 5.5), you will also need to add our service provider to your app configuration (`config/app.php`):

```
'providers' => [
    ...
    Schnoop\RemoteTemplate\RemoteTemplateServiceProvider::class,
],
```

Next, publish the configuration files:

```
php artisan vendor:publish --provider="Schnoop\RemoteTemplate\RemoteTemplateServiceProvider"
```

Configuration
-------------

[](#configuration)

#### Configuring the remote delimiter

[](#configuring-the-remote-delimiter)

The package extends Laravels FileViewFinder class used to resolve views by name. When encountering a special remote delimiter token, the configured remote host will be used to resolve the view instead of the local filesystem.

```
'remote-delimiter' => 'remote:',
```

Now, everytime you call or include a view by name and the name starts with `remote:`, the template is fetched from the remote host. Example:

```
@extends('remote:login')

{{-- Content --}}
@section('content')
	...
@endsection
```

The following would still resolve the view using the default Laravel (filesystem) behaviour:

```
@extends('layouts.master')

{{-- Content --}}
@section('content')
	...
@endsection
```

#### Configuring the view folder

[](#configuring-the-view-folder)

When resolving the remote templates, the files are downloaded to a special view folder. The view folder can be customized via the `view-folder` configuration option. If caching is enabled, these files will be re-used for subsequent requests and will not fire new requests to the remote host.

#### Configuring the remote host

[](#configuring-the-remote-host)

You can configure multiple remote hosts with unique identifiers using the `hosts` configuration option. The identifier can then be appended to the remote delimiter.

```
'hosts' => [
	'base' => [
    	...
    ],
],
```

The following example will use the `base` remote host to resolve the template:

```
@extends('remote:base::login')

{{-- Content --}}
@section('content')
	...
@endsection
```

If a `default` host is specified, it will be used when no other namespace is used. The following example will use the `default` host:

```
@extends('remote:login')

{{-- Content --}}
@section('content')
	...
@endsection
```

The host base URL can defined using the `hosts.*.host` configuration option:

```
'hosts' => [
        'default' => [
            'host' => env('CONTENT_DOMAIN'),
        ],
    ],
```

#### Configuring the URL mappings

[](#configuring-the-url-mappings)

Any token following the remote delimiter and host identifier will be used to construct the URL for the remote host. In the example above, a request would be made to `www.yourhost.com/login`, and the response would be used as the resolved view file. If you wish to configure custom mappings, you can do so using the `mappings` configuration option:

```
'hosts' => [
        'default' => [
            ...
            'mapping' => [
                'login' => '/index.php?id=51',
            ],
        ],
    ],
```

#### Configuring remote URls that should be ignored

[](#configuring-remote-urls-that-should-be-ignored)

If you have URLs that you don't want to expose via these fallback, you can configure those in the config file;

- `ignore-urls`: Is an array that can hold multiple urls that should not be resolved via the content host.

```
'ignore-urls' => [
    'foo'
],
```

If the request url to the remote host starts with any configured `ignore-urls`, you will receive an UrlIsForbiddenException instead of content:

e.g:

-
-
-
-

#### Configuring remote URls suffixes that should be ignored

[](#configuring-remote-urls-suffixes-that-should-be-ignored)

Instead of configuring URLs starting with an particular string, you also can deny access to urls that end with a suffix:

```
'ignore-url-suffix' => [
    'png',
    'jpg',
    'jpeg',
    'css',
    'js',
    'woff',
    'ttf',
    'gif',
    'svg'
],
```

In the case above we are denying the request to any static file.

#### Other configuration options

[](#other-configuration-options)

- `hosts.*.cache`: When set to true, requests to the remote host are only made if no matching template could be found in the view folder. If a template is found, it will be re-used for resolving the view.
- `hosts.*.request_options`: Array of request options that will be passed to the Guzzle HTTP client when making the request to the remote host. This option can be used to configure authentication.

Using a fallback route
----------------------

[](#using-a-fallback-route)

By using a fallback route in combination with a default view, any requests that do not match a route defined in Laravel will instead be forwarded to any of the configured remote hosts.

In your `routes/web.php` file:

```
Route::fallback('FallbackController@fallback');
```

The controller would then simply call a view and pass the requesting URL:

```
class FallbackController extends Controller
{
    /**
     * Fallback.
     *
     * @param Request $request
     *
     * @return View
     */
    public function fallback(Request $request): View
    {
        return view('cms::fallback')->with('uri', $request->getRequestUri());
    }
}
```

And the view would pass the URL to the remote host:

```
@extends('remote:'.$uri)
```

Now, for any requests made to routes not defined in the application, a request will be made to the remote host. If a successful response is returned, it will be used as the view. Otherwise a `404` response will be returned.

Modify remote URL before call is executed
-----------------------------------------

[](#modify-remote-url-before-call-is-executed)

Someday, you will have the case, that you would like to force the remote host to render the template based on a state in your Laravel application. A very common case is definitely to change the navigation if a user is authenticated.

To achieve this, we have a callback that will be triggered right before the call to the remote host happens:

```
$this->app->make('remoteview.finder')->setModifyTemplateUrlCallback(function ($url) {
    return $url;
});
```

In this callback, you have the chance to modify the request url as needed to tell the remote host to change its template rendering:

```
$this->app->make('remoteview.finder')->setModifyTemplateUrlCallback(function ($url) {
    $glue = '?';
    if (strpos($url, $glue) !== false) {
        $glue = '&';
    }

    if (Auth::check() === true) {
        $url .= $glue . 'login=true';
    }

    // ..... following by more role checks e.g.

    return $url;
});
```

Push response handlers
----------------------

[](#push-response-handlers)

Last but not least you have the option to push handlers that will be executed after the call has happened: Those handlers are assigned to response codes, that the remote host returns:

In the following example the handler will be executed only if the remote host respond with a 301 HTTP status code.

```
$this->app->make('remoteview.finder')->pushResponseHandler(301, function (Response $result, array $config, RemoteTemplateFinder $service) {
    // Do some stuff, and return the HTML.
});
```

A common case is that maybe the remote host responds with 301, which is a redirect to another url. In this case we would like to parse the destination out of the response, and fetch the content from there. To achieve this, an instance of RemoteTemplateFinder is injected in the function that can be used to execute further calls.

```
$this->app->make('remoteview.finder')->pushResponseHandler(301, function (Response $result, array $config, RemoteTemplateFinder $service) {
    return $service->fetchContentFromRemoteHost($result->getHeaderLine('Location'), $config);
});
```

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 86.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~356 days

Recently: every ~395 days

Total

7

Last Release

348d ago

Major Versions

v1.0.1 → 6.0.x-dev2021-03-11

6.0.x-dev → 9.0.x-dev2023-01-13

9.0.x-dev → 10.x-dev2024-10-02

10.x-dev → 11.x-dev2024-12-06

11.x-dev → 12.x-dev2025-07-10

PHP version history (4 changes)v1.0PHP ^7.1

6.0.x-devPHP &gt;=7.2.5

9.0.x-devPHP ^8.1

10.x-devPHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/7185ec01915d7f04ebd191be541786e5f1b61ab909e81f71f836a6631ef82e26?d=identicon)[Schnoop](/maintainers/Schnoop)

---

Top Contributors

[![Schnoop](https://avatars.githubusercontent.com/u/1263407?v=4)](https://github.com/Schnoop "Schnoop (32 commits)")[![chiiya](https://avatars.githubusercontent.com/u/15029301?v=4)](https://github.com/chiiya "chiiya (3 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/schnoop-laravel-remote-template/health.svg)

```
[![Health](https://phpackages.com/badges/schnoop-laravel-remote-template/health.svg)](https://phpackages.com/packages/schnoop-laravel-remote-template)
```

###  Alternatives

[backpack/crud

Quickly build admin interfaces using Laravel, Bootstrap and JavaScript.

3.4k3.6M217](/packages/backpack-crud)[grumpydictator/firefly-iii

Firefly III: a personal finances manager.

23.8k69.4k](/packages/grumpydictator-firefly-iii)[unopim/unopim

UnoPim Laravel PIM

10.3k2.2k](/packages/unopim-unopim)[backpack/basset

Dead-simple way to load CSS or JS assets only once per page, when using Laravel 10+.

207923.1k10](/packages/backpack-basset)[firefly-iii/data-importer

Firefly III Data Import Tool.

7965.8k](/packages/firefly-iii-data-importer)[nickurt/laravel-akismet

Akismet for Laravel 11.x/12.x/13.x

98145.2k3](/packages/nickurt-laravel-akismet)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
