Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8006899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:39:43+00:00 2026-06-04T17:39:43+00:00

I have started using v8js with php for a while now but the documentation

  • 0

I have started using v8js with php for a while now but the documentation is really thin.

One thing that is not explained is Extensions.

It is possible to registerExtension but it is not explained in detail how these behave or whats their purpose or benefits.

Can anyone provide a good description or link to a documentation that explains Extensions?

Thanks to everyone for taking time to read and answer 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:39:45+00:00Added an answer on June 4, 2026 at 5:39 pm

    Original Answer

    My original answer indicated that the extension was called every time executeString was.

    Corrected answer

    An extension is a bit of code that is executed before the first executeString call for a given V8Js instance.
    Extension can be global to all V8Js instances or local to a specific instance.

    I have experimentally determined that this isn’t always very reliable. If you frantically refresh a page, you may not always see the extension get run… This is probably why this is beta quality software.

    Here are two examples that I whipped up

    Global Extension Example

    Code

    V8Js::registerExtension('say_hi', 'print("hey from extension! "); var said_hi=true;', array(), true);
    $v8 = new V8Js();
    $v8->executeString('print("hello from regular code!")', 'test.php');
    $v8->executeString('if (said_hi) { print(" extension already said hi"); }');
    

    Output

    hey from extension! hello from regular code! extension already said hi

    Non-Global Example

    Code

    V8Js::registerExtension('say_hi', 'print("hey from non global extension! "); var said_hi=true;');
    $v8 = new V8Js('PHP', array(), array('say_hi'));
    $v8->executeString('print("hello from regular code!");', 'test.php');
    $v8->executeString('if (said_hi) { print(" extension already said hi"); }');
    

    Output

    hey from non global extension! hello from regular code! extension already said hi

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have started using of generics in Delphi 2010 but I have a problem
I have started using jQuery and rails. I have made a simple form that
I have started using c++ extensively in school and now my programs are getting
As I have started using Linux (Ubuntu) to broaden my knowledge, but the flow
We have started using MVC framework and now we are bit confused where to
I have started using django-piston for creating APIS but I am having trouble finding
I have started using the Android StrictMode and find that it would be great
I have started using Code Contracts and have found that it makes it difficult
I have started using the Excel interop assemblies that are provided by Microsoft for
I have started using jquery in one of my new asp.net webform application... I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.