The library generates Google AMP sites using PHP by using procedural code.
This application simplifies (via code) the generation of an AMP site. It's easiest to program, just a few of lines of code and that's it.
For example, let's say that you want to add a new section
$secImage= new SectionModel("The Cupcakes","","/image.jpg");
$secImage->buttons[]=new ButtonModel("More Information","#");
$secImage->buttons[]=new ButtonModel("More Information","#","warning");
$amp->sectionImage($secImage,2250,441);
It will generate the next visual:
use eftec\AmpGeneratorOne\AmpGeneratorOne;
use eftec\AmpGeneratorOne\ButtonModel;
use eftec\AmpGeneratorOne\FooterModel;
use eftec\AmpGeneratorOne\HeaderModel;
use eftec\AmpGeneratorOne\HeadModel;
use eftec\AmpGeneratorOne\LinkModel;
use eftec\AmpGeneratorOne\SectionModel;
include "lib/AmpGeneratorOne.php";
$amp=new AmpGeneratorOne("https://www.canonical.com","https://www.canonical.com/amp");
// #
$amp->startAmp(new HeaderModel("description","title","favicon.ico"));
// # sidebar (optional)
$amp->sidebar($menu); // $menu is an array of /LinkModel()
// #1 head (the top bar)
$amp->head(new HeadModel("",$base."logo.png"),70,70);
// # example section
$amp->sectionFirst(new SectionModel("Title","Description"));
// # footer
$amp->sectionFooter(new FooterModel("Copyright something(c)","See as desktop"));
amp->render(); // you also could generate a file.
Tablet version
Mobile version
Mobile version (slider open)
AmpGeneratorOne constructor.
- $canonical Original url . Example https://www.southprojects.com/somesite (string)
- $base Original base url without trailing slash. Example https://www.southprojects.com (string)
- $sidebarColor The background color of the sidebar Example #ffffff,white,rgb(255,255,255) (string)
- $themecolor .The color of the logo,burger Example #ffffff,white,rgb(255,255,255) (string)
- $classSidebar. text-primary,text-secondary,text-success,text-info,text-warning,text-danger,text-white,text-black (string)
Fix an url and convert a relative url into an absolute url
- $url param $url ()
$tmp=$ampgeneratorone->fixRelativeUrlthis();
It generates the social and seo structure (Twitter card, Facebook OG and Google Schema)
- $structured param StructureModel $structured (StructureModel)
$tmp=$ampgeneratorone->genStructuredthis();
Start to generate an Amp site.
- $param param HeaderModel $param (HeaderModel)
- $structured param StructureModel $structured (StructureModel)
Generates a sidebar.
- $urls param LinkModel[] $urls (LinkModel[])
$tmp=$ampgeneratorone->sidebarthis();
Generates the header navigation
- $param param HeadModel $param (HeadModel)
- $width param int $width (int)
- $height param int $height (int)
$tmp=$ampgeneratorone->headthis();
It generates a footer of the amp site.
- $param param FooterModel $param (FooterModel)
$tmp=$ampgeneratorone->sectionFooterthis();
Generates a Google Analytics section
- $account UA-XXXXX-Y (string)
HeaderModel());
$tmp=$ampgeneratorone->sectionAnalyticsthis();
It draw a first section (hero style)
- $content param SectionModel $content (SectionModel)
$tmp=$ampgeneratorone->sectionFirstthis();
It generates a section with a single button.
- $content param SectionModel $content (SectionModel)
- $fullscreen param bool $fullscreen (bool)
$tmp=$ampgeneratorone->sectionImageButtonthis();
It generates a section with a text.
- $content param SectionModel $content (SectionModel)
$tmp=$ampgeneratorone->sectionTextthis();
It generates a quote text
- $content param SectionModel $content (SectionModel)
$tmp=$ampgeneratorone->sectionTextQuotethis();
It generates an unsorted list section
- $links param LinkModel[] $links (LinkModel[])
$tmp=$ampgeneratorone->sectionULthis();
It generates a sorted list section
- $links param LinkModel[] $links (LinkModel[])
$tmp=$ampgeneratorone->sectionOLthis();
It generates a section with one (or more than one) buttons.
- $content param SectionModel $content (SectionModel)
$tmp=$ampgeneratorone->sectionButtonsthis();
It generates a section with columns
- $contents param SectionModel[] $contents (SectionModel[])
$tmp=$ampgeneratorone->sectionColsthis();
It generates a header central section. It could includes buttons.
- $content param SectionModel $content (SectionModel)
$tmp=$ampgeneratorone->sectionHeaderCentralthis();
It generates a section with an image content.
- $content param SectionModel $content (SectionModel)
- $width param $width ()
- $height param $height ()
$tmp=$ampgeneratorone->sectionImageContentthis();
It generates a section with a image content at the left.
- $content param SectionModel $content (SectionModel)
- $width param $width ()
- $height param $height ()
$tmp=$ampgeneratorone->sectionImageContentLeftthis();
It generates a table
- $cols param array $cols (array)
$tmp=$ampgeneratorone->sectionTablethis();
It generates an image. The size of the image is required to calculate the ratio
- $content param SectionModel $content (SectionModel)
- $width param int $width (int)
- $height param int $height (int)
$tmp=$ampgeneratorone->sectionImagethis();
It generates a google map section. It can't be locate at the 30% top of the site (Amp restriction)
- $content param SectionModel $content (SectionModel)
- $googleMapUrl param string $googleMapUrl (string)
- $placeholder param string $placeholder (string)
$tmp=$ampgeneratorone->sectionGMapFullthis();
It generates a google map (boxed) section. It can't be locate at the 30% top of the site (Amp restriction)
- $content param SectionModel $content (SectionModel)
- $googleMapUrl param string $googleMapUrl (string)
$tmp=$ampgeneratorone->sectionGMapBoxedthis();
It generates a footer navigation
- $content param SectionModel $content (SectionModel)
- $image param string $image (string)
- $width param int $width (int)
- $height param int $height (int)
- $navCol1 param LinkModel[] $navCol1 (LinkModel[])
- $navCol2 param LinkModel[] $navCol2 (LinkModel[])
- $navCol3 param LinkModel[] $navCol3 (LinkModel[])
- $navCol4 param LinkModel[] $navCol4 (LinkModel[])
$tmp=$ampgeneratorone->sectionNavigationthis();
It generates a section with images and text.
- $contents param SectionModel[] $contents (SectionModel[])
- $width param int $width (int)
- $height param int $height (int)
- $maxCol param int $maxCol (int)
$tmp=$ampgeneratorone->sectionColImagethis();
Fluent operation, it changes the background color of the next section
- $color Example #ffffff,rgb(30,30,30),white (string)
$tmp=$ampgeneratorone->setBackgroundColorthis();
Fluent operation, it changes the background image of the next section
- $bgImage param string $bgImage (string)
$tmp=$ampgeneratorone->setBgImagethis();
Fluent operation, it sets the class of the text
- $class text-primary,text-secondary,text-success,text-info,text-warning,text-danger,text-white,text-black (string)
$tmp=$ampgeneratorone->setClassTextColorthis();
Fluent operation, it changes the padding
- $top param $top ()
- $bottom param $bottom ()
$tmp=$ampgeneratorone->setPaddingthis();
It reset to the default background color and text class
- $backGroundColor Example #ffffff,rgb(30,30,30),white (string)
- $classTextColor text-primary,text-secondary,text-success,text-info,text-warning,text-danger,text-white,text-black (string)
It renders the result page.
It renders the result to file
- $filename param string $filename (string)
Generate the first link of an array only if array constains information or the link is not empty.
- $url param LinkModel|LinkModel[] $url (LinkModel|LinkModel[])
$tmp=$ampgeneratorone->genLinkthis();
Generate the first link of an array only if array constains information or the link is not empty.
- $url param ButtonModel|ButtonModel[] $url (ButtonModel|ButtonModel[])
Note: You could change the color. !
You could validate your amp on Google search validation
- 1.5 2019-08-31 Removed min-width in the sections.
- 1.4 2019-06-04 Some fixes.
- 1.3 2018-11-03 Added Phpunit and travis.
- 1.1 2018-09-20 Fixed some bugs.
- 1.0 2018-09-08 First non beta version
- 0.3 2018-09-07 Cleaning the house.
- 0.2 2018-09-06 Working version.
- 0.1 2018-08-20 First prototype