Category Archives: PHP

PHP encryption 3DES error Call to undefined function: mcrypt_module_open() solution

$td = mcrypt_module_open( MCRYPT_3DES,”, MCRYPT_MODE_CBC,”); It is him who reported the error.

I searched a lot of solutions, the correct method should be (only for windows system):


This error occurs when the function mcrypt_module_open is used for decryption when the server running php lacks libmcrypt.dll.
Do the following settings on the server to solve the problem.


Download a php mcrypt module installation package from the Internet, you only need the libmcrypt.dll file (generally downloaded from the official website, there is already in the php directory)


1. Copy libmcrypt.dll to the system32 directory or the extensions directory under the php installation directory
2. Copy libmcrypt.dll to the bin directory of the apache installation directory
3. Find the php.ini file in the windows directory and open it
4. Find; Directory in which the loadable extensions (modules) reside.
extension_dir = “./”  such as: extension_dir = “D:\php5\ext”
these two lines, make sure that libmcrypt.dll can be found in the directory pointed to by extension_dir, or the system There is libmcrypt.dll under path
5. Find; under the Windows Extensions item; extension=php_mcrypt.dll this line and ;extension=php_iconv.dll (mine is not, omitted) these two lines, remove the front semicolon

How to Solve opcache error: zend_mm_heap corrupted

There are always problems with production. It seems that the memory is full, which makes it impossible to request


1. Machine clusters are built with containers
2. The request always appears 502, and it will appear after restarting PHP FPM

3. Open the error log configuration

Of course, you can’t turn off opcache directly. You will find that there is no cache. The memory is very high

Open the error log, and the log will appear in/var/log/PHP FPM/error.log

VI/etc/php-fpm.d/w8002.conf # select different conf files according to which group you want to change
Add a line at the end: catch_ workers_ output = yes

Php5.6 has been reported Zend_ mm_ Heap corrupted with standard PHP 5.6: locating the cause and “Zend”_ mm_ “Heap corrupted” looks like a memory explosion. After a turn, it’s the problem of opcache. Try to disable it, modify the configuration in php.ini and restart PHP FPM

View PHP error log

[[email protected] php-fpm]# grep zend error.log | tail -n 3
[01-Jun-2021 00:21:01] WARNING: [pool www8002] child 20812 said into stderr: "zend_mm_heap corrupted"
[01-Jun-2021 00:27:49] WARNING: [pool www8002] child 32582 said into stderr: "zend_mm_heap corrupted"
[01-Jun-2021 00:28:06] WARNING: [pool www8002] child 339 said into stderr: "zend_mm_heap corrupted"

cat php.ini | grep "opcache"
1. /etc/php.d/opcache.ini 改 "opcache.enable=0"
2. systemctl restart php-fpm

Key point: of course, you can’t turn off opcache directly. You will find that the cache memory is too high, so you can’t turn off opcache directly. Let’s start tuning opcache

; switch on

; available memory, as appropriate, in megabytes

Maximum number of files to cache, try to increase this value if the hit rate is less than 100%

opcache.max_accelerated_files=5000 ; Opcache will check the modification time of files within a certain period of time, here set the check time period, the default is 2, in seconds

The memory size of the interned string, also adjustable

whether to fast shutdown, the speed of reclaiming memory will be increased when PHP Request Shutdown is turned on

Do not save file/function comments

Reference Links:

[Solved] Request exceeded the limit of 10 internal redirects due to possible configuration error

//httpd error log error:
Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase 
the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer:

Most of the answers on the Internet are about. Htaccess, but I don’t think there’s anything wrong with local HTaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond   %{REQUEST_FILENAME} !-f
    RewriteRule   ^(.*)$ index.php?_url=/$1 [QSA,L]

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule  ^$ apg/public/    [L]
    RewriteRule  (.*) apg/public/$1 [L]

The url is correct

