{"id":13562419,"url":"https://github.com/phpv8/v8js","last_synced_at":"2025-05-14T06:12:33.697Z","repository":{"id":3131870,"uuid":"4160039","full_name":"phpv8/v8js","owner":"phpv8","description":"V8 Javascript Engine for PHP — This PHP extension embeds the Google V8 Javascript Engine","archived":false,"fork":false,"pushed_at":"2025-01-09T21:27:22.000Z","size":1854,"stargazers_count":1843,"open_issues_count":28,"forks_count":202,"subscribers_count":67,"default_branch":"php8","last_synced_at":"2025-04-11T00:48:46.336Z","etag":null,"topics":["javascript","php","php-extension","php-v8","v8","v8-javascript-engine","v8js"],"latest_commit_sha":null,"homepage":"http://pecl.php.net/package/v8js","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phpv8.png","metadata":{"files":{"readme":"README.Linux.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-04-27T16:09:49.000Z","updated_at":"2025-03-30T00:40:17.000Z","dependencies_parsed_at":"2024-02-18T21:24:43.491Z","dependency_job_id":"2bc593d8-0f03-40d1-bcd0-f27ec3a01268","html_url":"https://github.com/phpv8/v8js","commit_stats":{"total_commits":907,"total_committers":50,"mean_commits":18.14,"dds":0.2976846747519294,"last_synced_commit":"133bf61e0544c0d0d7e92c297a1041a30ea9d3fc"},"previous_names":["preillyme/v8js"],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpv8%2Fv8js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpv8%2Fv8js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpv8%2Fv8js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpv8%2Fv8js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phpv8","download_url":"https://codeload.github.com/phpv8/v8js/tar.gz/refs/heads/php8","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254080563,"owners_count":22011443,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","php","php-extension","php-v8","v8","v8-javascript-engine","v8js"],"created_at":"2024-08-01T13:01:08.406Z","updated_at":"2025-05-14T06:12:33.624Z","avatar_url":"https://github.com/phpv8.png","language":"C++","readme":"V8Js on GNU/Linux\n=================\n\nInstallation of V8Js on GNU/Linux is pretty much straight forward.\n\nFirst you need to decide if you can go with a V8 library that is\nshipped with your GNU/Linux distribution or whether you would want\nto compile V8 on your own.\n\nMany GNU/Linux distributions, for example Debian/Ubuntu, have\nrecent V8 library versions installable, that are ready to be used.\nIn order to go with these, just `sudo apt-get install libv8-dev`\n(or similar, as it fits your distribution).\n\nIf you compile V8 on your own, it is recommended to install the V8\nversion for V8Js off your system's load path, so it doesn't interfere\nwith the V8 library shipped with your system's distribution.\n\n\nSnapshots\n---------\n\nV8 has (optional) support for so-called snapshots which speed up startup\nperformance drastically.  Hence they are generally recommended for use.\n\nThere are two flavours of snapshots: internal \u0026 external.\n\nInternal snapshots are built right into the V8 library (libv8.so file),\nso there's no need to handle them specially.\n\nBesides there are external snapshots (which are enabled unless configured\notherwise).  If V8 is compiled with these, then V8Js needs to provide two\n\"binary blobs\" to V8, named `natives_blob.bin` and `snapshot_blob.bin`.\nIn that case copy those two files to the same directory `libv8.so` was\ninstalled to.\n\n\nPointer Compression\n-------------------\n\nV8 versions 8.0 and higher enable pointer compression by default.\nSee [the design document](https://docs.google.com/document/d/10qh2-b4C5OtSg-xLwyZpEI5ZihVBPtn1xwKBbQC26yI/edit)\nfor details.\n\nHence if you use one of the recent version (which you really should),\nthen you\n\n a) either need to manually disable pointer compression during\n    the build of the library by passing the\n    `v8_enable_pointer_compression=false` flag to `v8gen.py`\n\n b) or compile php-v8js with pointer compression as well, by adding\n    `CPPFLAGS=\"-DV8_COMPRESS_POINTERS\"` to the `./configure` call.\n\n\nSandbox\n-------\n\nV8 has optional sandbox support.  You need to compile php-v8js with matching\nconfigurations.  If your V8 library was called with sandbox support, you\nneed to pass the `-DV8_ENABLE_SANDBOX` flag to the configure call.\n\nBy default V8 currently enables this feature.\nMany GNU/Linux distributions currently seem to have sandbox feature turned\noff however.\n\nIf you configure it the wrong way round, you'll get runtime errors like this,\nas soon as php-v8js tries to initialize V8:\n\n```\nEmbedder-vs-V8 build configuration mismatch. On embedder side sandbox is DISABLED while on V8 side it's ENABLED.\n```\n\nIn order to compile V8 with sandbox support off, pass `v8_enable_sandbox=false`\nto v8gen.py invocation.\n\n\nCompile V8 5.6 and newer (using GN)\n-----------------------------------\n\n```\n# Install required dependencies\nsudo apt-get install build-essential curl git python3 libglib2.0-dev\n\ncd /tmp\n\n# Install depot_tools first (needed for source checkout)\ngit clone https://chromium.googlesource.com/chromium/tools/depot_tools.git\nexport PATH=`pwd`/depot_tools:\"$PATH\"\n\n# Download v8\nfetch v8\ncd v8\n\n# (optional) If you'd like to build a certain version:\ngit checkout 12.0.267.36\ngclient sync -D\n\n# Setup GN\ntools/dev/v8gen.py -vv x64.release -- is_component_build=true use_custom_libcxx=false\n\n# Build\nninja -C out.gn/x64.release/\n\n# Install to /opt/v8/\nsudo mkdir -p /opt/v8/{lib,include}\nsudo cp out.gn/x64.release/lib*.so out.gn/x64.release/*_blob.bin \\\n  out.gn/x64.release/icudtl.dat /opt/v8/lib/\nsudo cp -R include/* /opt/v8/include/\n```\n\nOn Debian Stretch you need to set RPATH on the installed libraries,\nso the library loader finds the dependencies:\n\n```\nsudo apt-get install patchelf\nfor A in /opt/v8/lib/*.so; do sudo patchelf --set-rpath '$ORIGIN' $A; done\n```\n\nCompile php-v8js itself\n-----------------------\n\n```\ncd /tmp\ngit clone https://github.com/phpv8/v8js.git\ncd v8js\nphpize\n./configure --with-v8js=/opt/v8 LDFLAGS=\"-lstdc++\" CPPFLAGS=\"-DV8_COMPRESS_POINTERS -DV8_ENABLE_SANDBOX\"\nmake\nmake test\nsudo make install\n```\n\nThen add `extension=v8js.so` to your php.ini file. If you have a separate configuration for CLI, add it there also.\n\nV8Js' build system assumes that the `icudtl.dat` file is located next to the `libv8.so`\nlibrary file and compiles the path into the library itself.  If for whatever reason the\n`icudtl.dat` file is stored at a different place during runtime, you need to set the\nphp.ini variable `v8js.icudtl_dat_path` to point to the file.  Otherwise locale-aware\nfeatures of V8 will not work as expected.\n","funding_links":[],"categories":["C++","跨语言"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpv8%2Fv8js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphpv8%2Fv8js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpv8%2Fv8js/lists"}