shlinkio / shlink

The definitive self-hosted URL shortener
https://shlink.io
MIT License
3.21k stars 258 forks source link

Too few arguments to function Shlinkio\\Shlink\\Config\\parseEnvVar(), 0 passed in vendor/shlinkio/shlink-config/functions/functions.php on line 82 and exactly 1 expected invendor/shlinkio/shlink-config/functions/functions.php:46 #1718

Closed Emojigit closed 1 year ago

Emojigit commented 1 year ago

How Shlink is set up

Summary

I installed Shlink using the following commands (just like what developers would, but on the stable branch):

git clone https://github.com/shlinkio/shlink/ -b main --depth 1 --recursive # Clone the stable branch, shalow clone, recursive submodules (if any)
composer install # install PHP dependencies

I set up Shlink using vendor/bin/shlink-install. Here is my config/params/generated_config.php:

<?php
return array(
    'DB_DRIVER' => 'mysql',
    'DB_NAME' => 'shlink',
    'DB_HOST' => 'localhost',
    'DB_PORT' => '3306',
    'DB_USER' => 'shlink',
    'DB_PASSWORD' => '[PLACEHOLDER]',
    'DB_UNIX_SOCKET' => '/run/mysqld/mysqld.sock',
    'DEFAULT_DOMAIN' => 'placeholder.example.com',
    'IS_HTTPS_ENABLED' => true,
    'DEFAULT_SHORT_CODES_LENGTH' => 5,
    'AUTO_RESOLVE_TITLES' => true,
    'REDIRECT_APPEND_EXTRA_PATH' => false,
    'MULTI_SEGMENT_SLUGS_ENABLED' => false,
    'SHORT_URL_TRAILING_SLASH' => true,
    'SHORT_URL_MODE' => 'strict',
    'GEOLITE_LICENSE_KEY' => null,
    'REDIRECT_STATUS_CODE' => 308,
    'REDIRECT_CACHE_LIFETIME' => 30,
    'DISABLE_TRACKING' => false,
    'TRACK_ORPHAN_VISITS' => true,
    'DISABLE_TRACK_PARAM' => 'dnt',
    'DISABLE_TRACKING_FROM' => '127.0.0.1,::1',
    'DISABLE_IP_TRACKING' => true,
    'DISABLE_UA_TRACKING' => true,
    'DISABLE_REFERRER_TRACKING' => true,
    'DEFAULT_BASE_URL_REDIRECT' => null,
    'DEFAULT_INVALID_SHORT_URL_REDIRECT' => null,
    'DEFAULT_REGULAR_404_REDIRECT' => null,
    'DEFAULT_QR_CODE_SIZE' => 300,
    'DEFAULT_QR_CODE_MARGIN' => 0,
    'DEFAULT_QR_CODE_FORMAT' => 'svg',
    'DEFAULT_QR_CODE_ERROR_CORRECTION' => 'q',
    'DEFAULT_QR_CODE_ROUND_BLOCK_SIZE' => true,
    'DELETE_SHORT_URL_THRESHOLD' => null,
    'BASE_PATH' => '',
    'TIMEZONE' => null,
    'REDIS_SERVERS' => null,
);

Here I attach my Apache site configuration file:

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName placeholder.example.com

    DocumentRoot /var/www/s/public

    ErrorLog ${APACHE_LOG_DIR}/error-s.log
    CustomLog ${APACHE_LOG_DIR}/access-s.log combined

    # SSL certs and configurations are configured here; 
    # The server is proxied through Cloudflare.
    Include /etc/apache2/cf_certs/cf_certs.conf 
    <Directory "/var/www/s/public">
        Options FollowSymLinks Includes ExecCGI
        AllowOverride all
        Order allow,deny
        Allow from all
    </Directory>

    Header set Access-Control-Allow-Origin "app.shlink.io"
</VirtualHost>
</IfModule>

Current behavior

The PHP script failed to execute. It raises the following error:

PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function Shlinkio\\Shlink\\Config\\parseEnvVar(), 0 passed in /var/www/s/vendor/shlinkio/shlink-config/functions/functions.php on line 82 and exactly 1 expected in /var/www/s/vendor/shlinkio/shlink-config/functions/functions.php:46
Stack trace:
#0 /var/www/s/vendor/shlinkio/shlink-config/functions/functions.php(82): Shlinkio\\Shlink\\Config\\parseEnvVar()
#1 /var/www/s/config/autoload/swoole.global.php(26): Shlinkio\\Shlink\\Config\\getOpenswooleConfigFromEnv()
#2 /var/www/s/config/autoload/swoole.global.php(34): Laminas\\ConfigAggregator\\PhpFileProvider::{closure}()
#3 /var/www/s/vendor/laminas/laminas-config-aggregator/src/PhpFileProvider.php(29): include('...')
#4 /var/www/s/vendor/laminas/laminas-config-aggregator/src/ConfigAggregator.php(238): Laminas\\ConfigAggregator\\PhpFileProvider->__invoke()
#5 /var/www/s/vendor/laminas/laminas-config-aggregator/src/ConfigAggregator.php(82): Laminas\\ConfigAggregator\\ConfigAggregator->loadConfigFromProviders()
#6 /var/www/s/config/config.php(52): Laminas\\ConfigAggregator\\ConfigAggregator->__construct()
#7 /var/www/s/config/container.php(26): require('...')
#8 /var/www/s/config/container.php(31): {closure}()
#9 /var/www/s/config/run.php(10): include('...')
#10 /var/www/s/public/index.php(5): {closure}()
#11 {main}
  thrown in /var/www/s/vendor/shlinkio/shlink-config/functions/functions.php on line 46

Expected behavior

It should work. I've followed the steps in install from dist files.

How to reproduce

Follow what I did. If this is not a device-specific problem nor a careless mistake, this should be reproduced.

acelaya commented 1 year ago

In the document you reference it doesn't mention anything about git-cloning. Instead, you should download a "dist" file.

In that same document you will find a "Download" button. Click on it, and on the release page, download the appropriate dist file, decompress it, and then follow the next steps as you did.