Reputation: 103
I'm new to PHP and trying to open the CodeIgniter 4 welcome page by using localhost (I don't have any server programs like XAMPP since it's a company computer and PHP works fine with its built-in server.)
When I try to run the command: php spark serve
on the terminal, it gives an error like this:
Uncaught Error: Call to undefined function CodeIgniter\CLI\mb_strpos() in C:\Users\50290536\Desktop\php-test\system\CLI\CLI.php:776
I enabled the necessary extensions in the php.ini
file and the file: php_mbstring.dll
is available in the directory php/ext
.
I also tried to run the command: php spark
to see if spark
works fine but in that case, I got the following error:
The framework needs the following extension(s) installed and loaded: curl, intl, mbstring at SYSTEMPATH\Codeigniter.php:224
All these extensions are enabled in the php.ini
file and their respective .dll
files are available in the directory php/ext
.
PHP version: v8.2
CodeIgniter 4 framework version: v4.2.10
Currently enabled PHP modules after running the command: php -m
bcmath
calendar
Core
ctype
date
dom
filter
hash
iconv
json
libxml
mysqlnd
pcre
PDO
Phar
random
readline
Reflection
session
SimpleXML
SPL
standard
tokenizer
xml
xmlreader
xmlwriter
zlib
Upvotes: 2
Views: 1875
Reputation: 119
In my case the extension_dir directive in php.ini was relative path. If you change it to absolute it should works. For example:
extension_dir = "c:\php\ext"
Alternatively, you can try with these values: "./ext" or ".\ext" or "ext". Make sure you uncomment the directive. (Just delete the semicolon from the beginning)
It is a known bug on some machine/version.
As you said your OS is Windows, you may check if it resolves the problem. I think if the php -m
command lists the mbstring extension, then it will fix your original problem, and the CodeIgniter spark will works fine.
Make sure you edit the right php configuration file. You can find the location of your php with the which php
or where php
commands.
And yes, you can just simply move the php.ini-development to php.ini, it should work.
Source: https://stackoverflow.com/a/63489141/7742526 and https://bugs.php.net/bug.php?id=74866
Upvotes: 0