Add support for PHP 8.0.0-dev #104

This commit is contained in:
Shivam Mathur
2019-12-09 08:09:03 +05:30
parent 14acb26bdc
commit 1cf6a369bb
11 changed files with 156 additions and 108 deletions

View File

@ -42,7 +42,7 @@ export async function build(
export async function run(): Promise<void> {
try {
const os_version: string = process.platform;
const version: string = await utils.getVersion();
const version: string = await utils.getInput('php-version', true);
// check the os version and run the respective script
let script_path = '';
switch (os_version) {
@ -58,9 +58,7 @@ export async function run(): Promise<void> {
}
case 'win32':
script_path = await build('win32.ps1', version, os_version);
await exec(
'pwsh ' + script_path + ' -version ' + version + ' -dir ' + __dirname
);
await exec('pwsh ' + script_path + ' -version ' + version);
break;
}
} catch (error) {

View File

@ -29,7 +29,8 @@ ext_dir=$(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
add_log "$tick" "PHP" "Installed PHP $(php -v | head -n 1 | cut -c 5-10)"
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
add_log "$tick" "PHP" "Installed PHP $semver"
add_log "$tick" "Composer" "Installed"
add_extension() {
@ -46,10 +47,10 @@ add_extension() {
(
eval "$install_command" && \
add_log "$tick" "$extension" "Installed and enabled"
) || add_log "$cross" "$extension" "Could not install $extension on PHP$version"
) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
else
if ! php -m | grep -i -q "$extension"; then
add_log "$cross" "$extension" "Could not find $extension for PHP$version on PECL"
add_log "$cross" "$extension" "Could not find $extension for PHP $semver on PECL"
fi
fi
fi

View File

@ -17,35 +17,46 @@ add_log() {
fi
}
existing_version=$(php-config --version | cut -c 1-3)
version=$1
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
step_log "Setup PHP and Composer"
sudo mkdir -p /var/run
sudo mkdir -p /run/php
find /etc/apt/sources.list.d -type f -name 'ondrej-ubuntu-php*.list' -exec sudo DEBIAN_FRONTEND=noninteractive apt-fast update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1
if [ "$existing_version" != "$1" ]; then
if [ ! -e "/usr/bin/php$1" ]; then
if [ "$1" != "7.4" ]; then
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$1" curl php"$1"-curl >/dev/null 2>&1
else
if [ "$1" = "7.4" ]; then
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$1" php"$1"-phpdbg php"$1"-xml curl php"$1"-curl >/dev/null 2>&1
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
elif [ "$1" = "8.0" ]; then
tar_file=php_"$1"%2Bubuntu"$(lsb_release -r -s)".tar.xz
install_dir=~/php/"$1"
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install libicu-dev >/dev/null 2>&1
curl -o "$tar_file" -L https://bintray.com/shivammathur/php/download_file?file_path="$tar_file" >/dev/null 2>&1
sudo mkdir -m 777 -p ~/php
sudo tar xf "$tar_file" -C ~/php >/dev/null 2>&1 && rm -rf "$tar_file"
sudo ln -sf -S "$1" "$install_dir"/bin/* /usr/bin/ && sudo ln -sf "$install_dir"/etc/php.ini /etc/php.ini
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
else
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$1" curl php"$1"-curl >/dev/null 2>&1
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
fi
status="installed"
else
status="switched"
fi
for tool in php phar phar.phar php-cgi php-config phpize phpdbg; do
for tool in pear pecl php phar phar.phar php-cgi php-config phpize phpdbg; do
if [ -e "/usr/bin/$tool$1" ]; then
sudo update-alternatives --set $tool /usr/bin/"$tool$1" >/dev/null 2>&1
fi
done
if [ "$status" != "switched" ]; then
status="Installed PHP $(php -v | head -n 1 | cut -c 5-10)"
status="Installed PHP $semver"
else
status="Switched to PHP $(php -v | head -n 1 | cut -c 5-10)"
status="Switched to PHP $semver"
fi
else
status="PHP $(php -v | head -n 1 | cut -c 5-10) Found"
status="PHP $semver Found"
fi
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
@ -88,6 +99,6 @@ add_extension()
(
eval "$install_command" && \
add_log "$tick" "$extension" "Installed and enabled"
) || add_log "$cross" "$extension" "Could not install $extension on php$version"
) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
fi
}

View File

@ -1,6 +1,5 @@
param (
[Parameter(Mandatory = $true)][string]$version = "7.3",
[Parameter(Mandatory = $true)][string]$dir
[Parameter(Mandatory = $true)][string]$version = "7.3"
)
$tick = ([char]8730)
@ -16,6 +15,10 @@ Function Add-Log($mark, $subject, $message) {
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $code $mark $subject $message
}
if ($version -eq '8.0') {
$version = '7.4'
}
Step-Log "Setup PhpManager"
Install-Module -Name PhpManager -Force -Scope CurrentUser
Add-Log $tick "PhpManager" "Installed"
@ -85,6 +88,6 @@ Function Add-Extension {
}
}
catch {
Add-Log $cross $extension "Could not enable"
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
}
}

View File

@ -22,24 +22,6 @@ export async function getInput(
}
}
/**
* Function to read the PHP version.
*/
export async function getVersion(): Promise<string> {
const version: string = await getInput('php-version', true);
switch (version) {
case '8.0':
case '8.0-dev':
case '7.4':
case '7.4snapshot':
case '7.4nightly':
case 'nightly':
return '7.4';
default:
return version;
}
}
/**
* Async foreach loop
*