1. Go to this page and download the library: Download enm/external-layout library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
enm / external-layout example snippets
$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"
]
]
]
);
$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
$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
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.