Download the PHP package bnomei/kirby3-boost without Composer

On this page you can find all versions of the php package bnomei/kirby3-boost. 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 kirby3-boost

:rocket: Kirby3 Boost
⏱️ up to 3x faster content loading
🎣 fastest page lookup and resolution of relations

Release Downloads Build Status Maintainability Twitter

Boost the speed of Kirby by having content files of files/pages/users cached, with fast lookup based on uuid.

Commercial Usage


Support open source!

This plugin is free but if you use it in a commercial project please consider to sponsor me or make a donation.
If my work helped you to make some cash it seems fair to me that I might get a little reward as well, right?

Be kind. Share a little. Thanks.

‐ Bruno
 

M O N E Y
Github sponsor Patreon Buy Me a Coffee Paypal dontation Hire me

Installation

Usecase

If you have to process within a single request a lot of page objects (1000+) or if you have a lot of relations between page objects to resolve then consider using this plugin. With less page objects you will probably not gain enough to justify the overhead.

How does this plugin work?

Setup

For each template you want to be cached you need to use a model to add the content cache logic using a trait.

site/models/default.php

Since in most cases you will be using Kirbys autoloading for the pagemodels your classname needs to end in Page. Like site/models/article.php and ArticlePage or site/models/blogpost.php and BlogpostPage.

As a last step fill the boost cache in calling the following in a template or controller. You only have to do this once (not on every request).

Congratulations! Now your project is boosted.

User Models

Starting with version 1.9 you can also cache the content files of user models using the respective traits/extends in your custom models via a custom plugin.

File Models

Starting with version 2.0 the plugin to monkey patch the core Files class with content cache support. You can only turn this on or off for all files at once since Kirby does not allow custom File models. It would need to read content file first which would defeat the purpose for a content cache anyway.

site/config/config.php

Directories Inventory Cache (experimental)

Starting with version 5.0 the plugin will cache the inventory of directories. For that to be possible it will patch the Kirby\Filesystem\Dir class. It will automatically flush the cache if you edit pages in the panel, just like the core pages cache. It's enabled by default but you can disable it if you want to like the following.

index.php

You could also flush the cache manually.

Pages Field Alternative

This plugin provided a pages field alternative based on the multiselect field and optimized for performance.

site/blueprints/pages/default.yml

You can create your own fields for related pages based on the fields and collections this plugins provides.

Easier loading of custom models, blueprints, ...

When you use boost your project you might end up with a couple of custom models in a plugin. You can use my autoloader helper to make registering these classes a bit easier. It can also load blueprints, classes, collections, controllers, blockModels, pageModels, routes, api/routes, userModels, snippets, templates and translation files. If you installed the Boost plugin via composer the autoloader helper was installed as a dependency, and you can start using it straight way.

Usage

Page from PageId

Page from DirUri

Page from uuid

Pages from uuids

File from uuid

Resolving relations

Fields where defined in the example blueprint above.

Modified timestamp from cache

This will try to get the modified timestamp from cache. If the page object content can be cached but currently was not, it will force a content cache write. It will return the modified timestamp of a page object or if it does not exist it will return null.

Search for Template from cache

It will return a collection page object(s) and you can expect this to be a lot faster than calling site()->index()->template('myTemplateName')

Caches and Cache Drivers

A cache driver is a piece of code that defines where get/set commands for the key/value store of the cache are directed to. Kirby has built in support for File, Apcu, Memcached and Memory. I have created additional cache drivers for MySQL, Redis, SQLite and PHP.

Within Kirby caches can be used for:

To optimize performance it would make sense to use the same cache driver for all but the Pages Cache. The Pages Cache is better of in a file cache than anywhere else.

TL;DR

If you have APCu cache available and your content fits into the defined memory limit use the apcu cache driver.

Debug = read from content file (not from cache)

If you set Kirbys global debug option to true the plugin will not read the content cache but from the content file on disk. But it will write to the content cache so you can get debug messages if anything goes wrong with that process.

Forcing a content cache update

You can force writing outdated values to the cache manually but doing that should not be necessary.

Limitations

How much and if you gain anything regarding performance depends on the hardware. All your content files must fit within the memory limitation. If you run into errors consider increasing the server settings or choose a different cache driver.

Defaults for Memcached APCu Redis MySQL SQLite
max memory size 64MB 32MB 0 (none) 0 (none) 0 (none)
size of key/value pair 1MB 4MB 512MB 0 (none) 0 (none)

Benchmark

The included benchmark can help you make an educated guess which is the faster cache driver. The only way to make sure is measuring in production. Be aware that this will create and remove 1000 items cached. The benchmark will try to perform as many get operations within given timeframe (default 1 second per cache). The higher results are better.

But do not take my word for it. Download the plugin, set realistic benchmark options and run the benchmark on your production server.

Config

Once you know which driver you want to use you can set the plugin cache options.

site/config/config.php

Verify with Boostmark

First make sure all boosted pages are up-to-date in cache. Run this in a template or controller once. This will also add an unique id to boosted pages that do not have one yet (reindexing).

Then comment out the forced cache update and run the benchmark that tracks how many and how fast your content is loaded.

If you are interested in how fast a certain pages collection loads you can do that as well.

Site Index with lower memory footprint

Using site()->index() in Kirby will load all Pages into memory at the same time. This plugin provides a way to iterate over the index with having only one page loaded at a time.

Settings

bnomei.boost. Default Description
hashalgo xxh3,crc32 used hash algorithm php8.1+/php8.0
expire 0 expire in minutes for all caches created
read true read from cache
write true write to cache
drafts true index drafts
patch.files true monkey patch Files Class to do content caching
fileModifiedCheck false expects file to not be altered outside of kirby
helper true allow usage of boost() helper

External changes to content files

If your content file are written to by any other means than using Kirbys page object methods you need to enable the bnomei.boost.fileModifiedCheck option or overwrite the checkModifiedTimestampForContentBoost(): bool method on a model basis. This will reduce performance by about 1/3 but still be faster than without using a cache at all.

Disclaimer

This plugin is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please create a new issue.

License

MIT

It is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.


All versions of kirby3-boost with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2.0
getkirby/composer-installer 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 bnomei/kirby3-boost contains the following files

Loading the files please wait ....