Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<Yaf_Application::environYaf_Application::getAppDirectory>
^Yaf_ApplicationLast updated: Mon, 26 Oct 2026

Yaf_Application::execute

(Yaf >=1.0.0)

Yaf_Application::execute — Execute a callback

Description

public function Yaf_Application::execute(callable $callback, mixed ...$args): mixed

Execute a callback. This method is typically used to run Yaf in a cron job or other CLI script, so that the script can reuse the autoloader and the bootstrap mechanism.

Parameters

callback

A valid callback to execute.

args

Optional parameters passed to the callback.

Return Values

Returns whatever the callback returns, or false if calling the callback failed.

Examples

Example #1 Yaf_Application::execute() example

<?php
function main($argc, $argv) {
    var_dump($argc);
    var_dump($argv);
}

$config = array(
    "application" => array(
        "directory" => realpath(dirname(__FILE__)) . "/application",
    ),
);

/** Yaf_Application */
$application = new Yaf_Application($config);
$application->execute("main", $argc, $argv);
?>

The above example will output something similar to:

int(2)
array(2) {
  [0]=>
  string(11) "execute.php"
  [1]=>
  string(3) "arg"
}

See Also


<Yaf_Application::environYaf_Application::getAppDirectory>
^Yaf_ApplicationLast updated: Mon, 26 Oct 2026