我在推进ORM配置过程中遇到问题。
我按照以下规定文件在 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: �phpr’: No such file or directory
我该怎么做才能解决它?
编辑:我运行的文件(未编辑,通过作曲家安装(:
#!/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" "$@"
我不使用propel,但在phpunit上遇到了同样的问题。
问题通常是 vendor/propel/propel/bin/propel
,或者在我的情况下,您尝试执行的vendor/phpunit/phpunit/phpunit
文件是 Windows 编码的而不是 Unix 编码的。当您在 Windows 上执行作曲家安装/更新但在流浪框中运行代码时,就会发生这种情况。
您有多种方法可以摆脱 CRLF:
- dos2unix 命令 (
sudo apt-get install dos2unix
( - 使用你喜欢的文本编辑器(Sublime,PHPStorm,他们都可以做到这一点(
- 摆脱
vendor
并从您的流浪者框中运行作曲家安装/更新
请记住,问题不在于vendor/bin/propel
文件,而在于vendor/propel/propel/bin/propel
文件。
希望这有帮助!