YanKyawMin
YanKyawMin

Reputation: 25

Cannot redeclare __() (previously declared in /usr/local/src/master/xxx/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php:952)

  1. PHP version :
PHP 8.1.23 (cli) (built: Sep 15 2023 21:56:29) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.23, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.23, Copyright (c), by Zend Technologies
  1. runkit7 version: 4.0.0a6 Screen Shot 2023-10-20 at 15 48 28

  2. OS version and compiler version

NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="aaaa:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"
  1. Problem is : runkit7_function_remove() is not working. 502 error occur in nginx error log. Sample code:
        $user = Auth::user();
        error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED);
        try {
          // Remove the function of laravel helper *__* function
          if (function_exists('__')) {
                runkit7_function_remove('__');
          }
        }catch(\Exception $e){
           Log::debug($e->message);
        }
        define('WP_USE_THEMES', true);
        require(public_path() . '/wp/wp-blog-header.php');
  1. I want to remove laravel helper function because of Laravel helper function and WordPress function conflict.

in wordpress: __ function is in public/wp/wp-includes/l10n.php.[link]

in laravel : __function is in vendor/laravel/framework/src/Illuminate/Foundation/helpers.php [link]

Upvotes: 0

Views: 177

Answers (1)

YanKyawMin
YanKyawMin

Reputation: 25

I want to close the issue. Finally, I get the ans.

I edit the line WP's l10n.php to before line of laravel's autoload.php calling in public/index.php

i.e: in Laravel's public/index.php,

require __DIR__. '/wp/wp-includes/l10n.php';

require __DIR__.'/../vendor/autoload.php';

Upvotes: 0

Related Questions