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::runYaf_Bootstrap_Abstract>
^Yaf_ApplicationLast updated: Mon, 26 Oct 2026

Yaf_Application::setAppDirectory

(Yaf >=2.1.4)

Yaf_Application::setAppDirectory — Change the application directory

Description

public function Yaf_Application::setAppDirectory(string $directory): Yaf_Application|null|false

Change the application directory, under which Yaf looks for controllers, views and modules. The new directory must be an absolute path.

Parameters

directory

The absolute path of the new application directory.

Return Values

Returns the Yaf_Application object itself on success, false if directory is empty or not an absolute path, or null if the application is not properly initialized.

Examples

Example #1 Yaf_Application::setAppDirectory() example

<?php
$app = Yaf_Application::app();

/* returns the application itself on success, for chaining */
var_dump($app->setAppDirectory("/srv/legacy/mvc/app"));
var_dump($app->getAppDirectory());

/* an empty or relative path is rejected */
var_dump($app->setAppDirectory(""));
var_dump($app->setAppDirectory("relative/path"));
?>

The above example will output something similar to:

object(Yaf_Application)#1 (0) {
}
string(20) "/srv/legacy/mvc/app"
bool(false)
bool(false)

See Also


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