mirror of
				https://github.com/shivammathur/setup-php.git
				synced 2025-10-31 07:16:22 +07:00 
			
		
		
		
	Fix xdebug and pcov on PHP7.4 and restructre code
This commit is contained in:
		
							
								
								
									
										60
									
								
								src/scripts/7.4.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								src/scripts/7.4.sh
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,60 @@ | ||||
| brew install pkg-config autoconf bison re2c openssl@1.1 krb5 bzip2 enchant libffi libpng webp freetype intltool icu4c libiconv zlib t1lib gd libzip gmp tidyp libxml2 libxslt postgresql curl mhash mcrypt >/dev/null 2>&1 | ||||
| brew link icu4c gettext bzip2 --force >/dev/null 2>&1 | ||||
|  | ||||
| for package in gettext gmp zlib bzip2 krb5 icu4c bison openssl@1.1 libxml2 libffi libxslt libiconv pkgconfig enchant krb5 readline libedit freetype; | ||||
| do | ||||
|   caps_package=$(echo "$package" | tr '[:lower:]' '[:upper:]') | ||||
|   { | ||||
|   echo 'export PATH="/usr/local/opt/'"$package"'/bin:$PATH"' | ||||
|   echo 'export PKG_CONFIG_PATH="/usr/local/opt/'$package'/lib/pkgconfig:$PKG_CONFIG_PATH"' | ||||
|   echo 'export '"$caps_package"'_LIBS="-L/usr/local/opt/'$package'/lib"' | ||||
|   echo 'export '"$caps_package"'_CFLAGS="-I/usr/local/opt/'$package'/include"' | ||||
|   } >> ~/.bash_profile; | ||||
| done | ||||
| { | ||||
| echo 'export ICONV_LIBS="-L/usr/local/opt/libiconv/lib"' | ||||
| echo 'export ICONV_CFLAGS="-I/usr/local/opt/libiconv/include"' | ||||
| echo 'export LIBXML_LIBS="-L/usr/local/opt/libxml2/lib"' | ||||
| echo 'export LIBXML_CFLAGS="-I/usr/local/opt/libxml2/include"' | ||||
| echo 'export ICU_LIBS="-L/usr/local/opt/icu4c/lib"' | ||||
| echo 'export ICU_CFLAGS="-I/usr/local/opt/icu4c/include"' | ||||
| echo 'export OPENSSL_LIBS="-L/usr/local/opt/openssl@1.1/lib -lcrypto"' | ||||
| echo 'export OPENSSL_CFLAGS="-I/usr/local/opt/openssl@1.1/include"' | ||||
| echo 'export OPENSSL_ROOT_DIR="/usr/local/opt/openssl@1.1/"' | ||||
| echo 'export OPENSSL_LIB_DIR="/usr/local/opt/openssl@1.1/lib"' | ||||
| echo 'export OPENSSL_INCLUDE_DIR="/usr/local/opt/openssl@1.1/include"' | ||||
| echo 'export PKG_CONFIG="/usr/local/opt/pkgconfig/bin/pkg-config"' | ||||
| echo 'export EXTRA_LIBS="/usr/local/opt/readline/lib/libhistory.dylib | ||||
| /usr/local/opt/readline/lib/libreadline.dylib | ||||
| /usr/local/opt/openssl@1.1/lib/libssl.dylib | ||||
| /usr/local/opt/openssl@1.1/lib/libcrypto.dylib | ||||
| /usr/local/opt/icu4c/lib/libicudata.dylib | ||||
| /usr/local/opt/icu4c/lib/libicui18n.dylib | ||||
| /usr/local/opt/icu4c/lib/libicuio.dylib | ||||
| /usr/local/opt/icu4c/lib/libicutu.dylib | ||||
| /usr/local/opt/icu4c/lib/libicuuc.dylib"' | ||||
| } >> ~/.bash_profile | ||||
| config_file=$(pwd)/config.yaml | ||||
| curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew >/dev/null 2>&1 | ||||
| chmod +x ./phpbrew | ||||
| sudo mv phpbrew /usr/local/bin/phpbrew | ||||
| sudo mkdir -p /opt/phpbrew | ||||
| sudo mkdir -p /usr/local/lib | ||||
| sudo mkdir -p /usr/local/bin | ||||
| sudo phpbrew init --root=/opt/phpbrew --config="$config_file" >/dev/null 2>&1 | ||||
| sudo chmod -R 777 /opt/phpbrew | ||||
| export PHPBREW_ROOT=/opt/phpbrew | ||||
| export PHPBREW_HOME=/opt/phpbrew | ||||
| echo "[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc" >> ~/.bashrc | ||||
| source ~/.bash_profile >/dev/null 2>&1 | ||||
| source ~/.bashrc >/dev/null 2>&1 | ||||
| phpbrew install -j 10 7.4.0RC3 +dev | ||||
| phpbrew switch 7.4.0RC3 | ||||
| sudo mkdir -p /usr/local/bin | ||||
| sudo ln -sf /opt/phpbrew/php/php-7.4.0RC3/bin/* /usr/local/bin/ | ||||
| sudo ln -sf /opt/phpbrew/php/php-7.4.0RC3/etc/php.ini /etc/php.ini | ||||
| ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g") | ||||
| ext_dir=$(php -i | grep "extension_dir => /opt" | sed -e "s|.*=> s*||") | ||||
| pecl config-set php_ini "$ini_file" | ||||
| sudo chmod 777 "$ini_file" | ||||
| brew install composer | ||||
							
								
								
									
										11
									
								
								src/scripts/darwin.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								src/scripts/darwin.sh
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | ||||
| export HOMEBREW_NO_INSTALL_CLEANUP=TRUE | ||||
| brew tap exolnet/homebrew-deprecated >/dev/null 2>&1 | ||||
| brew install php@"$1" composer >/dev/null 2>&1 | ||||
| brew link --force --overwrite php@"$1" >/dev/null 2>&1 | ||||
| ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g") | ||||
| ext_dir=$(/usr/bin/php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||") | ||||
| sudo chmod 777 "$ini_file" | ||||
| mkdir -p "$(pecl config-get ext_dir)" | ||||
| composer global require hirak/prestissimo >/dev/null 2>&1 | ||||
| php -v | ||||
| composer -V | ||||
							
								
								
									
										40
									
								
								src/scripts/linux.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								src/scripts/linux.sh
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,40 @@ | ||||
| version=$(php-config --version | cut -c 1-3) | ||||
| if [ "$version" != "$1" ]; then | ||||
| 	if [ ! -e "/usr/bin/php$1" ]; then | ||||
| 		sudo DEBIAN_FRONTEND=noninteractive add-apt-repository ppa:ondrej/php -y >/dev/null 2>&1 | ||||
| 		sudo DEBIAN_FRONTEND=noninteractive apt update -y >/dev/null 2>&1 | ||||
| 		sudo DEBIAN_FRONTEND=noninteractive apt install -y php"$1" curl php"$1"-curl >/dev/null 2>&1 | ||||
| 		if [ "$1" != "7.4" ]; then | ||||
| 		  sudo DEBIAN_FRONTEND=noninteractive apt install -y php"$1" curl php"$1"-curl >/dev/null 2>&1 | ||||
| 		else | ||||
| 		  sudo DEBIAN_FRONTEND=noninteractive apt install -y php"$1" php"$1"-dev curl php"$1"-curl >/dev/null 2>&1 | ||||
| 		fi | ||||
| 	fi | ||||
| 	for tool in php phar phar.phar php-cgi php-config phpize; do | ||||
| 		if [ -e "/usr/bin/$tool$1" ]; then | ||||
| 			sudo update-alternatives --set $tool /usr/bin/"$tool$1" | ||||
| 		fi | ||||
| 	done | ||||
| fi	 | ||||
|  | ||||
| if [ ! -e "/usr/bin/composer" ]; then | ||||
| 	EXPECTED_SIGNATURE="$(curl -s https://composer.github.io/installer.sig)" | ||||
| 	curl -s -L https://getcomposer.org/installer > composer-setup.php | ||||
| 	ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" | ||||
|  | ||||
| 	if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]; then | ||||
| 		>&2 echo 'ERROR: Invalid installer signature'		 | ||||
| 	else | ||||
| 		COMPOSER_ALLOW_SUPERUSER=1 | ||||
| 		sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer	 | ||||
| 	fi | ||||
| 	rm composer-setup.php	 | ||||
| fi | ||||
|  | ||||
| composer global require hirak/prestissimo >/dev/null 2>&1 | ||||
| ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g") | ||||
| ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||") | ||||
| sudo chmod 777 "$ini_file" | ||||
| sudo mkdir -p /run/php | ||||
| php -v | ||||
| composer -V | ||||
							
								
								
									
										7
									
								
								src/scripts/pcov.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/scripts/pcov.sh
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | ||||
| git clone --depth=1 https://github.com/krakjoe/pcov.git | ||||
| ( | ||||
| cd pcov && phpize | ||||
| ./configure --enable-pcov | ||||
| make | ||||
| sudo make install | ||||
| ) | ||||
							
								
								
									
										41
									
								
								src/scripts/win32.ps1
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								src/scripts/win32.ps1
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,41 @@ | ||||
| param ( | ||||
|     [Parameter(Mandatory=$true)][string]$version = "7.3"   | ||||
| ) | ||||
|  | ||||
| if($version -eq '7.4') { | ||||
| 	$version = '7.4RC' | ||||
| } | ||||
|  | ||||
| echo "Installing PhpManager" | ||||
| Install-Module -Name PhpManager -Force -Scope CurrentUser | ||||
|  | ||||
| $installed = $($(php -v)[0] -join '')[4..6] -join '' | ||||
| if($installed -ne $version) { | ||||
|   if($version -lt '7.0') { | ||||
|     echo "Installing VcRedist" | ||||
|     Install-Module -Name VcRedist -Force | ||||
|   } | ||||
|   echo "Installing PHP" | ||||
|   Uninstall-Php C:\tools\php | ||||
|   Install-Php -Version $version -Architecture x86 -ThreadSafe $true -InstallVC -Path C:\tools\php$version -TimeZone UTC -InitialPhpIni Production -Force | ||||
|   echo "Switch PHP" | ||||
|   (Get-PhpSwitcher).targets | ||||
|   Initialize-PhpSwitcher -Alias C:\tools\php -Scope CurrentUser -Force | ||||
|   Add-PhpToSwitcher -Name $version -Path C:\tools\php$version -Force | ||||
|   Switch-Php $version -Force | ||||
| } | ||||
|  | ||||
| echo "Housekeeping in PHP.ini, enabling openssl" | ||||
| Add-Content C:\tools\php\php.ini "date.timezone = 'UTC'" | ||||
| Set-PhpIniKey extension_dir C:\tools\php\ext | ||||
| if($version -lt '7.4') { | ||||
|   Enable-PhpExtension openssl | ||||
| } else { | ||||
|   Add-Content C:\tools\php\php.ini "extension=php_openssl.dll" | ||||
| } | ||||
|  | ||||
| echo "Installing Composer" | ||||
| Install-Composer -Scope System -Path C:\tools\php | ||||
| $ext_dir = Get-PhpIniKey extension_dir | ||||
| php -v | ||||
| composer -V | ||||
							
								
								
									
										5
									
								
								src/scripts/xdebug.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/scripts/xdebug.sh
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,5 @@ | ||||
| git clone --depth=1 https://github.com/xdebug/xdebug.git | ||||
| ( | ||||
|   cd xdebug || echo "cd failed" | ||||
|   sudo ./rebuild.sh | ||||
| ) | ||||
							
								
								
									
										8
									
								
								src/scripts/xdebug_darwin.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/scripts/xdebug_darwin.sh
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | ||||
| git clone --depth=1 https://github.com/xdebug/xdebug.git | ||||
| ( | ||||
|   cd xdebug || echo "cd failed" | ||||
|   sudo phpize | ||||
|   sudo ./configure | ||||
|   sudo make | ||||
|   sudo cp modules/xdebug.so "$(php -i | grep "extension_dir => /opt" | sed -e "s|.*=> s*||")" | ||||
| ) | ||||
		Reference in New Issue
	
	Block a user
	 Shivam Mathur
					Shivam Mathur