Outdated installation errors

I am trying to install PEAR on OS X using the PHP 5.3 built-in installation. I have done this:

curl http://pear.php.net/go-pear > go-pear.php
php go-pear.php

After answering some tips, I start to get a lot of errors, for example:

Deprecated: Assigning the return value of new by reference is deprecated in /Users/username/bin/pear/temp/PEAR.php on line 563
PHP Deprecated:  Assigning the return value of new by reference is deprecated in /Users/username/bin/pear/temp/PEAR.php on line 566

Now I understand what these errors mean. I just want to hide them. So in my file /private/etc/php.iniI have the following:

error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED

This hides the same errors in my own code. But in PEAR this is not so. They seem to change the error_reporting level.

Is there a good way to fix this?

+3
source share
4 answers

@kguest

I could not find "php_ini" in the configuration list.

@JW

, PEAR: /usr/share/pear/pearcmd.php, , error_handler :

if ($errno & error_reporting()) {
     $errortype = array (
        E_ERROR   =>  "Error",
        E_WARNING   =>  "Warning",
        E_PARSE   =>  "Parsing Error",
        E_NOTICE   =>  "Notice",
        E_CORE_ERROR  =>  "Core Error",
        E_CORE_WARNING  =>  "Core Warning",
        E_COMPILE_ERROR  =>  "Compile Error",
        E_COMPILE_WARNING =>  "Compile Warning",
        E_USER_ERROR =>  "User Error",
        E_USER_WARNING =>  "User Warning",
        E_USER_NOTICE =>  "User Notice"
    );
    $prefix = $errortype[$errno];
    global $_PEAR_PHPDIR;
    if (stristr($file, $_PEAR_PHPDIR)) {
        $file = substr($file, strlen($_PEAR_PHPDIR) + 1);
    } else {
        $file = basename($file);
    }
    print "\n$prefix: $errmsg in $file on line $line\n";
}

PEAR php.ini. ( peclcmd.php)

,

$GLOBALS['config']->get('verbose') < 4

, PEAR, ( FATAL ERROR ).

, PEAR, , .

+2

, PEAR PHP 5.3, PHP 5.3, , .

, PEAR , PHP , INI display_errors "report_errors" ( , ).

, . , pearcmd.php, PEAR print "..." ( error_handler) file_put_contents("php://stderr","..."); ( ... ). , - , 2>/dev/null , , .

+2

, :

$pear config-set php_ini /private/etc/php.ini 

,

$pear config-get php_ini

$pear config-show
0

, PEAR ( , ). , .

My solution is to set the value error_reportingin php.ini only to display real (fatal) errors and to configure this value in your own application. For better behavior, you must, of course, do this first. Something like that:

<?php
  // include required PEAR classes
  require_once('PEAR.php');

  class Application() {

      public static main() {
          // get $errlevel value from some sort of configuration
          error_reporting($errlevel);
      }

  }

  $myApp = Application::main();

?> 
0
source

Source: https://habr.com/ru/post/1744856/


All Articles