Download the PHP package beebmx/kirby-patrol without Composer

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

Kirby Patrol Logo

Build Status Total Downloads Latest Stable Version License

Kirby Patrol

An easy and customizable way to manage access to website pages according to the roles assigned to users within the Kirby panel interface.


Overview

Installation

Download

Download and copy this repository to /site/plugins/kirby-patrol.

Composer

Usage

Out of the box, you don't need to do anything to start using (except for installation), but if you require customizing the default behavior, there are some options to personalize Kirby Patrol.

Panel

All users with panel access will see the new area and will be able to update the access to the pages on the website.

If you need to restrict this behavior, you can do so by adding the permission in the user YAML file:

[!NOTE] The access is set to true by default

The pages displayed in the new panel area will be all the site childrens published (with status listed and unlisted) and two levels inside every page. If you need a specific collection of pages you can change it with the query option in your config.php file:

And if you need to update the depth of the pages displayed, update the config.php file:

Here's an example of Kirby Patrol view page:

Patrol panel example

Frontend

When a logged-in user visits any page, Kirby Patrol will automatically validate the request. If the user has access to the visited page, they can normally view the content, but if not, an error page will be thrown with a 401 status code.

[!WARNING] It's important that you use a logged-in user when the validation occurs; otherwise, an error will be thrown. If the default

Middleware

Even when Kirby Patrol tries to validate a user, it's possible that behavior won't be enough for your own validation. In that case, you can customize and add additional restrictions to every page.

The middleware process is powered by Kirby Middleware, and you can use all features if you need to.

Closure middleware

The easyest way to add additional validation is with Closures. Added this in the config.php file:

As you can see, the Closure requires two parameters: an Request called $request and a Closure called $next. The $request contains the stack of previous validations from Patrol and any other middleware triggered.

The second parameter $next, you should call it at the end of the process to proceed to the next validation with the $request.

[!NOTE] You can return a Response::class object. When you do that, Kirby Patrol will automatically send the request.

Class middleware

If your own validation is more complex for a simple Closure, you can use a custom class for that purpose:

And your class should look like:

Your middleware logic should be inside the handle method; otherwise, the middleware will never be triggered.

[!NOTE] You can throw an exception ErrorPageException::class with your custom data in case you need it.

Redirection

Sometimes you don't need an error in your website to display an error, in that cases you can make a redireccion:

As you can see, when a redirection is set, you don't need to customize an extra middleware.

Utilities

You have utilities available to incorporate into your existing workflow:

User utilities

If you want to validate if a user has access to a given Page:

[!NOTE] Page can be a string or a Kirby\Cms\Page object

If you want to retrieve all the pages with access or without access

[!NOTE] A true value returns all pages with access. A false value returns all pages without access.

Pages utility

If you want to know if a pages collection have access or not:

[!NOTE] A true value returns all pages with access. A false value returns all pages without access.

Options

Option Default Type Description
beebmx.kirby-patrol.enabled true bool Enable access in Kirby Panel
beebmx.kirby-patrol.icon keyhole string Icon displayed in Kirby Panel. Options available are: flash keyhole police shield siren star user
beebmx.kirby-patrol.name Patrol string Set a string to display in the Kirby Panel.
beebmx.kirby-patrol.content.columns 4 int Set how many columns will be displayed into the Kirby Patrol view.
beebmx.kirby-patrol.content.depth 2 int Set the depth to dig into the pages collection.
beebmx.kirby-patrol.content.direction asc string Set the sort direction of the content.
beebmx.kirby-patrol.content.sort title string Set the sort value for the content.
beebmx.kirby-patrol.content.query null ?Closure Use a specific query to display and validate by Kirby Patrol. It requires returning a collection of pages.
beebmx.kirby-patrol.permissions.default true bool Set the default values of all the checkboxes when no patrol values are set.
beebmx.kirby-patrol.permissions.enabled true bool Enable/Disable the default middleware functionality.
beebmx.kirby-patrol.permissions.middleware [] array Additional middleware functionality.
beebmx.kirby-patrol.permissions.redirect null ?string Disabled the default middleware functionality and changed it to redirect to a specific URL path.

Here's an example of a full use of the options from the config.php file:

Roadmap

License

Licensed under the MIT.

Credits


All versions of kirby-patrol with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
getkirby/composer-installer Version ^1.1
beebmx/kirby-middleware Version ^1.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 beebmx/kirby-patrol contains the following files

Loading the files please wait ....