Tier 0 · Story 10Complete
This guide walks you through creating your first Tyhp project, from initialization to running the compiled PHP output. Before proceeding, make sure you have Tyhp installed (see the Installation section).
mkdir my-tyhp-project
cd my-tyhp-project
tyhp init
This creates a tyhp.json configuration file, a root composer.json (with tyhp/php and tyhp/core pins), src/index.tyhp, and empty tyhpdef/ and build/ directories.
my-tyhp-project/
tyhp.json # Project configuration
composer.json # Pins tyhp/php and tyhp/core
src/index.tyhp # Sample entry file
tyhpdef/ # Type definitions for external PHP code (.tyhpdef)
build/ # Compiled PHP output (generated)
{
"include": ["src/**/*.tyhp"],
"exclude": ["vendor/**", "node_modules/**"],
"source": {
"tagless": false
},
"output": {
"path": "build/",
"phpVersion": "8.4",
"strictTypes": true,
"comments": true
}
}
Supported output.phpVersion values are "8.2", "8.3", "8.4", and "8.5".
tyhp init writes src/index.tyhp. Tyhp files use the <?tyhp opening tag instead of <?php:
<?tyhp
namespace App;
echo 'Hello, World!';
tyhp build
The compiler reads tyhp.json, runs parse / bind / check / emit, and writes PHP to the output directory. tyhp init already pins tyhp/php and tyhp/core in the project composer.json. tyhp build updates Composer metadata only when build.updateComposer is true (default false); otherwise it reports which packages the emit needs. Pins use output.phpVersion plus each package’s own X.Y ("8.4" + 0.0 → 804.0.0). See the Composer Runtime Packages page.
composer install
php build/src/index.php
Until Packagist lists the tyhp/* packages, use a compiler checkout so path repositories can resolve runtime/packages/.
The compiled PHP looks like standard PHP. Variable type annotations are erased — they were checked at compile time.
<?php
declare(strict_types=1);
namespace App;
echo 'Hello, World!';
tyhp lint
Faster than a full build. Useful in development and CI.
Install tyhp/php for PHP builtin types (\strlen, DateTime, and so on). For other Composer packages, add .tyhpdef files under tyhpdef/ that describe the public API you call. Automatic tyhp generate_tyhpdef is not in this alpha — write tyhpdefs by hand or copy from existing stubs.
.tyhp filestyhp lint for type errorstyhp build to compile to PHPThis alpha has no Language Server and no Xdebug/sourcemap debugging. Debug the emitted PHP, or iterate with tyhp lint.