dev-master
9999999-devA PHP library for building web application manifests
MIT
The Requires
- php >=7.0
The Development Requires
- phpunit/phpunit ^7.1
- mikey179/vfsstream ^1.6
by Lukas White
Wallogit.com
2017 © Pedro Peláez
A PHP library for building web application manifests
A simple PHP library for programmatically generating Web App Manifests., (*1)
$manifest = new Manifest( );
$manifest->name( 'My Awesome App' )
->shortName( 'AwesomeApp' )
->description( 'Just testing' );
print $manifest->toJson( );
// or
$manifest->save( 'public/manifest.json' );
Route::get( 'manifest.json', function( ) {
$manifest = new Manifest( );
$manifest->name( Config::get( 'app.name' ) )
->description( trans( 'site.meta.description' ) );
return response( )->json( $manifest );
} );
Here's an example taken from the Mozilla documentation on web app manifests:, (*2)
{
"name": "HackerWeb",
"short_name": "HackerWeb",
"start_url": ".",
"display": "standalone",
"background_color": "#fff",
"description": "A simply readable Hacker News app.",
"icons": [{
"src": "images/touch/homescreen48.png",
"sizes": "48x48",
"type": "image/png"
}, {
"src": "images/touch/homescreen72.png",
"sizes": "72x72",
"type": "image/png"
}, {
"src": "images/touch/homescreen96.png",
"sizes": "96x96",
"type": "image/png"
}, {
"src": "images/touch/homescreen144.png",
"sizes": "144x144",
"type": "image/png"
}, {
"src": "images/touch/homescreen168.png",
"sizes": "168x168",
"type": "image/png"
}, {
"src": "images/touch/homescreen192.png",
"sizes": "192x192",
"type": "image/png"
}],
"related_applications": [{
"platform": "play",
"url": "https://play.google.com/store/apps/details?id=cheeaun.hackerweb"
}]
}
And here is how to build that using this library:, (*3)
$manifest = new Manifest( );
$manifest
->name( 'HackerWeb' )
->shortName( 'HackerWeb' )
->description( 'A simply readable Hacker News app.' )
->startUrl( '.' )
->standalone( )
->backgroundColor( '#fff' )
->icons(
[
new Icon( 'images/touch/homescreen48.png', 48, 'image/png' ),
new Icon( 'images/touch/homescreen72.png', 72, 'image/png' ),
new Icon( 'images/touch/homescreen96.png', 96, 'image/png' ),
new Icon( 'images/touch/homescreen144.png', 144, 'image/png' ),
new Icon( 'images/touch/homescreen168.png', 168, 'image/png' ),
new Icon( 'images/touch/homescreen192.png', 192, 'image/png' ),
]
)
->addRelatedApplication(
new RelatedApplication(
'play',
'https://play.google.com/store/apps/details?id=cheeaun.hackerweb'
)
);
I created this because I was a developing an application designed to be deployed multiple times with different configurations; things like the application name would be different across multiple installations, so it made sense to be able to control the contents of the manifest from the codebase., (*4)
Suppose you're building a CMS-driven application; chances are anything from the metadata (the name and description as it appears when adding an app to a homescreen) to the colour-scheme are probably database-driven; this allows you to do just that., (*5)
There are a number of other reasons you might want to use this approach:, (*6)
More documentation to follow, (*7)
A PHP library for building web application manifests
MIT