Yaf_Application::setAppDirectory

(Yaf >=2.1.4)

Yaf_Application::setAppDirectoryChange 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

add a note

User Contributed Notes

There are no user contributed notes for this page.