Zend Framework - zf.bat文件生成命令行错误

时间:2022-06-01 21:58:49

I modified the code of zf.bat file according to my needs but it generates this error "An error has occurred! Action '*' is not a valid action" on all commands, How could I solve this?. Below is the Code of batch file :

我根据自己的需要修改了zf.bat文件的代码,但它生成了这个错误“发生错误!操作'*'对所有命令都不是一个有效的操作”,我怎么解决这个问题?以下是批处理文件的代码:

@ECHO off
REM Zend Framework
REM
REM LICENSE
REM
REM This source file is subject to the new BSD license that is bundled
REM with this package in the file LICENSE.txt.
REM It is also available through the world-wide-web at this URL:
REM http://framework.zend.com/license/new-bsd
REM If you did not receive a copy of the license and are unable to
REM obtain it through the world-wide-web, please send an email
REM to license@zend.com so we can send you a copy immediately.
REM
REM Zend
REM Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
REM http://framework.zend.com/license/new-bsd     New BSD License


REM Test to see if this was installed via pear
SET ZTMPZTMPZTMPZ=@ph
SET TMPZTMPZTMP=%ZTMPZTMPZTMPZ%p_bin@
REM below @php_bin@
FOR %%x IN ("@php_bin@") DO (if %%x=="%TMPZTMPZTMP%" GOTO :NON_PEAR_INSTALLED)

GOTO PEAR_INSTALLED

:NON_PEAR_INSTALLED
REM Assume php.exe is executable, and that zf.php will reside in the
REM same file as this one
SET PHP_BIN=php.exe
SET PHP_DIR=%c:\xampp\php
GOTO RUN

:PEAR_INSTALLED
REM Assume this was installed via PEAR and use replacements php_bin & php_dir
SET PHP_BIN=@php_bin@
SET PHP_DIR=@php_dir@
GOTO RUN

:RUN
SET ZF_SCRIPT=%PHP_DIR%\zf.php
"%PHP_BIN%" -d safe_mode=Off -f "%ZF_SCRIPT%" -- %*

I think the error is in last character of last line.

我认为错误是最后一行的最后一个字符。

EDIT: Code of Original FIle

编辑:原始代码

@ECHO off
REM Zend Framework
REM
REM LICENSE
REM
REM This source file is subject to the new BSD license that is bundled
REM with this package in the file LICENSE.txt.
REM It is also available through the world-wide-web at this URL:
REM http://framework.zend.com/license/new-bsd
REM If you did not receive a copy of the license and are unable to
REM obtain it through the world-wide-web, please send an email
REM to license@zend.com so we can send you a copy immediately.
REM
REM Zend
REM Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
REM http://framework.zend.com/license/new-bsd     New BSD License


REM Test to see if this was installed via pear
SET ZTMPZTMPZTMPZ=@ph
SET TMPZTMPZTMP=%ZTMPZTMPZTMPZ%p_bin@
REM below @php_bin@
FOR %%x IN ("@php_bin@") DO (if %%x=="%TMPZTMPZTMP%" GOTO :NON_PEAR_INSTALLED)

GOTO PEAR_INSTALLED

:NON_PEAR_INSTALLED
REM Assume php.exe is executable, and that zf.php will reside in the
REM same file as this one
SET PHP_BIN=php.exe
SET PHP_DIR=%~dp0
GOTO RUN

:PEAR_INSTALLED
REM Assume this was installed via PEAR and use replacements php_bin & php_dir
SET PHP_BIN=@php_bin@
SET PHP_DIR=@php_dir@
GOTO RUN

:RUN
SET ZF_SCRIPT=%PHP_DIR%\zf.php
"%PHP_BIN%" -d safe_mode=Off -f "%ZF_SCRIPT%" -- %*

EDIT: Snapshot of generated error by One Command Zend Framework  -  zf.bat文件生成命令行错误

编辑:One Command生成错误的快照

1 个解决方案

#1


0  

Change this line in your modified code:

在修改后的代码中更改此行:

SET PHP_DIR=%c:\xampp\php

To this:

SET "PHP_DIR=c:\xampp\php"

Edit - I just realized the extra % in your original modification is getting stripped out by the parser anyway, so the above suggestion couldn't help.

编辑 - 我刚刚意识到原始修改中的额外百分比无论如何都被解析器剥离了,所以上面的建议无济于事。


Restore the last line to its original form with %* at end - this should expand to all command line arguments. But it is not working for you. To find out why, add a new line ECHO ON immediately before the restored last line.

使用%*结尾将最后一行恢复为其原始形式 - 这应该扩展到所有命令行参数。但它不适合你。要找出原因,请在恢复的最后一行之前添加一行新的ECHO ON。

Now run the script and look at how the last line is being interpreted. If you can't figure out why it's not working, post the result.

现在运行脚本并查看最后一行的解释方式。如果你无法弄清楚它为什么不起作用,请发布结果。

#1


0  

Change this line in your modified code:

在修改后的代码中更改此行:

SET PHP_DIR=%c:\xampp\php

To this:

SET "PHP_DIR=c:\xampp\php"

Edit - I just realized the extra % in your original modification is getting stripped out by the parser anyway, so the above suggestion couldn't help.

编辑 - 我刚刚意识到原始修改中的额外百分比无论如何都被解析器剥离了,所以上面的建议无济于事。


Restore the last line to its original form with %* at end - this should expand to all command line arguments. But it is not working for you. To find out why, add a new line ECHO ON immediately before the restored last line.

使用%*结尾将最后一行恢复为其原始形式 - 这应该扩展到所有命令行参数。但它不适合你。要找出原因,请在恢复的最后一行之前添加一行新的ECHO ON。

Now run the script and look at how the last line is being interpreted. If you can't figure out why it's not working, post the result.

现在运行脚本并查看最后一行的解释方式。如果你无法弄清楚它为什么不起作用,请发布结果。