PHPackages                             enm/external-layout - 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. enm/external-layout

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

enm/external-layout
===================

Load, modify and store html layouts from remote locally

1.1.2(7y ago)01851MITPHPPHP ^7.2

Since May 24Pushed 7y ago6 watchersCompare

[ Source](https://github.com/eosnewmedia/external-layout)[ Packagist](https://packagist.org/packages/enm/external-layout)[ RSS](/packages/enm-external-layout/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (4)Versions (7)Used By (1)

External Layout
===============

[](#external-layout)

This library loads html layouts from remote, modify them for local usage and stores the result into a new file.

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

[](#installation)

```
composer require enm/external-layout
```

If you want to use the default (guzzle) loader:

```
composer require guzzlehttp/guzzle
```

Usage
-----

[](#usage)

Their are different ways to use this library, depending on your needs.

### Simple

[](#simple)

The simplest way of usage is to use the layout creator factory with the default guzzle loader (requires `guzzlehttp/guzzle`). For simplest usage you should build your layout definitions from a config array.

```
$factory = \Enm\ExternalLayout\LayoutCreatorFactory::withGuzzleLoader();
$factory->enableRelativeUrlReplacement(); // adds the "UrlManipulator"
$factory->enableTwigBlocks(); // adds the "TwigManipulator" and the "WorkingTagFinisher"

$layoutCreator = $factory->create(); // create a configured instance of the LayoutCreator

$layoutCreator->createFromConfig( // load the original layout, manipulate the content and stores the modified content to the configured file
  [
      'source' => 'http://example.com', // your source url, with username and password (Basic Auth) if needed
      'destination' => __DIR__ . '/test.html.twig', // your destination file
      'blocks' => [
          'prepend' => [
              'headline' => 'body' // add block "body" as first child of html element "headline"
          ],
          'append' => [
              'stylesheets' => 'head', // add block "stylesheets" as last child of html element "head"
              'javascripts' => 'body' // add block "javascripts" as last child of html element "body"
          ],
          'replace' => [
              'title' => '%title%', // replace string "%title%" with block "title"
              'content' => '$$content$$' // replace string "$$content$$" with block "content"
          ]
      ]
  ]
);
```

### Customized

[](#customized)

If you want to customize loading, manipulation or finishing for the layout, you can also use the factory and configure your custom requirements.

```
$factory = new \Enm\ExternalLayout\LayoutCreatorFactory(
    new YourLoader() // here you can set an instance of a different loader, if you don' want to use the guzzle loader
);
$factory->addManipulator(
    new YourManipulator() // it is possible to set any number of custom manipulators
);
$factory->addFinisher(
    new YourFinisher() // it is possible to set any number of custom finishers
);

$layoutCreator = $factory->create();

// ... usage the same as above
```

### Fully Customized

[](#fully-customized)

If you want a fully customized implementation (for example for usage with a dependency injection service container), you could create all instances without factory by yourself.

```
$layoutCreator = new \Enm\ExternalLayout\LayoutCreator(
    new YourLoader(), // use your own loader or an instance of "Enm\ExternalLayout\Loader\GuzzleLoader"
    new YourManipulator(), // use your own manipulator or for example an instance of "Enm\ExternalLayout\Loader\ManipulatorChain"
    new YourFinisher() // use your own finisher or for example an instance of "Enm\ExternalLayout\Loader\FinisherChain"
);

// ... usage the same as above
```

Customization
-------------

[](#customization)

The library works as follows:

1. Load contents from source url into a \\DomDocument ("loaders")
2. Manipulate the \\DomDocument for example with content replacements or block for your templating ("manipulators")
3. Finish the layout with simple plain text processing ("finishers")
4. Store the manipulated and finished html content into the configured file

### Loaders

[](#loaders)

Loaders are responsible for loading the html content of the given uri into a \\DomDocument.

You can use the default loader (`Enm\ExternalLayout\Loader\GuzzleLoader`) which requires an instance of (`GuzzleHttp\ClientInterface`; composer: `guzzlehttp/guzzle`) or you can implement the `Enm\ExternalLayout\Loader\LoaderInterface` by yourself.

### Manipulators

[](#manipulators)

Manipulators are responsible for manipulation of the loaded \\DomDocument. Manipulators could change contents, remove or add new dom elements or insert blocks for different templating languages (default Twig).

If you want to use more than one manipulator you can add all your manipulators to an instance of `Enm\ExternalLayout\Manipulator\ManipulatorChain`. A manipulator must implement `Enm\ExternalLayout\Manipulator\ManipulatorInterface`.

Available manipulators are:

- `UrlManipulator`: Replace relative urls with absolute urls (needed because assets normally are farther loaded from original source)
- `TwigManipulator`: Replace strings with twig blocks; prepend or append twig blocks to html elements
- `BaseUrlManipulator`: Removes the base tag to avoid invalid local relative paths

### Finishers

[](#finishers)

Finishers are responsible for cleanup and string replacements which are not possible in a \\DomDocument.

If you want to use more than one finisher you can add all your finishers to an instance of `Enm\ExternalLayout\Finisher\FinisherChain`. A finisher must implement `Enm\ExternalLayout\Finisher\FinisherInterface`.

Available finishers are:

- `WorkingTagFinisher`: Remove "working tags", which are used to generate valid xml content for the \\DomDocument where actually no tag in the finished content is needed

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

Established project with proven stability

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 ~31 days

Total

5

Last Release

2827d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c18ae5f024ce04dbd7c18fb39db1ebe9c4feb654d0cc6f54f206404355d2500b?d=identicon)[eosnewmedia](/maintainers/eosnewmedia)

---

Tags

externallayoutlayout-manager

### Embed Badge

![Health badge](/badges/enm-external-layout/health.svg)

```
[![Health](https://phpackages.com/badges/enm-external-layout/health.svg)](https://phpackages.com/packages/enm-external-layout)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.2k532.1M2.5k](/packages/aws-aws-sdk-php)[craftcms/cms

Craft CMS

3.6k3.6M2.9k](/packages/craftcms-cms)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M196](/packages/sulu-sulu)[symfony/asset-mapper

Maps directories of assets &amp; makes them available in a public directory with versioned filenames.

1668.1M213](/packages/symfony-asset-mapper)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

318117.1k1](/packages/cognesy-instructor-php)

PHPackages © 2026

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