cohensive / laravel-amp
Package that helps you set up AMP (Accelerated Mobile Pages) using Laravel
Requires
- php: ^7.3|^8.0|^8.1|^8.2|^8.3
- laravel/framework: ^5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
Requires (Dev)
- phpunit/phpunit: ^8.0|^9.0|^10.0|^11.0
README
This package makes it easy to integrate AMP in your Laravel projects. By using the new Route::amp()
notation.
Installation
You can install the package via composer:
composer require cohensive/laravel-amp
Register the service provider in your app.php
// app.php 'providers' => [ ... Cohensive\Amp\AmpServiceProvider::class, ], 'aliases' => [ ... 'AmpRouter' => Cohensive\Amp\AmpRouteFacade::class, ]
And register the custom Route::amp()
notation in your RouteServiceProvider.php
.
/// app/Providers/RouteServiceProvider.php use AmpRouter; ... public function boot(Router $router) { AmpRouter::registerMacros(); parent::boot($router); }
Usage
//route.php Route::amp('url-of-my-route', ['as' => 'my-route', 'uses' => 'PageController@text']);
There well be two routes registered. One with '/url-of-my-route', and one prefixed with the config value you specify in the config file such as amp
: 'amp/url-of-my-route'.
The logic for both routes is the same, but the view that's being rendered for the amp route affixed the the config value you specify in the config file (view_affix).
In your view, include the amp::tag
file. This will match the AMP route (if exists) and put an link to the amp content in your HTML.
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.