Skip to content

Conversation

@kenjis
Copy link
Member

@kenjis kenjis commented Aug 30, 2024

Description
Supersedes #9051
See #9158

$ php spark db:create report

CodeIgniter v4.5.4 Command Line Tool - Server Time: 2024-08-30 00:59:08 UTC+00:00

[CodeIgniter\Exceptions\CriticalError]
The required PHP extension "sqlsrv" is not loaded. Install and enable it to use "SQLSRV" driver.
at SYSTEMPATH/Database/Database.php:177

...

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

To improve the error message.
throw new InvalidArgumentException('You have not selected a database type to connect to.');
}

assert($this->checkDbExtension($params['DBDriver']));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the assert here if the method throws by itself?

Copy link
Member Author

@kenjis kenjis Aug 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My intention is not to slow down CI4 at all by executing the check every time in production environment.
When zend.assertions is -1, PHP does not generate code for assert().

First, this check (error message) is only for PHP beginners. Once the extension is enabled, the check will be not needed.
And this error often happens on development environments.
On shared hosting servers, they probably know what DBMS is supported, and PHP extensions for supported DBs are installed.

Because we can name any classname.
@ddevsr ddevsr added the refactor Pull requests that refactor code label Aug 30, 2024
@kenjis kenjis merged commit ffd1b68 into codeigniter4:develop Sep 5, 2024
@kenjis kenjis deleted the check-db-ext branch September 5, 2024 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Pull requests that refactor code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants