Download the PHP package bnomei/kirby3-janitor without Composer

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

Kirby Janitor

Kirby 5 PHP 8.2 Release Downloads Coverage Maintainability Discord Buymecoffee

Janitor is a Kirby CMS Plugin for running commands.

Install

You have to use composer to install both the plugin and the CLI locally into your project:

[!WARNING] You need to install the CLI with composer into your project and not use the global version. Since Janitor depends on the CLI to be available, installing only the janitor plugin via submodules or via ZIP is NOT supported.

Setup

CLI Command

In any blueprint create a janitor field with your command, browse to that page in panel and press the button.

site/blueprints/page/default.yml

Janitor will automatically fill in the current model.

Create a Kirby CLI command via a custom plugin or put them into site/commands.

site/commands/example.php

View Buttons

You can also use Janitor to create custom view buttons.

site/blueprints/page/default.yml

Callback

Instead of using a command you can also create a callback in a custom plugin options or any config file.

site/config/config.php

The Janitor plugin has a special command janitor:job that you can use to trigger your callback.

site/blueprints/page/default.yml

The $model will match the model of whatever page, file, user or site object you pressed the button at.

[!NOTE] Why just a single model variable instead of one each for page, file, user and site? For one reason to make it work directly with any existing version 2 callbacks you might have already created and secondly because this why it is very easy to get the model that triggered the callback.

Built in commands and examples

This plugin comes with a few commands you might like to use yourself and some example commands used to showcase the various options the button has (like how to change the icon or open a URL in a new tab). Some commands can be used in both panel and terminal. Others are limited in their use to either one of them. In the terminal you can use --help argument to view the help for each command.

The plugin will register these commands starting with janitor:* automatically - no copying required.
But if you want to re-use any of the other example provided you need to copy them to your site/commands-folder

Blueprint field options

The button you create with the field: janitor in your blueprint can be configured to do various things. Checkout the example default.yml blueprint to familiarize yourself with how to use it.

Janitor API options

In either the command or the callback you will be setting/returning data to the Janitor button via its api. Depending on what you return you can trigger various things to happen in the panel.

Examples

Again... check out the built-in commands and plugin example commands to learn how to use the field and api options yourself.

If you want you can also call any of the core shipping with the CLI like clear:cache.

Keep in mind that the Janitor panel button and webhooks will append the --quiet option on all commands automatically to silence outputs to the non-existing CLI. But if you use janitor()->command() you will have to append --quiet to your command yourself.

Running commands in your code

You can run any command in you own code as well like in a model, template, controller or hook. Since commands do not return data directly you need to retrieve data stored for Janitor using a helper janitor()->data($commandName).

Get data returned from a command

Create and download a backup

site/config/config.php

Calling a command with parameters

Supplying parameter to the core CLI functions can be a bit tricky since you need to separate argument key and argument values. It seems easy with one but gets a bit tedious with a dynamic list of parameters and if values contain space-chars or quotes. But fret not – Janitor has a helper for that as well.

Remember that using the janitor()->command($string)-helper you can call any of your own commands and the core commands as well, not just the ones defined by Janitor.

If you want to work with command strings yourself you can use the following static helper method.

Webhook with secret

You can not call Janitors api unauthenticated. You either need to use the panel button or you can set a secret in your site/config/config.php file and call the janitor api URL with that secret.

site/config/config.php

You could also use a callback if you want to store the secret in a .env file and have it loaded by my dotenv plugin.

/.env

site/config/config.php

example URL

example URL with urlencoded arguments

CRON

Webhook with wget or curl

You can also use the secret to trigger a job using wget or curl.

Are you having issues with PHP bin and cron? read this.

Kirby CLI (installed with composer)

in your cron scheduler add the following command

Maintenance Mode

You can toggle maintenance mode with a janitor button like this:

If you need to add a custom check when maintenance mode is enforced you can do this by providing a callback for the bnomei.janitor.maintenance.check option.

site/config/config.php

You can also overwrite the maintenance snippet if you create your own and store it as site/snippets/maintenance.php.

Tinker(well), REPL and Debugging

You can use the kirby janitor:tinker command to start a REPL session in the terminal. This is a great way to test code snippets, debug and explore your Kirby installation. Another alternative would be using the Tinkerwell App which has built-in support for Kirby as long as it can find the ./kirby/bootstrap.php file via the matching driver.

Dependencies

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-janitor with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
getkirby/composer-installer Version ^1.2
symfony/deprecation-contracts Version ^3.0.1
symfony/finder Version ^7.0
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-janitor contains the following files

Loading the files please wait ....