PHP CLI 在 WampServer 中已停止工作

PHP CLI 在 WampServer 中已停止工作

当我php -v从命令行启动时,会出现一个弹出窗口CLI has stopped working,提示我正在使用wamp服务器2.5 和 Windows 8.1 上的 PHP 版本 5.5.12。因此,我无法安装 Composer 并完成任何编码工作。

php 错误日志为空白

我在事件查看器中收到此错误。

Faulting application name: php.exe, version: 5.6.25.0, time stamp: 0x57b60174
Faulting module name: ntdll.dll, version: 6.3.9600.18438, time stamp: 0x57ae642e
Exception code: 0xc0000005
Fault offset: 0x0000000000030c57
Faulting process ID: 0x2e70
Faulting application start time: 0x01d2aa27475e178b
Faulting application path: C:\wamp\bin\php\php5.6.25\php.exe
Faulting module path: C:\WINDOWS\SYSTEM32\ntdll.dll
Report ID: 870dbe02-161a-11e7-8263-38b1dbf6d8ea
Faulting package full name:
Faulting package-relative application ID:

Faulting application name: php-win.exe, version: 5.6.25.0, time stamp: 0x57b60195
Faulting module name: ntdll.dll, version: 6.3.9600.18438, time stamp: 0x57ae642e
Exception code: 0xc0000005
Fault offset: 0x0000000000030c57
Faulting process ID: 0x2f1c
Faulting application start time: 0x01d2aa0cab8c6362
Faulting application path: c:\wamp\bin\php\php5.6.25\php-win.exe
Faulting module path: C:\WINDOWS\SYSTEM32\ntdll.dll
Report ID: f3184580-15ff-11e7-8263-38b1dbf6d8ea
Faulting package full name:

发生了什么事?请帮忙。

答案1

正如你所说,你使用的是 PHP 版本 5.5.12,但错误消息描述了PHP5.6.25

检查你的 PATH。

我猜你PHP5.6.25不久前就添加了一个。

你永远不应该在 WAMPServer 上将 PHP 文件夹添加到您的 PATH,因为您可以在 WAMPServer 上安装多个版本的 PHP,并且仅指定一个版本会限制 WAMPServers 的即时灵活性。

而是创建一个.cmd文件并将其保存在已经在 PATH 上的文件夹中(因此您不需要在路径中添加任何新内容)

这是我的一个示例,如果您需要的话,它包含 PHP 版本、Composer 和 PEAR。

@echo off

REM **************************************************************
REM * PLACE This file in a folder that is already on your PATH
REM * Or just put it in your C:\Windows folder as that is on the
REM * Serch path by default
REM * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
REM * EDIT THE NEXT 3 Parameters to fit your installed WAMPServer
REM **************************************************************

REM The folder WAMPServer is installed in
set baseWamp=C:\wamp
REM Pick a default version so you can call this without specifying
set defaultPHPver=5.6.15
REM Comment out if composer is not installed
set composerInstalled=%baseWamp%\composer
REM leave this alone
set phpFolder=\bin\php\php

if %1.==. (
    set phpver=%baseWamp%%phpFolder%%defaultPHPver%
) else (
    set phpver=%baseWamp%%phpFolder%%1
)

PATH=%PATH%;%phpver%
php -v
echo ---------------------------------------------------------------


REM IF PEAR IS INSTALLED IN THIS VERSION OF PHP

IF exist %phpver%\pear (
    set PHP_PEAR_SYSCONF_DIR=D:\wamp\bin\php\php%phpver%
    set PHP_PEAR_INSTALL_DIR=D:\wamp\bin\php\php%phpver%\pear
    set PHP_PEAR_DOC_DIR=D:\wamp\bin\php\php%phpver%\docs
    set PHP_PEAR_BIN_DIR=D:\wamp\bin\php\php%phpver%
    set PHP_PEAR_DATA_DIR=D:\wamp\bin\php\php%phpver%\data
    set PHP_PEAR_PHP_BIN=D:\wamp\bin\php\php%phpver%\php.exe
    set PHP_PEAR_TEST_DIR=D:\wamp\bin\php\php%phpver%\tests

    echo PEAR INCLUDED IN THIS CONFIG
    echo ---------------------------------------------------------------
) else (
    echo PEAR DOES NOT EXIST IN THIS VERSION OF php
    echo ---------------------------------------------------------------
)

REM IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM **************************************************************
REM * IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM * 
REM * This assumes that composer is installed in /wamp/composer
REM * 
REM **************************************************************
IF EXIST %composerInstalled% (
    ECHO COMPOSER INCLUDED IN THIS CONFIG
    echo ---------------------------------------------------------------
    set COMPOSER_HOME=%baseWamp%\composer
    set COMPOSER_CACHE_DIR=%baseWamp%\composer

    PATH=%PATH%;%baseWamp%\composer

    rem echo TO UPDATE COMPOSER do > composer self-update
    echo ---------------------------------------------------------------
) else (
    echo ---------------------------------------------------------------
    echo COMPOSER IS NOT INSTALLED
    echo ---------------------------------------------------------------
)

set baseWamp=
set defaultPHPver=
set composerInstalled=
set phpFolder=

然后像这样调用

> phppath 7.1.3

并且它应该只对您的 PATH 进行临时修改,这些修改仅在命令窗口存在期间存在。

相关内容