Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
devcontainer-features
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eazydevelop-devcontainer-temp
devcontainer-features
Commits
36d7664e
Unverified
Commit
36d7664e
authored
Feb 07, 2023
by
Samruddhi Khandale
Committed by
GitHub
Feb 07, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHP: Allow 'version:none' (#439)
* PHP: Allow 'version:none' * fix tests
parent
c997f9af
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
87 additions
and
53 deletions
+87
-53
devcontainer-feature.json
src/php/devcontainer-feature.json
+3
-2
install.sh
src/php/install.sh
+60
-50
install_additional_php.sh
test/php/install_additional_php.sh
+2
-0
install_only_composer.sh
test/php/install_only_composer.sh
+10
-0
install_php_8.sh
test/php/install_php_8.sh
+1
-0
install_php_8_2.sh
test/php/install_php_8_2.sh
+1
-0
scenarios.json
test/php/scenarios.json
+9
-0
test.sh
test/php/test.sh
+1
-1
No files found.
src/php/devcontainer-feature.json
View file @
36d7664e
{
{
"id"
:
"php"
,
"id"
:
"php"
,
"version"
:
"1.1.
1
"
,
"version"
:
"1.1.
2
"
,
"name"
:
"PHP"
,
"name"
:
"PHP"
,
"documentationURL"
:
"https://github.com/devcontainers/features/tree/main/src/php"
,
"documentationURL"
:
"https://github.com/devcontainers/features/tree/main/src/php"
,
"options"
:
{
"options"
:
{
...
@@ -10,7 +10,8 @@
...
@@ -10,7 +10,8 @@
"latest"
,
"latest"
,
"8"
,
"8"
,
"8.2"
,
"8.2"
,
"8.2.0"
"8.2.0"
,
"none"
],
],
"default"
:
"latest"
,
"default"
:
"latest"
,
"description"
:
"Select or enter a PHP version"
"description"
:
"Select or enter a PHP version"
...
...
src/php/install.sh
View file @
36d7664e
...
@@ -123,38 +123,13 @@ find_version_from_git_tags() {
...
@@ -123,38 +123,13 @@ find_version_from_git_tags() {
# Install PHP Composer
# Install PHP Composer
addcomposer
()
{
addcomposer
()
{
"
${
PHP_
INSTALL_DIR
}
/bin/php
"
-r
"copy('https://getcomposer.org/installer', 'composer-setup.php');"
"
${
PHP_
SRC
}
"
-r
"copy('https://getcomposer.org/installer', 'composer-setup.php');"
HASH
=
"
$(
wget
-q
-O
- https://composer.github.io/installer.sig
)
"
HASH
=
"
$(
wget
-q
-O
- https://composer.github.io/installer.sig
)
"
"
${
PHP_INSTALL_DIR
}
/bin/php"
-r
"if (hash_file('sha384', 'composer-setup.php') === '
$HASH
') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
"
${
PHP_SRC
}
"
-r
"if (hash_file('sha384', 'composer-setup.php') === '
$HASH
') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
"
${
PHP_INSTALL_DIR
}
/bin/php"
composer-setup.php
"
${
PHP_SRC
}
"
composer-setup.php
--install-dir
=
"/usr/local/bin"
--filename
=
composer
"
${
PHP_INSTALL_DIR
}
/bin/php"
-r
"unlink('composer-setup.php');"
"
${
PHP_SRC
}
"
-r
"unlink('composer-setup.php');"
mv
composer.phar
"
${
PHP_INSTALL_DIR
}
/bin/composer"
}
}
# Install PHP if it's missing
# Persistent / runtime dependencies
RUNTIME_DEPS
=
"wget ca-certificates git build-essential xz-utils"
# PHP dependencies
PHP_DEPS
=
"libssl-dev libcurl4-openssl-dev libedit-dev libsqlite3-dev libxml2-dev zlib1g-dev libsodium-dev libonig-dev"
.
/etc/os-release
if
[
"
${
VERSION_CODENAME
}
"
=
"bionic"
]
;
then
PHP_DEPS
=
"
${
PHP_DEPS
}
libargon2-0-dev"
else
PHP_DEPS
=
"
${
PHP_DEPS
}
libargon2-dev"
fi
# Dependencies required for running "phpize"
PHPIZE_DEPS
=
"autoconf dpkg-dev file g++ gcc libc-dev make pkg-config re2c"
# Install dependencies
check_packages
$RUNTIME_DEPS
$PHP_DEPS
$PHPIZE_DEPS
install_php
()
{
install_php
()
{
PHP_VERSION
=
"
$1
"
PHP_VERSION
=
"
$1
"
PHP_INSTALL_DIR
=
"
${
PHP_DIR
}
/
${
PHP_VERSION
}
"
PHP_INSTALL_DIR
=
"
${
PHP_DIR
}
/
${
PHP_VERSION
}
"
...
@@ -216,30 +191,48 @@ install_php() {
...
@@ -216,30 +191,48 @@ install_php() {
echo
"xdebug.mode = debug"
>>
"
${
XDEBUG_INI
}
"
echo
"xdebug.mode = debug"
>>
"
${
XDEBUG_INI
}
"
echo
"xdebug.start_with_request = yes"
>>
"
${
XDEBUG_INI
}
"
echo
"xdebug.start_with_request = yes"
>>
"
${
XDEBUG_INI
}
"
echo
"xdebug.client_port = 9003"
>>
"
${
XDEBUG_INI
}
"
echo
"xdebug.client_port = 9003"
>>
"
${
XDEBUG_INI
}
"
}
# Install PHP Composer if needed
if
[
"
${
PHP_VERSION
}
"
!=
"none"
]
;
then
if
[[
"
${
INSTALL_COMPOSER
}
"
=
"true"
]]
||
[[
$(
composer
--version
)
=
""
]]
;
then
# Persistent / runtime dependencies
addcomposer
RUNTIME_DEPS
=
"wget ca-certificates git build-essential xz-utils"
fi
CURRENT_DIR
=
"
${
PHP_DIR
}
/current"
# PHP dependencies
if
[[
!
-d
"
${
CURRENT_DIR
}
"
]]
;
then
PHP_DEPS
=
"libssl-dev libcurl4-openssl-dev libedit-dev libsqlite3-dev libxml2-dev zlib1g-dev libsodium-dev libonig-dev"
ln
-s
-r
"
${
PHP_INSTALL_DIR
}
"
${
CURRENT_DIR
}
fi
if
[
"
${
OVERRIDE_DEFAULT_VERSION
}
"
=
"true"
]
;
then
.
/etc/os-release
if
[[
$(
ls
-l
${
CURRENT_DIR
})
!=
*
"->
${
PHP_INSTALL_DIR
}
"
*
]]
;
then
rm
"
${
CURRENT_DIR
}
"
if
[
"
${
VERSION_CODENAME
}
"
=
"bionic"
]
;
then
ln
-s
-r
"
${
PHP_INSTALL_DIR
}
"
"
${
CURRENT_DIR
}
"
PHP_DEPS
=
"
${
PHP_DEPS
}
libargon2-0-dev"
fi
else
PHP_DEPS
=
"
${
PHP_DEPS
}
libargon2-dev"
fi
fi
rm
-rf
"
${
PHP_SRC_DIR
}
"
# Dependencies required for running "phpize"
updaterc
"if [[
\"\$
{PATH}
\"
!= *
\"
${
CURRENT_DIR
}
\"
* ]]; then export PATH=
\"
${
CURRENT_DIR
}
/bin:
\$
{PATH}
\"
; fi"
PHPIZE_DEPS
=
"autoconf dpkg-dev file g++ gcc libc-dev make pkg-config re2c"
}
find_version_from_git_tags PHP_VERSION https://github.com/php/php-src
"tags/php-"
# Install dependencies
install_php
"
${
PHP_VERSION
}
"
check_packages
$RUNTIME_DEPS
$PHP_DEPS
$PHPIZE_DEPS
find_version_from_git_tags PHP_VERSION https://github.com/php/php-src
"tags/php-"
install_php
"
${
PHP_VERSION
}
"
PHP_SRC
=
"
${
PHP_INSTALL_DIR
}
/bin/php"
else
set
+e
PHP_SRC
=
$(
which php
)
set
-e
fi
# Install PHP Composer if needed
if
[[
"
${
INSTALL_COMPOSER
}
"
=
"true"
]]
;
then
if
[
-z
"
${
PHP_SRC
}
"
]
;
then
echo
"(!) Could not install Composer. PHP not found."
exit
1
fi
addcomposer
fi
# Additional php versions to be installed but not be set as default.
# Additional php versions to be installed but not be set as default.
if
[
!
-z
"
${
ADDITIONAL_VERSIONS
}
"
]
;
then
if
[
!
-z
"
${
ADDITIONAL_VERSIONS
}
"
]
;
then
...
@@ -253,9 +246,26 @@ if [ ! -z "${ADDITIONAL_VERSIONS}" ]; then
...
@@ -253,9 +246,26 @@ if [ ! -z "${ADDITIONAL_VERSIONS}" ]; then
IFS
=
$OLDIFS
IFS
=
$OLDIFS
fi
fi
chown
-R
"
${
USERNAME
}
:php"
"
${
PHP_DIR
}
"
if
[
"
${
PHP_VERSION
}
"
!=
"none"
]
;
then
chmod
-R
g+r+w
"
${
PHP_DIR
}
"
CURRENT_DIR
=
"
${
PHP_DIR
}
/current"
find
"
${
PHP_DIR
}
"
-type
d
-print0
| xargs
-n
1
-0
chmod
g+s
if
[[
!
-d
"
${
CURRENT_DIR
}
"
]]
;
then
ln
-s
-r
"
${
PHP_INSTALL_DIR
}
"
${
CURRENT_DIR
}
fi
if
[
"
${
OVERRIDE_DEFAULT_VERSION
}
"
=
"true"
]
;
then
if
[[
$(
ls
-l
${
CURRENT_DIR
})
!=
*
"->
${
PHP_INSTALL_DIR
}
"
*
]]
;
then
rm
"
${
CURRENT_DIR
}
"
ln
-s
-r
"
${
PHP_INSTALL_DIR
}
"
"
${
CURRENT_DIR
}
"
fi
fi
rm
-rf
"
${
PHP_SRC_DIR
}
"
updaterc
"if [[
\"\$
{PATH}
\"
!= *
\"
${
CURRENT_DIR
}
\"
* ]]; then export PATH=
\"
${
CURRENT_DIR
}
/bin:
\$
{PATH}
\"
; fi"
chown
-R
"
${
USERNAME
}
:php"
"
${
PHP_DIR
}
"
chmod
-R
g+r+w
"
${
PHP_DIR
}
"
find
"
${
PHP_DIR
}
"
-type
d
-print0
| xargs
-n
1
-0
chmod
g+s
fi
# Clean up
# Clean up
rm
-rf
/var/lib/apt/lists/
*
rm
-rf
/var/lib/apt/lists/
*
...
...
test/php/install_additional_php.sh
View file @
36d7664e
...
@@ -9,5 +9,7 @@ check "php version 8.1.4 installed as default" php --version | grep 8.1.4
...
@@ -9,5 +9,7 @@ check "php version 8.1.4 installed as default" php --version | grep 8.1.4
check
"php version 8.0.17 installed"
ls
-l
/usr/local/php |
grep
8.0.17
check
"php version 8.0.17 installed"
ls
-l
/usr/local/php |
grep
8.0.17
check
"php version 8.0.3 installed"
ls
-l
/usr/local/php |
grep
8.0.3
check
"php version 8.0.3 installed"
ls
-l
/usr/local/php |
grep
8.0.3
check
"composer-version"
composer
--version
# Report result
# Report result
reportResults
reportResults
test/php/install_only_composer.sh
0 → 100644
View file @
36d7664e
#!/bin/bash
set
-e
# Optional: Import test library
source
dev-container-features-test-lib
check
"composer-version"
composer
--version
# Report result
reportResults
test/php/install_php_8.sh
View file @
36d7664e
...
@@ -6,6 +6,7 @@ set -e
...
@@ -6,6 +6,7 @@ set -e
source
dev-container-features-test-lib
source
dev-container-features-test-lib
check
"php-version-8-is-installed"
bash
-c
"php --version | grep '8.'"
check
"php-version-8-is-installed"
bash
-c
"php --version | grep '8.'"
check
"composer-version"
composer
--version
# Report result
# Report result
reportResults
reportResults
test/php/install_php_8_2.sh
View file @
36d7664e
...
@@ -6,6 +6,7 @@ set -e
...
@@ -6,6 +6,7 @@ set -e
source
dev-container-features-test-lib
source
dev-container-features-test-lib
check
"php-version-8.2-is-installed"
bash
-c
"php --version | grep '8.2'"
check
"php-version-8.2-is-installed"
bash
-c
"php --version | grep '8.2'"
check
"composer-version"
composer
--version
# Report result
# Report result
reportResults
reportResults
test/php/scenarios.json
View file @
36d7664e
...
@@ -23,5 +23,14 @@
...
@@ -23,5 +23,14 @@
"version"
:
"8.2"
"version"
:
"8.2"
}
}
}
}
},
"install_only_composer"
:
{
"image"
:
"mcr.microsoft.com/devcontainers/php:latest"
,
"features"
:
{
"php"
:
{
"version"
:
"none"
,
"installComposer"
:
true
}
}
}
}
}
}
test/php/test.sh
View file @
36d7664e
...
@@ -7,7 +7,7 @@ source dev-container-features-test-lib
...
@@ -7,7 +7,7 @@ source dev-container-features-test-lib
check
"PHP version"
php
--version
check
"PHP version"
php
--version
check
"Mbstring loaded"
php
-r
"extension_loaded('mbstring') || throw new Error('Extension Mbstring is not loaded');"
check
"Mbstring loaded"
php
-r
"extension_loaded('mbstring') || throw new Error('Extension Mbstring is not loaded');"
check
"
Composer
version"
composer
--version
check
"
composer-
version"
composer
--version
# Report result
# Report result
reportResults
reportResults
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment