1. Go to this page and download the library: Download germania-kg/favicons library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
germania-kg / favicons example snippets
// 1. Setup Twig Filesystem Loader, add Favicons' template dir as well
$loader = new Twig_Loader_Filesystem( [
'path/to/your/templates',
'vendor/germania-kg/favicons/templates'
]);
// 2. Setup Twig, pass loader
$twig = new Twig_Environment($loader, array(
// other Twig settings
));
$favicons = new Germania\Favicons\Favicons;
echo $favicons->getTemplatesPath();
// Usually outputs something like
// "vendor/germania-kg/favicons/templates"
use Germania\Favicons\SlimRouter;
use Slim\App;
use Twig_Environment;
// Have your Slim v3 app and Twig ready
$app = new App;
$twig = new Twig_Environment( ... );
// Setup favicon data
$favicon_data = [
'app_name' => 'My App',
'app_url' => '/app',
'base_url' => '/path/to/icons',
'theme_color' => '#ffffff',
'icon_color' => '#e21e79'
'display' => 'minimal-ui',
// This is optional
'cache_bust' => '134p38rfwef'
];
// Setup routes
new SlimRouter( $app, $twig, $favicon_data);
// Have your Slim app, Twig and favicon data ready
$favicon_data = [ ... ];
$app->get('/browserconfig.xml', function (Request $request, Response $response) use ($twig, $favicon_data) {
$output = $twig->render('favicons.browserconfig.xml.tpl', $favicon_data);
$newResponse = $response->withHeader('Content-type', 'application/xml');
$newResponse->getBody()->write($output);
return $newResponse;
});
$app->get('/manifest.json', function (Request $request, Response $response) use ($twig, $favicon_data) {
$output = $twig->render('favicons.manifest.json.tpl', $favicon_data);
$newResponse = $response->withHeader('Content-type', 'application/manifest+json');
$newResponse->getBody()->write($output);
return $newResponse;
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.