app icon indicating copy to clipboard operation
app copied to clipboard

Ambiguous difference between App.webroot and App.wwwRoot

Open othercorey opened this issue 4 years ago • 5 comments

The documentation shows them being essentially the same:

     * - webroot - The webroot directory.
     * - wwwRoot - The file path to webroot.

        'webroot' => 'webroot',
        'wwwRoot' => WWW_ROOT,

However, wwwRoot uses a path from paths.php wile webroot hard-codes the same directory in the config.

/*
 * File path to the webroot directory.
 *
 * To derive your webroot from your webserver change this to:
 *
 * `define('WWW_ROOT', rtrim($_SERVER['DOCUMENT_ROOT'], DS) . DS);`
 */
define('WWW_ROOT', ROOT . DS . 'webroot' . DS);

When would you want the webroot separate from the path? Asset loading from plugins don't use either of these, but instead hard-code the directory name webroot/ in source.

othercorey avatar Apr 14 '21 03:04 othercorey

The only use cases I remember around App.webroot are when URL rewriting is off, and the application is in a subdirectory. Plugins are different because their static assets are either served by middleware or the webserver and deployment tooling.

markstory avatar Apr 14 '21 15:04 markstory

There is one direct use of WWW_ROOT in cakephp/cakephp, but it's in ServerCommand.

The only use of App.webroot is in ServerRequestFactory::updatePath():

        $endsWithIndex = '/' . (Configure::read('App.webroot') ?: 'webroot') . '/index.php';

othercorey avatar Apr 14 '21 19:04 othercorey

This issue is stale because it has been open for 120 days with no activity. Remove the stale label or comment or this will be closed in 15 days

github-actions[bot] avatar Aug 13 '21 00:08 github-actions[bot]

This issue is stale because it has been open for 120 days with no activity. Remove the stale label or comment or this will be closed in 15 days

github-actions[bot] avatar Apr 22 '22 00:04 github-actions[bot]