Comments (9)
v3 is strongly discouraged on recent releases of Hack/HHVM
That said:
- you need the .hhconfig options from https://github.com/hhvm/xhp-lib/blob/v3.x/.hhconfig#L12-L14
- you need the runtime options from https://github.com/hhvm/xhp-lib/blob/v3.x/.github/workflows/build-and-test.yml#L28
from xhp-lib.
@fredemmott anyway of using v4 while using the global namespace? For legacy purposes I'd like to use :
from xhp-lib.
"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.
@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.
You need to pass the additional runtime options to HHVM.
from xhp-lib.
@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.
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.
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.
@fredemmott that did it, thank you!
from xhp-lib.
Related Issues (20)
- Remove XHPRoot, seal `x:node`/composable-element to x:primitive and x:element HOT 5
- [ Todo ] When XHP version 4 is released, update the docs about runtime validation in user-documentation. HOT 2
- Remove class2element/element2class
- Audit all code that is not in namespaces HOT 1
- Do we want the HTML xhp classes to be final in v4?
- [ RFC ] Introduce a new exception class for modifying/rendering xhp after initial render HOT 1
- Remove string selectors from getFirstChild and friends
- Audit missing category declarations HOT 4
- Rewrite docs on user-documentation to use xhp 4 syntax and rules HOT 2
- Make a full list of changes from v3
- Write a migration guide for v3 -> v4
- better exception message when rendering parent with an already rendered child HOT 8
- Review and consider removing all 'deprecated' features HOT 1
- Update README to reflect xhp-4
- hhvm 4.97 issue: x\node should permit ?XHPChild children HOT 2
- Use of XHP at Facebook HOT 2
- Default values of aria- and data- attributes are ignored
- [Request] Custom special attributes HOT 4
- Status of the project HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xhp-lib.