aprivette / bedrock-auth

Environment-specific basic auth for the Bedrock WordPress framework
GNU General Public License v3.0
3 stars 2 forks source link

PHPDotEnv 5.5 compatibility #1

Closed bwp-codes closed 8 months ago

bwp-codes commented 8 months ago

Hi Adam, first off, thanks for this plugin! I have noticed that it is currently not compatible with vlucas/phpdotenv v5.5 and throws some fatal errors regarding phpdotenv internals. I created a fork and changed some things to make it work, that I would like to share with you:

1: bedrock-auth.php:15-18

namespace BedrockAuth;

use Dotenv;
use Env;

changed to

use function Env\env;

2: changed constructor from:

    public function __construct()
    {
        $this->root_dir = dirname(dirname(ABSPATH));
        $this->dotenv = new Dotenv\Dotenv($this->root_dir);

        Env::init();
    }

to:

    public function __construct()
    {
        $this->root_dir = dirname(dirname(ABSPATH));
        $this->dotenv = Dotenv\Dotenv::createUnsafeImmutable($this->root_dir);
    }

After these changes, the plugin can be activated when using with vlucas/phpdotenv v5.5

aprivette commented 8 months ago

Hey! Thanks for the notes, I just tagged a new release :)