byn9826 / fake-ssr
This package is abandoned and no longer maintained.
No replacement package was suggested.
Feed web crawlers on rendered HTML for JavaScript rendering pages
dev-master
2018-04-16 01:42 UTC
Requires
- jaybizzle/crawler-detect: ^1.2
This package is not auto-updated.
Last update: 2020-01-20 19:47:06 UTC
README
Feed web crawlers on rendered HTML for JavaScript rendering pages/Single Page Application.
Users will visit the page normally while web crawlers will directly get already rendered HTML.
Prerequisite
Install Google Chrome
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo apt-get -f install
Installation
composer require "byn9826/fake-ssr:dev-master"
Usage
In default controller default action (Handle all the traffic here).
use byn9826\FakeSSR\FakeSSR;
class IndexController extends ControllerBase {
public function indexAction() {
//$cache_folder is the location of the folder used to cache rendered HTML
//make sure www-data could execute in this folder
//$cache_folder could be null if $expire is 0
$cache_folder = dirname(__dir__) . '/.ssr';
//$expire is the cache expiring time.
//Default value is false, means never expire.
//0 means never use cache.
//1 means cache for 1 min, 10 means cache for 10 min, 100 means cache for 100 min, etc
$expire = 0;
FakeSSR::detect($cache_folder, $expire);
//Render the index.html for the single page application
include(dirname(__dir__) . '/frontend/index.html');
}
}