paliarush / magento2-vagrant-for-developers

Vagrant Box for Magento 2 Developers
MIT License
447 stars 165 forks source link

Host PHP version php-5.6.9 -> newer and adding VC_redist.x64.exe as requirement #231

Open medmek opened 3 years ago

medmek commented 3 years ago

When I execute manually : curl http://windows.php.net/downloads/releases/archives/php-5.6.9-nts-Win32-VC11-x86.zip -o lib/php.zip it creates a small file (1kb)

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   207  100   207    0     0   1510      0 --:--:-- --:--:-- --:--:--  1522

a file that is clearly not the whole php5.6 zip (trying to unzip it manually tells me that it's not a zip file)

So I had to curl manually another version of PHP : curl https://windows.php.net/downloads/releases/php-7.4.16-nts-Win32-vc15-x64.zip -o lib/php.zip

I also had to install VC_redist.x64.exe like advised in this stackoverflow answer otherwise I get this :

php --version
PHP Warning: 'vcruntime140.dll' 14.0 is not compatible with this PHP build linked with 14.16 in Unknown on line 0

So it might be a good idea to add VC_redist.x64.exe it to the requirement and update the PHP version to download. (Or maybe to make a list of versions (list of urls) to try before renouncing the Automatic PHP host installation)

Thank you

medmek commented 3 years ago

While doing the above solves the php download problem, the newer php version architecture, or more precisely the php.ini layout seems to be different. Because of this, parts of this project for enabling php extensions (necessary for the installation of magento code base via composer) seems to not work.

[2021-04-25 22:56:54] STATUS: >  Installing composer [/c/dev/shop/scripts/host/composer.sh]]
Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:

The openssl extension is missing, which means that secure HTTPS transfers are impossible.
If possible you should enable it or recompile php with --with-openssl
[2021-04-25 22:56:55] STATUS: >  composer --ignore-platform-reqs --no-interaction create-project [/c/dev/shop/scripts/host/composer.sh]]

it seems to be caused by this lines in install_php.sh

sed -i.back 's|; extension_dir = "ext"|extension_dir = "ext"|g' "${vagrant_dir}/lib/php/php.ini"
sed -i.back 's|;extension=php_openssl.dll|extension=php_openssl.dll|g' "${vagrant_dir}/lib/php/php.ini"

trying to remove the ; to uncomment, except that the php.ini layout in php-7.4.16 is

; On windows:
;extension_dir = "ext"
...
;extension=openssl

so I propose the following I just tested successfully :

sed -i.back 's|;extension_dir = "ext"|extension_dir = "ext"|g' "${vagrant_dir}/lib/php/php.ini"
sed -i.back 's|;extension=openssl|extension=openssl|g' "${vagrant_dir}/lib/php/php.ini"

I think I'll do PR