PHP Classes
elePHPant
Icontem

PHP AMP Page Generator: Generate HTML for using as Google AMP site

Recommend this page to a friend!
  Info   View files Example   View files View files (24)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2018-09-08 (2 months ago) RSS 2.0 feedNot enough user ratingsTotal: 166 All time: 8,462 This week: 370Up
Version License PHP version Categories
ampgeneratorone 1.0.0GNU Lesser Genera...5HTTP, PHP 5, Performance and optimiza...
Description Author

This package can generate HTML for using as Google AMP site.

It provides several classes that abstract the different types of HTML elements that are usually present in a Web page.

The package can compose the output of the whole page from the output of the objects for each page element and returns the page output as a string or saves it to a given file.

Innovation Award
PHP Programming Innovation award nominee
September 2018
Number 9
AMP (Accelerated Mobile Pages) is a form of delivering Web site pages in a way that is more efficient and pages can be loaded by browsers quicker.

This package can help composing and serving the Web site pages in PHP using the rules of AMP.

Manuel Lemos
  Performance   Level  
Name: Jorge Castro <contact>
Classes: 6 packages by
Country: Chile Chile
Age: 42
All time rank: 260910 in Chile Chile
Week rank: 41 Up1 in Chile Chile Up
Innovation award
Innovation award
Nominee: 4x

Winner: 1x

Details

AMPGeneratorOne

It generates Google AMP sites using PHP

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:

simple section

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.

result

Tablet version

result

Mobile version

result.jpg)

Mobile version (slider open)

> Note: You could change the color. !

Validity

You could validate your amp on Google search validation

Google Amp Validation

Version

  • 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

Full Project

  Files folder image Files  
File Role Description
Files folder imagedoc (6 files)
Files folder imageexample (4 files, 1 directory)
Files folder imagelib (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  doc  
File Role Description
  Accessible without login Image file example1-sm.jpg Icon Icon image
  Accessible without login Image file example1-sm.png Data Auxiliary data
  Accessible without login Image file example1.jpg Data Auxiliary data
  Accessible without login Image file example1.png Data Auxiliary data
  Accessible without login Image file simplesection.jpg Data Auxiliary data
  Accessible without login Image file validate.jpg Data Auxiliary data

  Files folder image Files  /  example  
File Role Description
Files folder imageresources (10 files)
  Accessible without login Plain text file example-generated.html Output Documentation
  Accessible without login Plain text file index-amp.php Example Example script
  Accessible without login Plain text file smallexample-amp.php Example Example script
  Accessible without login HTML file smallexample-generated.html Doc. Documentation

  Files folder image Files  /  example  /  resources  
File Role Description
  Accessible without login Image file accessory-analog-classic-84475.jpg Data Auxiliary data
  Accessible without login Image file banner_2250x441.jpg Data Auxiliary data
  Accessible without login Image file cupcake_square.jpg Data Auxiliary data
  Accessible without login Image file favicon.ico Data Auxiliary data
  Accessible without login Image file logo.jpg Data Auxiliary data
  Accessible without login Image file pexels-photo-1028704.jpeg Data Auxiliary data
  Accessible without login Image file pexels-photo-1073767.jpeg Data Auxiliary data
  Accessible without login Image file pexels-photo-1073772.jpeg Data Auxiliary data
  Accessible without login Image file pexels-photo-532126.jpeg Data Auxiliary data
  Accessible without login Image file pexels-photo-635409.jpeg Data Auxiliary data

  Files folder image Files  /  lib  
File Role Description
  Plain text file AmpGeneratorOne.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:166
This week:0
All time:8,462
This week:370Up