【问题标题】:How to disable xdebug during laravel installation via composer如何在通过作曲家安装 laravel 期间禁用 xdebug
【发布时间】:2016-12-29 02:27:19
【问题描述】:

我正在使用 composer 安装 laravel。但是在命令提示符屏幕中,“您正在运行带有 xdebug 启用的作曲家。这对运行时性能有重大影响。”此消息正在显示。我想在 laravel 安装期间禁用 xdebug。如果在我的系统中启用了 xdebug,有什么问题吗?

[]

【问题讨论】:

    标签: php laravel-5 xdebug


    【解决方案1】:

    在使用 Composer 安装依赖项之前,您应该在控制台的 php.ini 中暂时禁用 xdebug:

    # Set xdebug autostart to false
    xdebug.remote_autostart=0
    xdebug.remote_enable=0
    
    # Disable your profiller
    xdebug.profiler_enable=0
    

    并在composer install/composer update 完成时启用它。

    此外,如果您不想在每次使用 Composer 时在 php.ini 中启用/禁用它,您可以在控制台 PHP 文件中添加 xdebug_disable() 函数:

    if (function_exists('xdebug_disable')) {
        xdebug_disable();
    }
    

    【讨论】:

      【解决方案2】:

      我正在使用 Laravel Homestead,我创建了几个别名来快速打开/关闭 Xdebug,我在繁重的 composer 命令之前/之后使用它们,如下所示:

      $ xdebug_off # Disable Xdebug
        ...
      $ composer heavy-load stuff
        ...
      $ xdebug_on # Enable Xdebug
        ...
      

      一旦您进入您的盒子(在vagrant ssh 之后),请将这些别名添加到您的~/.profile 文件中:

      # Xdebug aliases
      alias xdebug_on='sudo phpenmod xdebug; sudo service php7.0-fpm restart;'
      alias xdebug_off='sudo phpdismod xdebug; sudo service php7.0-fpm restart;'
      

      如果你经常这样做,你可以使用我的快捷方式,在你的虚拟机上启动这个命令:

      curl -LsS https://git.io/vrc3y  >> ~/.profile; source ~/.profile
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-12-25
        • 2013-07-10
        • 2019-12-26
        • 2018-02-13
        • 2019-03-05
        • 2014-10-28
        相关资源
        最近更新 更多