PHP code example of syntaxx / phpx-starter-kit
1. Go to this page and download the library: Download syntaxx/phpx-starter-kit library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
syntaxx / phpx-starter-kit example snippets
namespace Syntaxx\PHPX\Demo;
use Syntaxx\PHPX\Framework\Component;
use Syntaxx\PHPX\Framework\Runtime;
use Syntaxx\PHPX\Framework\Document;
use function Syntaxx\PHPX\Framework\useState;
function MyApp() {
return (
<div>
<h1>Click to increment</h1>
<MyButton />
</div>
);
}
function MyButton() {
[$count, $setCount] = useState(0);
$handleClick = function() use ($count, $setCount) {
$setCount($count + 1);
};
return (
<button onClick={$handleClick}>
Count: {$count}
</button>
);
}
// Render to DOM
$root = Runtime::createRoot(Document::document()->getElementById('root'));
$root->render(
Component::create("StrictMode", [], [
Component::create("MyApp", [], [])
])
);