roots / bedrock

WordPress boilerplate with Composer, easier configuration, and an improved folder structure
https://roots.io/bedrock/
MIT License
6.19k stars 1.17k forks source link

Maybe use a var for "web" #581

Closed tlcd96 closed 3 years ago

tlcd96 commented 3 years ago

Motivation

https://github.com/roots/bedrock/blob/ea2872512b9cecb2dea2291ddabcb3693ee39d43/config/application.php#L26 In my case i change the web to public_html, for the php in vendor and configs and the env file to be completely secured. The public_html is the public dir, below that there's no apparent way for a unknown user to access it, improving security. my server example, can be replicated with:

In my case i change the web to public_html, for the php in vendor and configs and the env file to be completely secured. The public_html is the public dir, below that there's no apparent way for a unknown user to access it, improving security. my server example, can be replicated with:

possible code:


/**
 * Use Dotenv to set required environment variables and load .env file in root
 */
$dotenv = Dotenv\Dotenv::createUnsafeImmutable($root_dir);

if (file_exists($root_dir . '/.env')) {
    $dotenv->load();
    $dotenv->required(['WP_HOME', 'WP_SITEURL']);
    if (!env('DATABASE_URL')) {
        $dotenv->required(['DB_NAME', 'DB_USER', 'DB_PASSWORD']);
    }
    /**
     * Document Root
     * Created from env var 'WP_WEBROOT'
     *
     * @var string
     */
    $webroot_dir = $root_dir . '/'. ltrim(env('WP_WEBROOT'),'/');
}
if(!isset($webroot_dir) || ($root_dir == rtrim($webroot_dir,'/')){
    /**
     * Document Root Fallback if it isn't created correctly
     * 
     * @var string
     */
    $webroot_dir = $root_dir . '/web';
}

The code was written on the fly, so it might contain errors.

github-actions[bot] commented 3 years ago

Hi @skullwritter, It looks like the issue template is missing from this issue. Please take a look at the Contribution Guidelines, which will tell you exactly what your ticket has to contain in order to be processable. Please do not use the issue tracker for personal support requests. Use Roots Discourse to ask the Roots community for help, or hire someone from the community.