PHP

PhpScriptTask

  • configure: Should be overridden only with @before_parent decorator

  • inner_execute: Should be overridden preserving original parent after or before

  • input: A string of PHP code, optionally

Package to import

Single task to import

PIP package to install

Stable version

rkd.php.script

rkd.php.script.PhpScriptTask

pip install rkd.php== SELECT VERSION

https://badgen.net/pypi/v/rkd.php

Caution

This is a Base Task. It is not a Task to run, but to create a own, runnable Task basing on it.

Hint

This is an extendable task. Read more in Extending tasks chapter.

class rkd.php.script. PhpScriptTask [source]

# <sphinx:extending-tasks> Execute a PHP code (using a docker container) Can be extended - this is a base task.

Inherits settings from RunInContainerBaseTask .

Configuration:

  • script: Path to script to load instead of stdin (could be a relative path)

  • version: PHP version. Leave None to use default 8.0-alpine version

Example of usage:

version: org.riotkit.rkd/yaml/v2
imports:
    - rkd.php.script.PhpScriptTask
tasks:
    :yaml:test:php:
        extends: rkd.php.script.PhpScriptTask
        configure@before_parent: |
            self.version = '7.2-alpine'
        inner_execute@after_parent: |
            self.in_container('php --version')
            print('IM AFTER PARENT. At first the PHP code from "input" will be executed.')
            return True
        input: |
            var_dump(getcwd());
            var_dump(phpversion());

Example of usage with MultiStepLanguageAgnosticTask:

version: org.riotkit.rkd/yaml/v1
tasks:
    :exec:
        environment:
            PHP: '7.4'
            IMAGE: 'php'
        steps: |
            #!rkd.php.script.PhpLanguage
            phpinfo();

# </sphinx:extending-tasks>

configure ( event : rkd.core.execution.lifecycle.ConfigurationLifecycleEvent ) None [source]

Executes before all tasks are executed. ORDER DOES NOT MATTER, can be executed in parallel.

configure_argparse ( parser : argparse.ArgumentParser ) [source]

Allows a task to configure ArgumentParser (argparse)

def configure_argparse(self, parser: ArgumentParser):
    parser.add_argument('--php', help='PHP version ("php" docker image tag)', default='8.0-alpine')
    parser.add_argument('--image', help='Docker image name', default='php')
inner_execute ( context : rkd.core.api.contract.ExecutionContext ) bool [source]

Execute a code when the container is up and running :param context: :return:

PhpLanguage

class rkd.php.script. PhpLanguage [source]

Language extension for MultiStepLanguageAgnosticTask

version: org.riotkit.rkd/yaml/v1
tasks:
    :exec:
        environment:
            PHP: '7.4'
            IMAGE: 'php'
        steps: |
            #!rkd.php.script.PhpLanguage
            phpinfo();