Download the PHP package getkirby/kql without Composer

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

Kirby QL

Kirby's Query Language API combines the flexibility of Kirby's data structures, the power of GraphQL and the simplicity of REST.

The Kirby QL API takes POST requests with standard JSON objects and returns highly customized results that fit your application.

Playground

You can play in our KQL sandbox. The sandbox is based on the Kirby starterkit.

ℹī¸ Source code of the playground is available on GitHub.

Example

Given a POST request to: /api/query

🆗 Response

Installation

Manual

Download and copy this repository to /site/plugins/kql of your Kirby installation.

Composer

Documentation

API Endpoint

KQL adds a new query API endpoint to your Kirby API (i.e. yoursite.com/api/query). This endpoint requires authentication.

You can switch off authentication in your config at your own risk:

Sending POST Requests

You can use any HTTP request library in your language of choice to make regular POST requests to your /api/query endpoint. In this example, we are using the fetch API and JavaScript to retrieve data from our Kirby installation.

query

With the query, you can fetch data from anywhere in your Kirby site. You can query fields, pages, files, users, languages, roles and more.

Queries Without Selects

When you don't pass the select option, Kirby will try to come up with the most useful result set for you. This is great for simple queries.

Fetching the Site Title
🆗 Response
Fetching a List of Page IDs
🆗 Response

Running Field Methods

Queries can even execute field methods.

🆗 Response

select

KQL becomes really powerful by its flexible way to control the result set with the select option.

Select Single Properties and Fields

To include a property or field in your results, list them as an array. Check out our reference for available properties for pages, users, files, etc.

🆗 Response

You can also use the object notation and pass true for each key/property you want to include.

🆗 Response

Using Queries for Properties and Fields

Instead of passing true, you can also pass a string query to specify what you want to return for each key in your select object.

🆗 Response

Executing Field Methods

🆗 Response

Creating Aliases

String queries are a perfect way to create aliases or return variations of the same field or property multiple times.

🆗 Response

Subqueries

With such string queries you can of course also include nested data

🆗 Response

Subqueries With Selects

You can also pass an object with a query and a select option

🆗 Response

Pagination

Whenever you query a collection (pages, files, users, roles, languages) you can limit the resultset and also paginate through entries. You've probably already seen the pagination object in the results above. It is included in all results for collections, even if you didn't specify any pagination settings.

limit

You can specify a custom limit with the limit option. The default limit for collections is 100 entries.

🆗 Response

page

You can jump to any page in the resultset with the page option.

🆗 Response

Pagination in Subqueries

Pagination settings also work for subqueries.

Multiple Queries in a Single Call

With the power of selects and subqueries you can basically query the entire site in a single request

Allowing Methods

KQL is very strict with allowed methods by default. Custom page methods, file methods or model methods are not allowed to make sure you don't miss an important security issue by accident. You can allow additional methods though.

Allow List

The most straight forward way is to define allowed methods in your config.

DocBlock Comment

You can also add a comment to your methods' doc blocks to allow them:

This works for model methods as well as for custom page methods, file methods or other methods defined in plugins.

Blocking Methods

You can block individual class methods that would normally be accessible by listing them in your config:

Blocking Classes

Sometimes you might want to reduce access to various parts of the system. This can be done by blocking individual methods (see above) or by blocking entire classes.

Now, access to any user is blocked.

Custom Classes and Interceptors

If you want to add support for a custom class or a class in Kirby's source that is not supported yet, you can list your own interceptors in your config

You can put the class for such a custom interceptor in a plugin for example.

Interceptor classes are pretty straight forward. With the CLASS_ALIAS you can give objects with that class a short name for KQL queries. The $toArray property lists all methods that should be rendered if you don't run a subquery. I.e. in this case kirby.system would render an array with the isInstallable value.

The allowedMethods method must return an array of all methods that can be access for this object. In addition to that you can also create your own custom methods in an interceptor that will then become available in KQL.

This custom method can now be used with kirby.system.isReady in KQL and will return yes it is!

Unintercepted Classes

If you want to fully allow access to an entire class without putting an interceptor in between, you can add the class to the allow list in your config:

This will introduce full access to all public class methods. This can be very risky though and you should avoid this if possible.

No Mutations

KQL only offers access to data in your site. It does not support any mutations. All destructive methods are blocked and cannot be accessed in queries.

Plugins

What's Kirby?


License

Bastian Allgeier


All versions of kql with dependencies

PHP Build Version
Package Version
Requires getkirby/cms Version ^3.10.0 || ^4.0 || ^5.0
getkirby/composer-installer Version ^1.2.1
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 getkirby/kql contains the following files

Loading the files please wait ....