{"id":19092088,"url":"https://github.com/eosnewmedia/external-layout","last_synced_at":"2026-06-29T14:31:34.342Z","repository":{"id":56978013,"uuid":"134702376","full_name":"eosnewmedia/external-layout","owner":"eosnewmedia","description":"Load, modify and store html layouts from remote locally.","archived":false,"fork":false,"pushed_at":"2018-09-26T15:32:17.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-11-12T14:37:16.557Z","etag":null,"topics":["external","layout","layout-manager"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eosnewmedia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-24T10:56:05.000Z","updated_at":"2018-09-26T15:32:19.000Z","dependencies_parsed_at":"2022-08-21T08:10:53.351Z","dependency_job_id":null,"html_url":"https://github.com/eosnewmedia/external-layout","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/eosnewmedia/external-layout","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eosnewmedia%2Fexternal-layout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eosnewmedia%2Fexternal-layout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eosnewmedia%2Fexternal-layout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eosnewmedia%2Fexternal-layout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eosnewmedia","download_url":"https://codeload.github.com/eosnewmedia/external-layout/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eosnewmedia%2Fexternal-layout/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34931586,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-29T02:00:05.398Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["external","layout","layout-manager"],"created_at":"2024-11-09T03:18:02.062Z","updated_at":"2026-06-29T14:31:34.315Z","avatar_url":"https://github.com/eosnewmedia.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"External Layout\n===============\nThis library loads html layouts from remote, modify them for local usage and stores the result into a new file.\n\n## Installation\n```bash\ncomposer require enm/external-layout\n```\nIf you want to use the default (guzzle) loader:\n```bash\ncomposer require guzzlehttp/guzzle\n```\n\n## Usage\n\nTheir are different ways to use this library, depending on your needs.\n\n### Simple\nThe simplest way of usage is to use the layout creator factory with the default guzzle loader (requires `guzzlehttp/guzzle`).\nFor simplest usage you should build your layout definitions from a config array.\n\n```php\n$factory = \\Enm\\ExternalLayout\\LayoutCreatorFactory::withGuzzleLoader();\n$factory-\u003eenableRelativeUrlReplacement(); // adds the \"UrlManipulator\"\n$factory-\u003eenableTwigBlocks(); // adds the \"TwigManipulator\" and the \"WorkingTagFinisher\"\n\n$layoutCreator = $factory-\u003ecreate(); // create a configured instance of the LayoutCreator\n\n$layoutCreator-\u003ecreateFromConfig( // load the original layout, manipulate the content and stores the modified content to the configured file\n  [\n      'source' =\u003e 'http://example.com', // your source url, with username and password (Basic Auth) if needed\n      'destination' =\u003e __DIR__ . '/test.html.twig', // your destination file\n      'blocks' =\u003e [\n          'prepend' =\u003e [\n              'headline' =\u003e 'body' // add block \"body\" as first child of html element \"headline\"\n          ],\n          'append' =\u003e [\n              'stylesheets' =\u003e 'head', // add block \"stylesheets\" as last child of html element \"head\"\n              'javascripts' =\u003e 'body' // add block \"javascripts\" as last child of html element \"body\"\n          ],\n          'replace' =\u003e [\n              'title' =\u003e '%title%', // replace string \"%title%\" with block \"title\"\n              'content' =\u003e '$$content$$' // replace string \"$$content$$\" with block \"content\"\n          ]\n      ]\n  ]\n);\n```\n\n### Customized\nIf you want to customize loading, manipulation or finishing for the layout, you can also use the factory and configure your custom requirements.\n\n```php\n$factory = new \\Enm\\ExternalLayout\\LayoutCreatorFactory(\n    new YourLoader() // here you can set an instance of a different loader, if you don' want to use the guzzle loader\n);\n$factory-\u003eaddManipulator(\n    new YourManipulator() // it is possible to set any number of custom manipulators\n);\n$factory-\u003eaddFinisher(\n    new YourFinisher() // it is possible to set any number of custom finishers\n);\n\n$layoutCreator = $factory-\u003ecreate();\n\n// ... usage the same as above\n\n```\n\n### Fully Customized\nIf 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.\n\n```php\n$layoutCreator = new \\Enm\\ExternalLayout\\LayoutCreator(\n    new YourLoader(), // use your own loader or an instance of \"Enm\\ExternalLayout\\Loader\\GuzzleLoader\"\n    new YourManipulator(), // use your own manipulator or for example an instance of \"Enm\\ExternalLayout\\Loader\\ManipulatorChain\"\n    new YourFinisher() // use your own finisher or for example an instance of \"Enm\\ExternalLayout\\Loader\\FinisherChain\"\n);\n\n// ... usage the same as above\n```\n\n## Customization\n\nThe library works as follows:\n1. Load contents from source url into a \\DomDocument (\"loaders\")\n1. Manipulate the \\DomDocument for example with content replacements or block for your templating (\"manipulators\")\n1. Finish the layout with simple plain text processing (\"finishers\")\n1. Store the manipulated and finished html content into the configured file\n\n### Loaders\nLoaders are responsible for loading the html content of the given uri into a \\DomDocument.\n\nYou can use the default loader (`Enm\\ExternalLayout\\Loader\\GuzzleLoader`) which requires an instance of (`GuzzleHttp\\ClientInterface`; composer: `guzzlehttp/guzzle`) or you\ncan implement the `Enm\\ExternalLayout\\Loader\\LoaderInterface` by yourself.\n\n### Manipulators\nManipulators are responsible for manipulation of the loaded \\DomDocument. Manipulators could change contents, remove or \nadd new dom elements or insert blocks for different templating languages (default Twig).\n\nIf you want to use more than one manipulator you can add all your manipulators to an instance of `Enm\\ExternalLayout\\Manipulator\\ManipulatorChain`.\nA manipulator must implement `Enm\\ExternalLayout\\Manipulator\\ManipulatorInterface`.\n\nAvailable manipulators are:\n- `UrlManipulator`: Replace relative urls with absolute urls (needed because assets normally are farther loaded from original source)\n- `TwigManipulator`: Replace strings with twig blocks; prepend or append twig blocks to html elements\n- `BaseUrlManipulator`: Removes the base tag to avoid invalid local relative paths\n\n### Finishers\nFinishers are responsible for cleanup and string replacements which are not possible in a \\DomDocument.\n\nIf you want to use more than one finisher you can add all your finishers to an instance of `Enm\\ExternalLayout\\Finisher\\FinisherChain`.\nA finisher must implement `Enm\\ExternalLayout\\Finisher\\FinisherInterface`.\n\nAvailable finishers are:\n- `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\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feosnewmedia%2Fexternal-layout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feosnewmedia%2Fexternal-layout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feosnewmedia%2Fexternal-layout/lists"}