Skip to content

New parameter %rootDir% #61

@fprochazka

Description

@fprochazka

One of the very few things that prevents Nette application from beeing compiled before deployment (and therefore using it on readonly filesystems) are hardcoded absolute paths in DI Container.

Now imagine if you were to tell the container the root directory of the project.

// this ofcourse could be autoresolved by default, but the setter should be available
$configurator->setRootDir(dirname(__DIR__)); //  dirname(%appDir%)

Now that we have the absolute path, we can set the value "dynamically"

class SystemContainer
{
    public function __construct()
    {
        parent::__construct(array(
            // ....
            'rootDir' => __DIR__ . '/../..',
        ));
    }
}

and the strings in generated container that contain the rootDir string can be replaced with the dynamic value

"/var/www/hosts/kdyby.org/app/../www/images"
$this->parameters['rootDir'] . "/app/../www/images"

This is merely a concept and there are other obstacles, but IMHO this is the main one. Composer uses the same concept for the generated autoloader. I think we should do it similarly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions