php Class 在 mac 上找不到 Redis

php Class Redis not found on mac

Php版本: enter image description here

当我请求我的 CodeIgniter 项目的接口之一并回显 phpinfo() 时,message.And 中没有 redis 扩展,项目加载了错误版本的 php 喜欢: enter image description here

是的,我的 MacOS 中有多个版本的 php。 谁能帮我解决这个问题?

我的项目有这个错误消息:

 ERROR - 2019-01-09 04:18:05 --> Exception:Error::__set_state(array(
   'message' => 'Class \'Redis\' not found',
   'string' => '',
   'code' => 0,
   'file' => '/Users/charlie/IdeaProjects/my_project/src/application/libraries/My_Redis.php',
   'line' => 93,
   'trace' => 
  array (
    0 => 
    array (
      'file' => '/Users/charlie/IdeaProjects/my_project/src/application/libraries/My_Redis.php',
      'line' => 51,
      'function' => '_init',
      'class' => 'My_Redis',
      'type' => '->',
      'args' => 
      array (
        0 => 
        array (
          'host' => '',
          'port' => 6379,
          'password' => '',
          'timeout' => 2,
          'persistent' => 0,
        ),
      ),
    ),
    1 => 
    array (
      'file' => '/Users/charlie/IdeaProjects/my_project/src/application/libraries/My_Redis.php',
      'line' => 35,
      'function' => 'getInstance',
      'class' => 'My_Redis',
      'type' => '->',
      'args' => 
      array (
        0 => 'supply_chain_busi',
      ),
    ),
    2 => 
    array (
      'file' => '/Users/charlie/IdeaProjects/my_project/src/system/core/Loader.php',
      'line' => 1095,
      'function' => '__construct',
      'class' => 'My_Redis',
      'type' => '->',
      'args' => 
      array (
        0 => 'supply_chain_busi',
      ),
    ),
    3 => 
    array (
      'file' => '/Users/charlie/IdeaProjects/my_project/src/system/core/Loader.php',
      'line' => 975,
      'function' => '_ci_init_class',
      'class' => 'CI_Loader',
      'type' => '->',
      'args' => 
      array (
        0 => 'my_redis',
        1 => '',
        2 => 
        array (
          0 => 'supply_chain_busi',
        ),
        3 => 'redis',
      ),
    ),
    4 => 
    array (
      'file' => '/Users/charlie/IdeaProjects/my_project/src/system/core/Loader.php',
      'line' => 216,
      'function' => '_ci_load_class',
      'class' => 'CI_Loader',
      'type' => '->',
      'args' => 
      array (
        0 => 'My_Redis',
        1 => 
        array (
          0 => 'supply_chain_busi',
        ),
        2 => 'redis',
      ),
    ),
    5 => 
    array (
      'file' => '/Users/charlie/IdeaProjects/my_project/src/application/libraries/Tank_auth.php',
      'line' => 45,
      'function' => 'library',
      'class' => 'CI_Loader',
      'type' => '->',
      'args' => 
      array (
        0 => 'My_Redis',
        1 => 
        array (
          0 => 'supply_chain_busi',
        ),
        2 => 'redis',
      ),
    ),
    6 => 
    array (
      'file' => '/Users/charlie/IdeaProjects/my_project/src/system/core/Loader.php',
      'line' => 1095,
      'function' => '__construct',
      'class' => 'Tank_auth',
      'type' => '->',
      'args' => 
      array (
        0 => 
        array (
          'website_name' => 'mycom',
          'webmaster_email' => 'webmaster@mycom.com',
          'phpass_hash_portable' => true,
          'phpass_hash_strength' => 8,
          'allow_registration' => false,
          'captcha_registration' => false,
          'email_activation' => false,
          'email_activation_expire' => 172800,
          'email_account_details' => true,
          'use_username' => true,
          'username_min_length' => 4,
          'username_max_length' => 20,
          'password_min_length' => 4,
          'password_max_length' => 20,
          'login_by_username' => true,
          'login_by_email' => true,
          'login_record_ip' => true,
          'login_record_time' => true,
          'login_count_attempts' => true,
          'login_max_attempts' => 99,
          'login_attempt_expire' => 86400,
          'autologin_cookie_name' => 'autologin',
          'autologin_cookie_life' => 2592000,
          'forgot_password_expire' => 900,
          'captcha_path' => 'captcha/',
          'captcha_fonts_path' => 'captcha/fonts/5.ttf',
          'captcha_width' => 200,
          'captcha_height' => 50,
          'captcha_font_size' => 14,
          'captcha_grid' => false,
          'captcha_expire' => 180,
          'captcha_case_sensitive' => false,
          'use_recaptcha' => false,
          'recaptcha_public_key' => '',
          'recaptcha_private_key' => '',
          'db_table_prefix' => '',
        ),
      ),
    ),
    7 => 
    array (
      'file' => '/Users/charlie/IdeaProjects/my_project/src/system/core/Loader.php',
      'line' => 975,
      'function' => '_ci_init_class',
      'class' => 'CI_Loader',
      'type' => '->',
      'args' => 
      array (
        0 => 'tank_auth',
        1 => '',
        2 => 
        array (
          'website_name' => 'mycom',
          'webmaster_email' => 'webmaster@mycom.com',
          'phpass_hash_portable' => true,
          'phpass_hash_strength' => 8,
          'allow_registration' => false,
          'captcha_registration' => false,
          'email_activation' => false,
          'email_activation_expire' => 172800,
          'email_account_details' => true,
          'use_username' => true,
          'username_min_length' => 4,
          'username_max_length' => 20,
          'password_min_length' => 4,
          'password_max_length' => 20,
          'login_by_username' => true,
          'login_by_email' => true,
          'login_record_ip' => true,
          'login_record_time' => true,
          'login_count_attempts' => true,
          'login_max_attempts' => 99,
          'login_attempt_expire' => 86400,
          'autologin_cookie_name' => 'autologin',
          'autologin_cookie_life' => 2592000,
          'forgot_password_expire' => 900,
          'captcha_path' => 'captcha/',
          'captcha_fonts_path' => 'captcha/fonts/5.ttf',
          'captcha_width' => 200,
          'captcha_height' => 50,
          'captcha_font_size' => 14,
          'captcha_grid' => false,
          'captcha_expire' => 180,
          'captcha_case_sensitive' => false,
          'use_recaptcha' => false,
          'recaptcha_public_key' => '',
          'recaptcha_private_key' => '',
          'db_table_prefix' => '',
        ),
        3 => NULL,
      ),
    ),
    8 => 
    array (
      'file' => '/Users/charlie/IdeaProjects/my_project/src/system/core/Loader.php',
      'line' => 216,
      'function' => '_ci_load_class',
      'class' => 'CI_Loader',
      'type' => '->',
      'args' => 
      array (
        0 => 'Tank_auth',
        1 => NULL,
        2 => NULL,
      ),
    ),
    9 => 
    array (
      'file' => '/Users/charlie/IdeaProjects/my_project/src/system/core/Loader.php',
      'line' => 1178,
      'function' => 'library',
      'class' => 'CI_Loader',
      'type' => '->',
      'args' => 
      array (
        0 => 'Tank_auth',
      ),
    ),
    10 => 
    array (
      'file' => '/Users/charlie/IdeaProjects/my_project/src/system/core/Loader.php',
      'line' => 152,
      'function' => '_ci_autoloader',
      'class' => 'CI_Loader',
      'type' => '->',
      'args' => 
      array (
      ),
    ),
    11 => 
    array (
      'file' => '/Users/charlie/IdeaProjects/my_project/src/system/core/Controller.php',
      'line' => 51,
      'function' => 'initialize',
      'class' => 'CI_Loader',
      'type' => '->',
      'args' => 
      array (
      ),
    ),
    12 => 
    array (
      'file' => '/Users/charlie/IdeaProjects/my_project/src/application/libraries/REST_Controller.php',
      'line' => 197,
      'function' => '__construct',
      'class' => 'CI_Controller',
      'type' => '->',
      'args' => 
      array (
      ),
    ),
    13 => 
    array (
      'file' => '/Users/charlie/IdeaProjects/my_project/src/application/controllers/api/my_project.php',
      'line' => 11,
      'function' => '__construct',
      'class' => 'REST_Controller',
      'type' => '->',
      'args' => 
      array (
      ),
    ),
    14 => 
    array (
      'file' => '/Users/charlie/IdeaProjects/my_project/src/system/core/CodeIgniter.php',
      'line' => 310,
      'function' => '__construct',
      'class' => 'my_project',
      'type' => '->',
      'args' => 
      array (
      ),
    ),
    15 => 
    array (
      'file' => '/Users/charlie/IdeaProjects/my_project/src/index.php',
      'line' => 204,
      'args' => 
      array (
        0 => '/Users/charlie/IdeaProjects/my_project/src/system/core/CodeIgniter.php',
      ),
      'function' => 'require_once',
    ),
  ),
   'previous' => NULL,
))

日志的其余部分 similar.It 只是找不到 Redis class。

好的,最后我解决了it.Just用brew安装它:

*brew install --without-apache --with-fpm --with-mysql --with-redis --with-curl --with-intl --with-iconv php72

回显 'export PATH="/usr/local/opt/php@7.2/bin:$PATH"' >> ~/.bash_profile echo 'export PATH="/usr/local/opt/php@7.2/sbin:$PATH"' >> ~/.bash_profile 来源 ~/.bash_profile

*

我不知道这些选项是否正确,但我确实正确安装了我的 php 以及我需要的所有扩展。