But the page doesn’t display the right content.
Let me see where the framework needs to be changed. I still think the framework hasn’t changed.
Later, I checked my collection.php, and there was an array in it, and I added the name of MyProject MyProject:

 static private $ProjectsArray = array(

The problem solved! Check my localhost page again and you can visit my Project login page. The framework has been set up successfully!

Laravel-admin php artisan admin:install error reporting problem solution

Problem description: According to the installation steps of the official laravel-admin document, execute: php artisan admin:install An error was reported during installation.

In fact, the problem of creating special characters in the database is too long. Laravel 5.4 changed the default database character set. Now utf8mb4 includes support for storing emojis. If you are running MySQL v5.7.7 or higher, you don’t need to do anything.

When you try to run the migrations command on some MariaDB or some older versions of MySQL, you may encounter the following error:

D:\wwwroot\>php artisan admin:install
Migration table created successfully.

In Connection.php line 664:

  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (S
  QL: alter table `users` add unique `users_email_unique`(`email`))

In Connection.php line 458:

  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes

The solution is to add default values ​​in app\Providers\AppServiceProvider.php, and you need to delete the database migrations and users tables. Re-execute: php artisan admin:install


namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema; //add fixed sql

class AppServiceProvider extends ServiceProvider
    /* *
     * Bootstrap any application services.
     * @return void
    public function boot()
        Schema::defaultStringLength(191); //add fixed sql

    /* *
     * Register any application services.
     * @return void
    public function register()

Workman Run Error: stream_socket_server() has been disabled for security reasons

Start the workman and report an error

Workerman[start.php] start in DEBUG mode
stream_socket_server() has been disabled for security reasons in file /home/wwwroot/laykefu/vendor/workerman/workerman/Worker.php on line 2214
PHP Fatal error:  Uncaught Exception in /home/wwwroot/laykefu/vendor/workerman/workerman/Worker.php:2216
Stack trace:
#0 /home/wwwroot/laykefu/vendor/workerman/workerman/Worker.php(646): Workerman\Worker->listen()
#1 /home/wwwroot/laykefu/vendor/workerman/workerman/Worker.php(504): Workerman\Worker::initWorkers()
#2 /home/wwwroot/laykefu/vendor/workerman/Config/start.php(37): Workerman\Worker::runAll()
#3 {main}
  thrown in /home/wwwroot/laykefu/vendor/workerman/workerman/Worker.php on line 2216

Fatal error: Uncaught Exception in /home/wwwroot/laykefu/vendor/workerman/workerman/Worker.php:2216
Stack trace:
#0 /home/wwwroot/laykefu/vendor/workerman/workerman/Worker.php(646): Workerman\Worker->listen()
#1 /home/wwwroot/laykefu/vendor/workerman/workerman/Worker.php(504): Workerman\Worker::initWorkers()
#2 /home/wwwroot/laykefu/vendor/workerman/Config/start.php(37): Workerman\Worker::runAll()
#3 {main}
  thrown in /home/wwwroot/laykefu/vendor/workerman/workerman/Worker.php on line 2216

The reason is: PHP the stream_socket_erver()function is disabled


Find the php.inifile and find disable_functionswhether stream_socket_server()this function is disabled in this item

find / -name php.ini # Find the location of php.ini
vim /usr/local/php/etc/php.ini # open edit php.ini

Press esc key, enter :/stream_socket_server, press nstart search

Check the function is not in disable_functionsthis one there, this one is meant Prohibited Method

If there is this function, delete it, press the esc key, enter to wqsave and exit

Restart php-fpm

service php-fpm restart

Mac installs the php Swoole extension and appears Enable openssl support, require openssl library or fatal error:’openssl/ssl.h’ file not found

When installing php Swoole extend Mac Enable openssl support, require openssl libraryor fatal error: 'openssl/ssl.h' file not foundwhen specifying the opensslpath just fine

./configure --with-openssl-dir=/usr/local/opt/[email protected]1.1 --enable-http2 --with-php-config=/Applications/MAMP/bin/php/php7.4.2/bin/php-config

The OpenSSL installed by brew is by default /usr/local/Cellar/openss/version, and I will report fatal error: 'openssl/ssl.h' file not foundan error after using it . Probably my openssl installation path is in/usr/local/opt/[email protected]

PHP solves the problem that composer exceeds the memory size Allowed memory size


Today, when I used composer to update and install the expansion pack, it reported that the memory size was exceeded

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/Rule2Literals.php on li
ne 53

Check for more info on how to handle out of memory errors.


First execute the composer help command to obtain the composer installation directory

composer -h

Results of the

D:\php_work\fund-admin>composer -h
  help [options] [--] [<command_name>]

  command                        The command to execute
  command_name                   The command name [default: "help"]

      --xml                      To output help as XML
      --format=FORMAT            The output format (txt, xml, json, or md) [default: "txt"]
      --raw                      To output raw command help
  -h, --help                     Display this help message
  -q, --quiet                    Do not output any message
  -V, --version                  Display this application version
      --ansi                     Force ANSI output
      --no-ansi                  Disable ANSI output
  -n, --no-interaction           Do not ask any interactive question
      --profile                  Display timing and memory usage information
      --no-plugins               Whether to disable plugins.
  -d, --working-dir=WORKING-DIR  If specified, use the given directory as working directory.
      --no-cache                 Prevent use of the cache
  -v|vv|vvv, --verbose           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

  The help command displays help for a given command:

    php C:\ProgramData\ComposerSetup\bin\composer.phar help list

  You can also output the help in other formats by using the --format option:

    php C:\ProgramData\ComposerSetup\bin\composer.phar help --format=xml list

  To display the list of available commands, please use the list command.

I can see C:\ProgramData\ComposerSetup\bin\composer.pharmy composer installation directory

At this time, the installation extension command is modified to

# php -d memory_limit=-1 php program set memory unlimited
# C:\ProgramData\ComposerSetup\bin\composer.phar composer install url
# require dcat/laravel-admin:"2.*" -vvv Loading expansion packs
php -d memory_limit=-1 C:\ProgramData\ComposerSetup\bin\composer.phar require dcat/laravel-admin:"2.*" -vvv

[PHP] Array to string conversion error when sending data in post

When using curl to pass post data, if the data field is an array, an error will be reported Array to string conversion

When calling curl_setopt_array($curl, $options);

Call curl_setopt($ch, CURLOPT_POSTFIELDS, $data)

Errors may be reported in these two places, the solution is to process the data array