Download the PHP package alexandre-daubois/phikl without Composer

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

🥒 Phikl - Apple's Pkl Bridge for PHP

PHPUnit

Phikl (pronounced "fickle") is a PHP binding for Apple's PKL language. This library uses the official PKL CLI tool from Apple and provides a PHP interface to it.

Installation

You can install this library using composer:

The CLI tool must be installed on your system. You can either install it manually and set the PKL_CLI_BIN environment variable to the path of the binary or use the install subcommand of the pkl command to download the latest supported version of the PKL CLI tool into the vendor/bin directory.

You can also set the download location by using the --location option:

If you do so, you must set the PKL_CLI_BIN environment variable to the path of the binary.

Usage

⚠️ If you plan to use this tool in production, it is highly recommended to cache the PKL modules.

Using the CLI tool

This package offers a CLI tool to interact with the PKL CLI tool. You can use the phikl command to interact with the PKL CLI tool, among other things.

Here are some examples of how to use the phikl command:

Using Pkl in PHP

The main way to use this library is to evaluate PKL code. You can do this by using the evaluate method of the Pkl class.

Basic Usage with PklModule

Let's say you have the following PKL code:

You can evaluate this code like this:

This also works with nested modules:

Cast to other types

You can cast the values to other types using the cast method with a class representing your data. Let's take the following PKL code:

You can cast this to a User class like this:

You can also pass User::class as the second argument to the eval method. This will automatically cast the module to the given class. Beware that it returns an array indexed by the PKL instance name:

The PklProperty Attribute

You can use the PklProperty attribute to specify the name of the property in the PKL file. This is useful when the property name in the PKL file is different from the property name in the PHP class. Let's take the following PKL code:

You can define a User class like this:

When casting, the PklProperty attribute will be used to map the property name in the PKL file to the property name in the PHP class.

Caching

You can (and should) cache the PKL modules to improve performance. This is especially useful when evaluating the same PKL file multiple times.

⚠️ Using Phikl with the cache avoids the PKL CLI tool to be executed to evaluate modules and should be done when deploying your application for better performances.

Warmup the Cache

You can use the warmup command to dump the PKL modules to a cache file by default. Phikl will then use the cache file automatically when evaluating a PKL file. If the PKL file is not found in the cache, Phikl will evaluate the PKL file on the go.

Phikl will go through all .pkl files of your project and dump them to the cache file.

Here's an example of how to use the warmup command:

If you need to validate a cache file, you can do so by using the validate-cache command:

Here are a few things to note about Phikl cache:

Cache Backends

If you have your own cache system, you can use the Pkl::setCache() method to set the cache system to use. You can pass it any instance of compliant PSR-16 cache system implementing Psr\SimpleCache\CacheInterface. This is useful you want to use, for example, a Redis server as a cache system for your Pkl modules.

Phikl comes with the following cache backends:


All versions of phikl with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
psr/simple-cache Version ^3.0
symfony/console Version ^6.4|^7.0
symfony/finder Version ^6.4|^7.0
symfony/process Version ^6.4|^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 alexandre-daubois/phikl contains the following files

Loading the files please wait ....