DownloadAMPGeneratorOne
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:
How it works?
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
.jpg)
Mobile version (slider open)
Method __construct
AmpGeneratorOne constructor.
Parameters:
-
$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)
## Method fixRelativeUrl
Fix an url and convert a relative url into an absolute url
Parameters:
Parameters:
Parameters:
-
$param param HeaderModel $param (HeaderModel)
-
$structured param StructureModel $structured (StructureModel)
## Method sidebar
Generates a sidebar.
Parameters:
Parameters:
Parameters:
Parameters:
Parameters:
Parameters:
Parameters:
Parameters:
Parameters:
Parameters:
Parameters:
Parameters:
Parameters:
Parameters:
Method sectionImageContent
It generates a section with an image content.
Parameters:
Parameters:
Parameters:
Parameters:
Parameters:
Parameters:
Parameters:
Parameters:
Parameters:
Method setBackgroundColor
Fluent operation, it changes the background color of the next section
Parameters:
-
$color Example #ffffff,rgb(30,30,30),white (string)
$tmp=$ampgeneratorone->setBackgroundColorthis();
## Method setBgImage
Fluent operation, it changes the background image of the next section
Parameters:
Parameters:
-
$class text-primary,text-secondary,text-success,text-info,text-warning,text-danger,text-white,text-black (string)
$tmp=$ampgeneratorone->setClassTextColorthis();
## Method setPadding
Fluent operation, it changes the padding
Parameters:
Parameters:
Method setDefault
It reset to the default background color and text class
Parameters:
-
$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)
## Method image
Parameters:
Method table
Parameters:
Method render
It renders the result page.
Parameters:
Method renderToFile
It renders the result to file
Parameters:
-
$filename param string $filename (string)
## Method genLink
Generate the first link of an array only if array constains information or the link is not empty.
Parameters:
Parameters:
-
$url param ButtonModel|ButtonModel[] $url (ButtonModel|ButtonModel[])
> Note: You could change the color. !
Validity
You could validate your amp on Google search validation
Version
-
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
Example demo:
See end result
|