PHP RFC: Oniguruma maintenance end and end of mbregex
- Version: 0.1
- Date: 2025-08-21
- Author: Yuya Hamada youkidearitai@gmail.com
- Status: Under Discussion
- Implementation: https://github.com/php/php-src/pull/21490
Introduction
Oniguruma maintenance ended on 2025-04-24. PHP uses mbregex (mb_ereg...) functions. So we decide future of mbregex. This proposal is ends of support mbregex PHP 9.0 and Deprecate 8.6.
Proposal
Deprecate mbregex functions in PHP 8.6, Delete 9.0.
Deprecated: Function mb_ereg_replace() is deprecated since 8.6, Oniguruma functions support ends PHP 9.0 in %s on line %d
It is likely that the following points need to be decided, and how we will maintain versions 8.2 - 8.5.
- Maintenance versions: 8.2, 8.3, 8.4, 8.5
- Mbregex instead of mb_onig
- Deprecate version: 8.6 (next after 8.5)
- Drop support: 9.0
Maintenance versions can use mbregex functions. However, FreeBSD will drop support on 2026-12-01 (ref: https://github.com/php/php-src/issues/18467#issuecomment-3044192511). We should decide what we will do after EOL in FreeBSD. (This is effect CI in php-src repository)
I suggest to below:
- External packaging for example https://github.com/youkidearitai/mb_onig/ (create by me)
- Disable mbregex in configure option(--disable-mbregex)
Drop the following mbregex functions
- mb_ereg
- mb_ereg_match
- mb_ereg_replace
- mb_ereg_replace_callback
- mb_ereg_search
- mb_ereg_search_getpos
- mb_ereg_search_getregs
- mb_ereg_search_init
- mb_ereg_search_pos
- mb_ereg_search_regs
- mb_ereg_search_setpos
- mb_eregi
- mb_eregi_replace
- mb_regex_encoding
- mb_regex_set_options
- mb_split
Constants
- MB_ONIGURUMA_VERSION
php.ini options
- mbstring.regex_retry_limit
- mbstring.regex_stack_limit
Forked from Oniguruma
In Ruby, There is a Onigmo forked from Oniguruma.
However, Onigmo is different in Oniguruma.
- Performance(faster than Oniguruma)
- Unicode version
- Some expressions: `\K`, `\R`, `(?(cond)yes|no)`
Libraries that depend on estimated Oniguruma
I quoted from https://news-web.php.net/php.internals/130429
Uses code from Juliette https://gist.github.com/jrfnl/bd0f66f1c185930427db4f093babf214
Summary of findings: PHP CODE SNIFFER VIOLATION SOURCE SUMMARY ------------------------------------------------------------------------------------------- SOURCE COUNT ------------------------------------------------------------------------------------------- PHPCompatibility.FunctionUse.RemovedFunctions.mb_splitDeprecated 30 PHPCompatibility.FunctionUse.RemovedFunctions.mb_regex_encodingDeprecated 25 PHPCompatibility.FunctionUse.RemovedFunctions.mb_eregi_replaceDeprecated 20 PHPCompatibility.FunctionUse.RemovedFunctions.mb_ereg_replaceDeprecated 18 PHPCompatibility.FunctionUse.RemovedFunctions.mb_ereg_matchDeprecated 13 PHPCompatibility.FunctionUse.RemovedFunctions.mb_ereg_search_initDeprecated 10 PHPCompatibility.FunctionUse.RemovedFunctions.mb_ereg_search_regsDeprecated 9 PHPCompatibility.FunctionUse.RemovedFunctions.mb_ereg_replace_callbackDeprecated 6 PHPCompatibility.FunctionUse.RemovedFunctions.mb_ereg_search_getregsDeprecated 5 PHPCompatibility.FunctionUse.RemovedFunctions.mb_eregDeprecated 4 PHPCompatibility.FunctionUse.RemovedFunctions.mb_ereg_search_setposDeprecated 4 PHPCompatibility.FunctionUse.RemovedFunctions.mb_eregiDeprecated 2 PHPCompatibility.FunctionUse.RemovedFunctions.mb_ereg_search_posDeprecated 1 ------------------------------------------------------------------------------------------- A TOTAL OF 147 SNIFF VIOLATIONS WERE FOUND IN 13 SOURCES -------------------------------------------------------------------------------------------
Thanks, Juliette.
However, Probably proprietary software are uses mbregex functions. Impact is larger than that result.
External packaging for mb_onig
This RFC is big impact from multibyte(not UTF-8) users.
Therefore, I created bailout extension mb_onig https://packagist.org/packages/mb_onig/mb_onig that we can still use mbregex functions. So PHP 8.x can still use mbregex functions and we can still maintain mbregex for PHP 9.x.
Why name is `mb_onig`?
Debian/Ubuntu users calls Oniguruma to `onig`. I quoted this.
$ sudo apt search onig libonig-dev/noble,now 6.9.9-1build1 amd64 [installed] regular expressions library — development files libonig5/noble,now 6.9.9-1build1 amd64 [installed,automatic] regular expressions library
PHP 8.x
./configure --enable-mbstring --disable-mbregex make make install pie install mb_onig/mb_onig
PHP 9
./configure --enable-mbstring make make install pie install mb_onig/mb_onig
Backward Incompatible Changes
The mbregex functions cannot be used.
Proposed PHP Version(s)
Deprecate for 8.6 and remove in 9.0.
RFC Impact
To Existing Extensions
Mbregex
To SAPIs
Describe the impact to CLI, Development web server, embedded PHP etc.
Open Issues
Future Scope
This section should outline areas that you are not planning to work on in the scope of this RFC, but that might be iterated upon in the future by yourself or another contributor.
This helps with long-term planning and ensuring this RFC does not prevent future work.
Voting Choices
- Drop support the mbregex functions, Deprecate 8.6 and delete 9.0
Implementation
- Re-include Oniguruma version: https://github.com/php/php-src/pull/19258
-
- Deprecate mbregex: https://github.com/php/php-src/pull/21490
References
Rejected Features
Keep this updated with features that were discussed on the mail lists.
Changelog
If there are major changes to the initial proposal, please include a short summary with a date or a link to the mailing list announcement here, as not everyone has access to the wikis' version history.