Skip to content

Ambiguous difference between App.webroot and App.wwwRoot #838

Open

Description

@othercorey

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.

Activity

  1. added this to the 4.x milestone on Apr 14, 2021
  2. markstory commented on Apr 14, 2021

    @markstory
    Member

    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.

  3. othercorey commented on Apr 14, 2021

    @othercorey
    ContributorAuthor

    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';
    
  4. github-actions commented on Aug 13, 2021

    @github-actions

    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

  5. github-actions commented on Apr 22, 2022

    @github-actions

    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

  6. dereuromark commented on Oct 15, 2024

    @dereuromark
    Member

    Do we want to tackle this for 5.next or 6.0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions