Unable to Initialize .env file

Hi There!!

will be glad if you could help me with this issue :slight_smile:

I am new to Kirby and trying to add .env file to the kirby repository.

Tried following steps

  1. Install "bnomei/kirby3-dotenv": "^1.1"

  2. Create .env file

      Matomo Token is used to access the Matomo dashboard.                            
      MATOMO_TOKEN= 334*******************************9
    
  3. initialized plugin inside /config/config.php as bellow
    <?php

     Bnomei\DotEnv::load();
     $matomo_token =  getenv('MATOMO_TOKEN');
    
     return [
       'sylvainjule.matomo.url' => 'my/motomo/url',
       'sylvainjule.matomo.id' => '1',
       'sylvainjule.matomo.token' => $matomo_token
     ];
    

I am unable to use the token using .env and getting the following error

Allowed memory size of 134217728 bytes exhausted (tried to allocate 65536 bytes)

you can not use a plugin in the config file without an closure.

 return [
   'sylvainjule.matomo.url' => 'my/motomo/url',
   'sylvainjule.matomo.id' => '1',
   'sylvainjule.matomo.token' => function () {
      Bnomei\DotEnv::load();
      return getenv('MATOMO_TOKEN');
   }
 ];

i created a feature request for the matomo plugin by @sylvainjule to support this.

1 Like

Thanks for the quick replay!!

will be great to see this working after the issue " allow token from closure"

a little tip: if you type @ followed by any name of a forum member they will receive a notification unless they have already posted in the thread. so feel free to mention me with @bnomei if you need help with any of my plugins.

1 Like

@bnomei Thanks for the solution!!
However, after updating the Matomo and config.php now I can see an empty dashboard Like bellow

still, there is a problem to update Token from .env the file. will be great if you could help me !!

@sylvainjule has not yet responded or even implemented the possibility for the token to be a closure. unless you apply a hotfix yourself it will not work yet. please β€œwatch” the issue to get notifications once its implmented.

1 Like

Sure will wait until it gets resolved :+1:

1 Like

v2 of my plugin now supports loading in config file and multi-environment setups. see examples