php8.5
Home/ Manual/ yaf / yaf_application/ Yaf_Application::setAppDirectory

Yaf_Application::setAppDirectory

PHP function Edit on GitHub ✎

(Yaf >=2.1.4)

Change the application directory

Description

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

Yaf_Application::setAppDirectory example

php
<?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:

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

See Also

  • Yaf_Application::getAppDirectory

Source: reference/yaf/yaf_application/setappdirectory.xml · from the official PHP manual (php/doc-en)