PHPackages                             eftec/amp-generator-one - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. eftec/amp-generator-one

ActiveLibrary[Templating &amp; Views](/categories/templating)

eftec/amp-generator-one
=======================

It generates Google AMP sites using PHP

1.5(6y ago)175.8k8LGPL-3.0-onlyPHP

Since Sep 8Pushed 6y ago5 watchersCompare

[ Source](https://github.com/EFTEC/AMPGeneratorOne)[ Packagist](https://packagist.org/packages/eftec/amp-generator-one)[ RSS](/packages/eftec-amp-generator-one/feed)WikiDiscussions master Synced today

READMEChangelog (5)Dependencies (1)Versions (6)Used By (0)

AMPGeneratorOne
===============

[](#ampgeneratorone)

The library generates Google AMP sites using PHP by using procedural code.

[![Build Status](https://camo.githubusercontent.com/e8bf0f8b089894b4e72f07abded7ba10dccbe413e13ccc9c3888324cf0955b4f/68747470733a2f2f6170692e7472617669732d63692e6f72672f45465445432f414d5047656e657261746f724f6e652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/EFTEC/AMPGeneratorOne)[![Packagist](https://camo.githubusercontent.com/6bc4dafd3ad4d3e5416390ca5d0b1571034ef21e404804f06bc7119ac256cebf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f65667465632f616d702d67656e657261746f722d6f6e652e737667)](https://packagist.org/packages/eftec/amp-generator-one)[![Total Downloads](https://camo.githubusercontent.com/ec0f8b8b7a7db32bd4257251f7460a26c52ee12aaa6edee1c0a09e9f9d6f96ea/68747470733a2f2f706f7365722e707567782e6f72672f65667465632f616d702d67656e657261746f722d6f6e652f646f776e6c6f616473)](https://packagist.org/packages/eftec/amp-generator-one)![Maintenance](https://camo.githubusercontent.com/107cdbc6a67ec677b7459f72c05d13f2de1ea897382420addec98c9d70988496/68747470733a2f2f696d672e736869656c64732e696f2f6d61696e74656e616e63652f7965732f323031392e737667)![composer](https://camo.githubusercontent.com/fa7721827f4123ffceb42269b28f0af36ac2dcfab355a02ead8037f58d84dba5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6d706f7365722d253345312e382d626c75652e737667)![php](https://camo.githubusercontent.com/62fb387978945851f2340aa880bfc2a4164d74b4efcdf06b40833d91998dd145/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345352e362d677265656e2e737667)![php](https://camo.githubusercontent.com/0d20998129714e2662748003f3e0fab165e7f10d9dd4eb097376217b12c07b15/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d372e782d677265656e2e737667)![CocoaPods](https://camo.githubusercontent.com/347353606ed8f26b45bcf9da083db0063fa1dadd1baef36a5f3bf9ce1d127548/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f63732d37302532352d79656c6c6f772e737667)

- [AMPGeneratorOne](#ampgeneratorone)
    - [How it works?](#how-it-works-)
    - [Validity](#validity)
    - [Version](#version)
    - [Example demo:](#example-demo-)

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](doc/simplesection.jpg)](doc/simplesection.jpg)

How it works?
-------------

[](#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](doc/example1.jpg)](doc/example1.jpg)

Tablet version

[![result](doc/example1-sm.jpg)](doc/example1-sm.jpg)

Mobile version

[![result](doc/example1-sm(open).jpg)](doc/example1-sm(open).jpg)

Mobile version (slider open)

Method \_\_construct
--------------------

[](#method-__construct)

AmpGeneratorOne constructor.

### Parameters:

[](#parameters)

- **$canonical** Original url . Example  (string)
- **$base** Original base url without trailing slash. Example  (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
---------------------

[](#method-fixrelativeurl)

Fix an url and convert a relative url into an absolute url

### Parameters:

[](#parameters-1)

- **$url** param $url ()

```
$tmp=$ampgeneratorone->fixRelativeUrlthis();
```

Method genStructured
--------------------

[](#method-genstructured)

It generates the social and seo structure (Twitter card, Facebook OG and Google Schema)

### Parameters:

[](#parameters-2)

- **$structured** param StructureModel $structured (StructureModel)

```
$tmp=$ampgeneratorone->genStructuredthis();
```

Method startAmp
---------------

[](#method-startamp)

Start to generate an Amp site.

### Parameters:

[](#parameters-3)

- **$param** param HeaderModel $param (HeaderModel)
- **$structured** param StructureModel $structured (StructureModel)

Method sidebar
--------------

[](#method-sidebar)

Generates a sidebar.

### Parameters:

[](#parameters-4)

- **$urls** param LinkModel\[\] $urls (LinkModel\[\])

```
$tmp=$ampgeneratorone->sidebarthis();
```

Method head
-----------

[](#method-head)

Generates the header navigation

### Parameters:

[](#parameters-5)

- **$param** param HeadModel $param (HeadModel)
- **$width** param int $width (int)
- **$height** param int $height (int)

```
$tmp=$ampgeneratorone->headthis();
```

Method sectionFooter
--------------------

[](#method-sectionfooter)

It generates a footer of the amp site.

### Parameters:

[](#parameters-6)

- **$param** param FooterModel $param (FooterModel)

```
$tmp=$ampgeneratorone->sectionFooterthis();
```

Method sectionAnalytics
-----------------------

[](#method-sectionanalytics)

Generates a Google Analytics section

### Parameters:

[](#parameters-7)

- **$account** UA-XXXXX-Y (string)

```
HeaderModel());
```

```
$tmp=$ampgeneratorone->sectionAnalyticsthis();
```

Method sectionFirst
-------------------

[](#method-sectionfirst)

It draw a first section (hero style)

### Parameters:

[](#parameters-8)

- **$content** param SectionModel $content (SectionModel)

```
$tmp=$ampgeneratorone->sectionFirstthis();
```

Method sectionImageButton
-------------------------

[](#method-sectionimagebutton)

It generates a section with a single button.

### Parameters:

[](#parameters-9)

- **$content** param SectionModel $content (SectionModel)
- **$fullscreen** param bool $fullscreen (bool)

```
$tmp=$ampgeneratorone->sectionImageButtonthis();
```

Method sectionText
------------------

[](#method-sectiontext)

It generates a section with a text.

### Parameters:

[](#parameters-10)

- **$content** param SectionModel $content (SectionModel)

```
$tmp=$ampgeneratorone->sectionTextthis();
```

Method sectionTextQuote
-----------------------

[](#method-sectiontextquote)

It generates a quote text

### Parameters:

[](#parameters-11)

- **$content** param SectionModel $content (SectionModel)

```
$tmp=$ampgeneratorone->sectionTextQuotethis();
```

Method sectionUL
----------------

[](#method-sectionul)

It generates an unsorted list section

### Parameters:

[](#parameters-12)

- **$links** param LinkModel\[\] $links (LinkModel\[\])

```
$tmp=$ampgeneratorone->sectionULthis();
```

Method sectionOL
----------------

[](#method-sectionol)

It generates a sorted list section

### Parameters:

[](#parameters-13)

- **$links** param LinkModel\[\] $links (LinkModel\[\])

```
$tmp=$ampgeneratorone->sectionOLthis();
```

Method sectionButtons
---------------------

[](#method-sectionbuttons)

It generates a section with one (or more than one) buttons.

### Parameters:

[](#parameters-14)

- **$content** param SectionModel $content (SectionModel)

```
$tmp=$ampgeneratorone->sectionButtonsthis();
```

Method sectionCols
------------------

[](#method-sectioncols)

It generates a section with columns

### Parameters:

[](#parameters-15)

- **$contents** param SectionModel\[\] $contents (SectionModel\[\])

```
$tmp=$ampgeneratorone->sectionColsthis();
```

Method sectionHeaderCentral
---------------------------

[](#method-sectionheadercentral)

It generates a header central section. It could includes buttons.

### Parameters:

[](#parameters-16)

- **$content** param SectionModel $content (SectionModel)

```
$tmp=$ampgeneratorone->sectionHeaderCentralthis();
```

Method sectionRaw
-----------------

[](#method-sectionraw)

### Parameters:

[](#parameters-17)

Method sectionImageContent
--------------------------

[](#method-sectionimagecontent)

It generates a section with an image content.

### Parameters:

[](#parameters-18)

- **$content** param SectionModel $content (SectionModel)
- **$width** param $width ()
- **$height** param $height ()

```
$tmp=$ampgeneratorone->sectionImageContentthis();
```

Method sectionImageContentLeft
------------------------------

[](#method-sectionimagecontentleft)

It generates a section with a image content at the left.

### Parameters:

[](#parameters-19)

- **$content** param SectionModel $content (SectionModel)
- **$width** param $width ()
- **$height** param $height ()

```
$tmp=$ampgeneratorone->sectionImageContentLeftthis();
```

Method sectionTable
-------------------

[](#method-sectiontable)

It generates a table

### Parameters:

[](#parameters-20)

- **$cols** param array $cols (array)

```
$tmp=$ampgeneratorone->sectionTablethis();
```

Method sectionImage
-------------------

[](#method-sectionimage)

It generates an image. The size of the image is required to calculate the ratio

### Parameters:

[](#parameters-21)

- **$content** param SectionModel $content (SectionModel)
- **$width** param int $width (int)
- **$height** param int $height (int)

```
$tmp=$ampgeneratorone->sectionImagethis();
```

Method sectionGMapFull
----------------------

[](#method-sectiongmapfull)

It generates a google map section. It can't be locate at the 30% top of the site (Amp restriction)

### Parameters:

[](#parameters-22)

- **$content** param SectionModel $content (SectionModel)
- **$googleMapUrl** param string $googleMapUrl (string)
- **$placeholder** param string $placeholder (string)

```
$tmp=$ampgeneratorone->sectionGMapFullthis();
```

Method sectionGMapBoxed
-----------------------

[](#method-sectiongmapboxed)

It generates a google map (boxed) section. It can't be locate at the 30% top of the site (Amp restriction)

### Parameters:

[](#parameters-23)

- **$content** param SectionModel $content (SectionModel)
- **$googleMapUrl** param string $googleMapUrl (string)

```
$tmp=$ampgeneratorone->sectionGMapBoxedthis();
```

Method sectionNavigation
------------------------

[](#method-sectionnavigation)

It generates a footer navigation

### Parameters:

[](#parameters-24)

- **$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();
```

Method sectionColImage
----------------------

[](#method-sectioncolimage)

It generates a section with images and text.

### Parameters:

[](#parameters-25)

- **$contents** param SectionModel\[\] $contents (SectionModel\[\])
- **$width** param int $width (int)
- **$height** param int $height (int)
- **$maxCol** param int $maxCol (int)

```
$tmp=$ampgeneratorone->sectionColImagethis();
```

Method genModifyStyle
---------------------

[](#method-genmodifystyle)

### Parameters:

[](#parameters-26)

Method setBackgroundColor
-------------------------

[](#method-setbackgroundcolor)

Fluent operation, it changes the background color of the next section

### Parameters:

[](#parameters-27)

- **$color** Example #ffffff,rgb(30,30,30),white (string)

```
$tmp=$ampgeneratorone->setBackgroundColorthis();
```

Method setBgImage
-----------------

[](#method-setbgimage)

Fluent operation, it changes the background image of the next section

### Parameters:

[](#parameters-28)

- **$bgImage** param string $bgImage (string)

```
$tmp=$ampgeneratorone->setBgImagethis();
```

Method setClassTextColor
------------------------

[](#method-setclasstextcolor)

Fluent operation, it sets the class of the text

### Parameters:

[](#parameters-29)

- **$class** text-primary,text-secondary,text-success,text-info,text-warning,text-danger,text-white,text-black (string)

```
$tmp=$ampgeneratorone->setClassTextColorthis();
```

Method setPadding
-----------------

[](#method-setpadding)

Fluent operation, it changes the padding

### Parameters:

[](#parameters-30)

- **$top** param $top ()
- **$bottom** param $bottom ()

```
$tmp=$ampgeneratorone->setPaddingthis();
```

Method resetDefault
-------------------

[](#method-resetdefault)

### Parameters:

[](#parameters-31)

Method setDefault
-----------------

[](#method-setdefault)

It reset to the default background color and text class

### Parameters:

[](#parameters-32)

- **$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
------------

[](#method-image)

### Parameters:

[](#parameters-33)

Method table
------------

[](#method-table)

### Parameters:

[](#parameters-34)

Method render
-------------

[](#method-render)

It renders the result page.

### Parameters:

[](#parameters-35)

Method renderToFile
-------------------

[](#method-rendertofile)

It renders the result to file

### Parameters:

[](#parameters-36)

- **$filename** param string $filename (string)

Method genLink
--------------

[](#method-genlink)

Generate the first link of an array only if array constains information or the link is not empty.

### Parameters:

[](#parameters-37)

- **$url** param LinkModel|LinkModel\[\] $url (LinkModel|LinkModel\[\])

```
$tmp=$ampgeneratorone->genLinkthis();
```

Method genButton
----------------

[](#method-genbutton)

Generate the first link of an array only if array constains information or the link is not empty.

### Parameters:

[](#parameters-38)

- **$url** param ButtonModel|ButtonModel\[\] $url (ButtonModel|ButtonModel\[\])

> Note: You could change the color. **!**

Validity
--------

[](#validity)

You could validate your amp on [Google search validation](https://search.google.com/test/amp)

[![Google Amp Validation](doc/validate.jpg)](doc/validate.jpg)

Version
-------

[](#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:
-------------

[](#example-demo)

[See end result](http://htmlpreview.github.io/?https://raw.githubusercontent.com/EFTEC/AMPGeneratorOne/master/example/example-generated.html)

[![Full Project](doc/fullproject.png)](doc/fullproject.png)

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~89 days

Total

5

Last Release

2497d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8bf6ba9d7f6f6c3ecde2779a29e1a4948f0f338c074ddceb3fbeb79c6dd1e68c?d=identicon)[JorgeCastro](/maintainers/JorgeCastro)

---

Top Contributors

[![jorgecc](https://avatars.githubusercontent.com/u/9570242?v=4)](https://github.com/jorgecc "jorgecc (20 commits)")

---

Tags

ampamp-htmlphp7seo-optimizationtemplate

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/eftec-amp-generator-one/health.svg)

```
[![Health](https://phpackages.com/badges/eftec-amp-generator-one/health.svg)](https://phpackages.com/packages/eftec-amp-generator-one)
```

###  Alternatives

[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3851.2M](/packages/limenius-react-bundle)[area17/laravel-auto-head-tags

Laravel Auto Head Tags helps you build the list of head elements for your app

4616.1k](/packages/area17-laravel-auto-head-tags)[jelix/wikirenderer

WikiRenderer is a library to generate HTML or anything else from wiki content.

1712.3k1](/packages/jelix-wikirenderer)[webkinder/sproutset

A Composer package for handling responsive images in Roots Bedrock + Sage + Blade projects.

282.2k](/packages/webkinder-sproutset)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
