How to install php v8js on Mac?

Hi i need php v8JS extension for ReactJs app. Can anyone give me complete installation instructions? I am using php 5.6 and Xampp.

+3


source to share


1 answer


Let me preface this with words: if you're looking for a shorter way to do this, it doesn't exist.

install engine
$ brew install v8

install dependency for PECL extension
$ brew install autoconf

install / configure PEAR and PECL:

  • first download the go-pear.phar file (you can also just download it manually using your browser)
    $ curl -O https://pear.php.net/go-pear.phar


  • configure PEAR for installation:
    $ php -d detect_unicode=0 go-pear.phar


    when prompted by the command above (the first three steps should change the installation base and the last 3 should change the binaries directory):
    1. enter 1 and press enter.
    2. enter / usr / local / pear
    3. press Enter.
    4. type 4 and press enter
    5. enter / usr / local / bin
    6. press Enter.

update / update PEAR / PECL:

$ sudo pear channel-update pear.php.net


$ sudo pecl channel-update pecl.php.net


$ sudo pear upgrade-all


Grab the PECL V8Js extension from GitHub and install it

$ cd ~


$ mkdir tmp && cd tmp


$ git clone https://github.com/phpv8/v8js


$ cd v8js


$ phpize


$./configure CXXFLAGS="-Wno-c++11-narrowing"


$ make


$ make test #if this step fails you can try to install anyway. should work.


$ make install




(Note the Capitan users and the command make install

: if you get an operation not allowed error, you will have to disable System Integrity Protection as described here - be sure to read why this restriction is in effect from the beginning.)

make sure your php.ini file (located at: /etc/php.ini) has the following: extension=v8js.so

at this point v8js should be available in php command line, check: $ php -i | grep v8js

$ php -i | grep v8js

Bonus: the above should answer the question of how to install v8js, but you have to go further for it to work on a Mac built -in Apache Server.

Apache httpd.conf (located at: / etc / apache2):
Uncomment the following line:LoadModule php7_module libexec/httpd/libphp7.so

Add the following to your httpd.conf file:

<IfModule mod_php7.c>
# If php is turned on, we respect .php and .phps files.
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

# Since most users will want index.php to work we
# also automatically enable index.php
<IfModule mod_dir.c>
    DirectoryIndex index.html index.php
</IfModule>

      

save file. and restart the server: sudo apachectl graceful

(or just start it if it doesn't work)

+1


source







All Articles