Accept array of strings for "compressors" URI option

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • PHP Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      Summary

      The ext-mongodb driver currently requires the compressors URI option to be a comma-separated string:

      new MongoDB\Driver\Manager\('mongodb://localhost/', [
          'compressors' => 'snappy,zstd,zlib',
      ]);
      

      Passing a PHP array throws:

      InvalidArgumentException: Expected string for "compressors" URI option, array given
      

      Proposal

      Accept an array of strings in addition to the CSV string form:

      new MongoDB\Driver\Manager\('mongodb://localhost/', [
          'compressors' => ['snappy', 'zstd', 'zlib'],
      ]);
      

      Rationale* More idiomatic in PHP and in framework configuration files (e.g. Laravel config/database.php).

      • Avoids CSV pitfalls: stray spaces, typos, manual implode() calls.
      • Consistent with how other list-like options are typically expressed in PHP userland.
      • The CSV string form should remain supported for backward compatibility and parity with the connection string.

      Scope

      URI option parsing in ext-mongodb. Documentation and library examples can be updated once available.

            Assignee:
            Unassigned
            Reporter:
            Jérôme Tamarelle
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: