Download the PHP package tsekka/prerender without Composer

On this page you can find all versions of the php package tsekka/prerender. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package prerender

Prerender & cache your SPA pages for crawlers on Laravel

Latest Version on Packagist Total Downloads

This package intends to make it easier to serve prerendered pages to crawlers for better SEO.

You could make use of it if

It could be used as a

Installation

Via Composer

Preparing the database

The package loads migrations

Publishing the config file

Publishing the config file is optional.

Registering prerender middleware

Enable prerendering for all routes by adding PRERENDER_REGISTER_GLOBALLY=true in your .env file; or add middleware to specific routes:

Prerendering by third party service

By using prerender.io or similar service, you don't have to install node server and headless chrome by yourself.

The primary use case of this package is to make it easier to run custom prerender server & cache it's responses. However, the easiest way to start prerendering the pages for crawlers is by using third-party service like prerender.io.

  1. Register at prerender.io or at another similar service and follow their instructions.
  2. Set prerenderer's url PRERENDER_URL=https://service.prerender.io and token PRERENDER_TOKEN=YOUR-THIRD-PARTY-TOKEN (add this in your .env file)
  3. Prerender.io already caches the pages for speed, so you can turn off local cache PRERENDER_CACHE_TTL=null (.env)
  4. Register the middleware and you're good to go!

Running your own prerender service

To run your own prerender service, you must have Node, headless Chrome and their dependencies installed in your webserver.

Prerender.io has open-sourced node server that you can use to prerender the pages at your server.

Here's how you can make use of it:

  1. Install and run prerenderer's node server.
    • Clone it from this package's directory (cp -r ./vendor/tsekka/prerender/prerenderer ./prerenderer) and install dependencies cd prerenderer && npm install.
    • You can also follow this quick tutorial which includes instructions how to install headless Chrome browser on Debian-based Linux distributions.
  2. Set prerenderer's url to url of your prerenderer's service. Eg. if you're running it locally, then add PRERENDER_URL=http://localhost:3000 to your .env file.
  3. Decide if you will keep the prerender server constantly running or if you would rather start the server for the duration of schedule command.
    • If you will keep the server constantly running, then start the prerendering server node server.js and make sure that the node server will re-start even after webserver is rebooted.
    • If you would rather start the server only for the duration of prerender command, then set PRERENDER_RUN_LOCAL_SERVER=true in your .env file.
  4. Register the middleware
  5. Prerendering the page on-demand can be slow and therefore, by default the pages will be cached.
  6. It's recommended that you set up the schedule to re-cache the prerendered pages.

Caching prerendered responses

Prerendering the page can take up to few seconds or even more.

Therefore the pages will be cached by default for 1 week.

You can change cache time-to-live and cache driver by setting .env variables PRERENDER_CACHE_TTL and PRERENDER_CACHE_DRIVER or by publishing and modifying the config file.

If you're using third-party service like Prerender.io, then the responses are probably already cached, so you can turn off local cache (add PRERENDER_CACHE_TTL=null to your .env).

Running cache command

You can run php artisan prerender:cache command to cache all pages that are defined in array of cacheable urls.

By default, the cache command only caches urls that have not been cached yet or whose cache ttl have already expired. You can run cache command with --force option (php artisan prerender:cache --force) to re-cache all urls.

Keeping prerendered pages up to date

Prerendering the page on-demand can be slow and it's therefore recommended to keep fresh copy of pages constantly in cache.

You could set up event listener to keep the prerendered page in sync
Or schedule prerendering and recaching on specified time

Providing list of urls to cache

Each time crawler visits the url that matches all requirements for it to be prerendered, the prerendered response will be cached and the url of request will be recorded in database.

So by default, before you actually start using the package, the list will be empty and the urls will be prerendered at the time of request (and therefore the request time could be quite slow, as prerendering takes time).

If you would like to cache the pages only on demand or you would like to keep response time low even on first crawler visit, then you should provide a class & method name that returns array of of urls by publishing config file and modifying it's cacheable_urls value.

Pruning old entries

The package logs all crawler visits into database.

Use php artisan prerender:prune command to clear old entries.

You can also schedule the artisan command:

Whitelisting urls

Whitelist paths or patterns. You can use asterix syntax. If a whitelist is supplied, only url's containing a whitelist path will be prerendered. An empty array means that all URIs will pass this filter. Note that this is the full request URI, so including starting slash and query parameter string.

Blacklisting urls

Blacklist paths to exclude. You can use asterix syntax. If a blacklist is supplied, all url's will be prerendered except ones containing a blacklist path. By default, a set of asset extentions are included (this is actually only necessary when you dynamically provide assets via routes). Note that this is the full request URI, so including starting slash and query parameter string.

Other resources

If you don't know why or when you should prerender your SPA apps, then there are some resources for you to check out:

Contributing

This package is under development. Contributions are appreciated and will be credited.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

MIT. Please see the license file for more information.


All versions of prerender with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
illuminate/support Version ~8|~9
guzzlehttp/guzzle Version ^7.0
symfony/psr-http-message-bridge Version ^2.0
chrome-php/chrome Version ^1.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tsekka/prerender contains the following files

Loading the files please wait ....