Download the PHP package bnomei/kirby-mongodb without Composer

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

🐎 Khulan - Kirby MongoDB

Release Downloads Coverage Maintainability Discord

Khulan is a cache driver and content cache with NoSQL interface for Kirby using MongoDB.

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

MongoDB

There are various ways to install MongoDB. This is one way to do it on localhost for Mac OSX using Homebrew and MongoDB Atlas.

Usecase

The plugin caches all content files and keeps the cache up to date when you add/remove or update content. This cache will be used when constructing page/file/user objects making everything that involves model faster (even the Panel).

It will also allow you to query the content cache directly as a NoSQL database which might be very useful for some use-cases like filtering or searching content.

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

[!NOTE] You can also use the trait for user models. File models are patched automatically.

Kirby's Content goes NoSQL

The plugin writes the content cache to a collection named khulan in the database. You can query this collection directly. It is not wrapped in an Cache object. This allows you to treat all your Kirby content as a NoSQL database.

Special Fields with [], {} and [,]

The plugin creates modified copies of a few field types to make the YAML based content from Kirby ready for queries. You can use

Example: Filtering and Resolving Relations

With Kirby's content cache as a NoSQL database you can do some advanced filtering. If you would do the same with Kirby's filtering on collection you would end up loading a lot pages and that is not as efficient. We can load the information we need directly from the cache without the need to load the full page object.

Why would we bother to read the content from a NoSQL based cache and not just put a cache around the native Kirby logic? Because the hard thing with caches is to know when to invalidate them. With the content cache we can query the NoSQL based cache directly and updating any model will be reflected instantly. Whereas with a cache around the native Kirby logic we would need rebuild the cache on every change (like with the pages cache).

Let's assume we have two models: film and actor. The film model has a field actors which is a pages field with linked actor pages. We want to list all films with their actors.

Load 1000 films and their actors, total of 6429 pages accessed in 250ms

Query the cache instead to get the same information in under 100ms

[!NOTE]

This example is from my Sakila DB kit. You can use similar queries to filter and resolve relations of files and user objects.

MongoDB Client

You can access the underlying MongoDB client directly.

Cache

You can either use the cache directly or use it as a cache driver for Kirby.

The MongoDB based cache will, compared to the default file-based cache, perform worse! This is to be expected as web-servers are optimized for handling requests to a couple of hundred files and keep them in memory.

As with regular Kirby cache you can also use the getOrSet method to wrap your time expensive code into a closure and only execute it when the cache is empty.

Using the MongoDB-based cache will allow you to perform NoSQL queries on the cache and do advanced stuff like filtering my tags or invalidating many cache entries at once.

[!NOTE]

Querying the cache directly is not recommended for regular use-cases. It will not check for the expiration of the cache entries and delete them automatically.

Using the Cache Driver in Kirby

You can also use the MongoDB-based cache as a cache driver for Kirby. This will allow you to use it for caching of other extensions in Kirby.

site/config/config.php

Settings

bnomei.mongodb. Default Description
host 127.0.0.1
port 27017
username null
password null
database kirby you can give it any name you want and MongoDB will create it for you
uriOptions []
driverOptions []
auto-clean-cache true will clean the cache once before the first get()
khulan.read false read from cache is disabled by default as loading from file might be faster
khulan.write true write to cache for all models that use the ModelWithKhulan trait
khulan.patch-files-class true monkey-patch the \Kirby\CMS\Files class to use Khulan for caching its content

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 kirby-mongodb with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2.0
getkirby/composer-installer Version ^1.2
mongodb/mongodb Version ^1.19
ext-mongodb Version *
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/kirby-mongodb contains the following files

Loading the files please wait ....