Giter VIP home page Giter VIP logo

Comments (9)

fredemmott avatar fredemmott commented on June 20, 2024 1

v3 is strongly discouraged on recent releases of Hack/HHVM

That said:

from xhp-lib.

tyrellbain avatar tyrellbain commented on June 20, 2024

@fredemmott anyway of using v4 while using the global namespace? For legacy purposes I'd like to use :

from xhp-lib.

fredemmott avatar fredemmott commented on June 20, 2024

"For legacy purposes I'd like to use :"

It's not clear to me how this relates to namespace - if you mean you want to keep using the class :foo syntax, no, this can not be used with v4; the syntax change was required to avoid creating parser ambiguities with these changes.

Using the global namespace

If you want to be able to do <p> in v4 without a use type, we do not offer a way to do this. If you wanted to do this yourself, it would probably be best to:

  • use HHAST's core (or extend hhvm/definition-finder) to find non-abstract XHP classes
  • generate wrapper classes - e.g.
use namespace Facebook\XHP\Core as x;
use namespace Facebook\XHP\HTML as impl;

final xhp class p extends x\element {
 attribute :Facebook:XHP:HTML:p;

 protected async function renderAsync(): Awaitable<x\node> {
   return (
     <impl:p {...$this}>{$this->getChildren()}</impl:p>
   );
 }
};

from xhp-lib.

tyrellbain avatar tyrellbain commented on June 20, 2024

@fredemmott Thanks for responding, yeah sorry I worded that poorly. But you covered all the points I was trying to get at. I've updated the .hhconfig and I'm still getting undefined class errors.

.hhconfig

ignored_paths = [ "vendor/.*tests/.+", "vendor-rb/.*", "vendor/bin/.*"]
assume_php=false
error_php_lambdas = true
user_attributes=
enable_xhp_class_modifier=false
disable_xhp_element_mangling=false
disable_xhp_children_declarations=false
allowed_decl_fixme_codes=2053,4045,4047
allowed_fixme_codes_strict=2011,2049,2050,2053,2083,3084,4005,4026,4027,4045,4047,4053,4090,4104,4106,4107,4108,4110,4112,4128,4135,4183,4188,4223,4240,4281,4323,4390,4401

composer.json

{
  "name": "tyrellbain/facebook-component-library",
  "description": "Used to store references to frequently used components",
  "require": {
    "hhvm/hhvm-autoload": "^3.2",
    "hhvm/hsl": "^4.41",
    "facebook/xhp-lib": "^3.1",
    "hhvm": "^4.92"
  },
  "require-dev": {
    "hhvm/hhast": "^4.95",
    "hhvm/hacktest": "^2.2",
    "facebook/fbexpect": "^2.7"
  }
}

index.php

<?hh //strict

<<__EntryPoint>>
function main(): void {
  require_once(__DIR__ . '/vendor/autoload.hack');
  \Facebook\AutoloadMap\initialize();
  $xhp = <p>Test</p>;
   echo "Test";
   echo(__DIR__ . '/vendor/autoload.hack');
  exit(0);
}

Running with the following HHVM command:
hhvm -m server -p 8080

Getting this error:
\nFatal error: Class undefined: p in /Users/tyrell/Desktop/test-hhvm/index.php on line 7

from xhp-lib.

fredemmott avatar fredemmott commented on June 20, 2024

You need to pass the additional runtime options to HHVM.

from xhp-lib.

tyrellbain avatar tyrellbain commented on June 20, 2024

@fredemmott I've passed the appropriate options via config, now I'm getting a similar but slightly different error. My classnames are be prepended with xhp_ now. Is there a recommenced version of HHVM to run with xhp-lib v3?

config.ini

hhvm.server.port = 8080
hhvm.server.default_document = ./index.php
hhvm.debugger.vs_debug_enable = 1
hhvm.server.allow_run_as_root = true
hhvm.hack.lang.enable_xhp_class_modifier=false
hhvm.hack.lang.disable_xhp_element_mangling=false
hhvm.enable_xhp=true

Executing with
hhvm -c config.ini -m server

Error:
\nFatal error: Class undefined: xhp_p in /Users/tyrell/Desktop/test-hhvm/index.php on line 7

from xhp-lib.

tyrellbain avatar tyrellbain commented on June 20, 2024

Sorry not sure if there's a better place get help on this. Just been scratching my head these past couple days trying to get a basic xhp-lib v3 example to render

from xhp-lib.

fredemmott avatar fredemmott commented on June 20, 2024

Try hhvm -c config.ini vendor/bin/hh-autoload (as the options change the class names, the autoloader must be ran with the same options), then re-starting the server

from xhp-lib.

tyrellbain avatar tyrellbain commented on June 20, 2024

@fredemmott that did it, thank you!

from xhp-lib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.