0


我在 Propel ORM 配置过程中遇到问题。
我按照这个配置文件在我的 Vagrant 上使用 PHP 7.1 准备了环境:

# Install software
add-apt-repository ppa:ondrej/php
apt update
apt install python-software-properties
apt update

apt install -y apache2
apt install -y php
apt install -y php-mcrypt
apt install -y php-mysql
apt install -y php-curl
apt install -y php-cli
apt install -y php-xml
apt install -y libapache2-mod-php
apt install -y mc

# install composer, configure Apache and create database

service apache2 restart
/etc/init.d/mysql restart

目前我想安装 Propel ORM。我将 Propel 添加到作曲家,安装,现在我输入(通过 Vagrant 中的 SSH) /var/www/application/Vendors/bin/propel init但不幸的是我收到错误:

/usr/bin/env: �php\r’: No such file or directory

我能做些什么来解决它?

编辑: 我运行的文件(未编辑,通过 Composer 安装):

#!/usr/bin/env sh

dir=$(d=${0%[/\\]*}; cd "$d"; cd "../propel/propel/bin" && pwd)

# See if we are running in Cygwin by checking for cygpath program
if command -v 'cygpath' >/dev/null 2>&1; then
    # Cygwin paths start with /cygdrive/ which will break windows PHP,
    # so we need to translate the dir path to windows format. However
    # we could be using cygwin PHP which does not require this, so we
    # test if the path to PHP starts with /cygdrive/ rather than /usr/bin
    if [[ $(which php) == /cygdrive/* ]]; then
        dir=$(cygpath -m "$dir");
    fi
fi

dir=$(echo $dir | sed 's/ /\ /g')
"${dir}/propel" "$@"
4

1 回答 1

1

我不使用推进器,但与 phpunit 有同样的问题。

问题通常是vendor/propel/propel/bin/propel,或者在我的情况下,vendor/phpunit/phpunit/phpunit您尝试执行的文件是 Windows 编码的,而不是 Unix 编码的。当您在 Windows 上执行 composer install/update 但在 vagrant box 中运行您的代码时,就会发生这种情况。

您有多种摆脱 CRLF 的方法:

  1. dos2unix 命令 ( sudo apt-get install dos2unix)
  2. 使用您喜欢的文本编辑器(Sublime、PHPStorm,它们都可以做到)
  3. vendor从您的 vagrant box 中删除并运行 composer install/update

请记住,问题不是vendor/bin/propel文件而是vendor/propel/propel/bin/propel文件。

希望这有帮助!

于 2017-09-20T23:40:53.657 回答