php.ts
php.ts is deno static site generator with a development workflow similar to PHP, but with typesafe JSX and all the tooling that comes with deno and javascript ecosystem.
$(
<div style={{ background: "#222", color: "#fff" }}>
<p>hello there</p>
<a href="other.tsx?category=test">other page</a>
</div>
);
console.log("<div>this will also be part of the html output</div>");
console.log(`<p>query parameter value of x: ${$.request.data.x}</p>`);
Development workflow
The development process is very similar to the goodbad ole days of early PHP sites:
- start dev server:
$ php.ts dev
- create a page (example.tsx)
- view in browser (http://localhost:3000/example.tsx)
- edit page
- refresh page in browser
- goto 3 if not yet done
- generate html files:
$ php.ts build
- push html files to repository or server
But why?
If you are someone who has strong allergic reactions to anything related to JS or PHP, you might think this is a troll or joke project. You are not too far off actually. You ask me a “but why”, I give you a “what if”. I set out on a flaming trainwreck of a journey with a question mind: what if I could do PHP-like development but with a modern tooling and libraries of typescript.
I scratched a technical itch, now I’m sharing my mild skin irritation with random people AHA ha Ah HA. More seriously, despite my initial intention, I do believe php.ts did turn out to be quite useable for actual projects, for me at least.
Setup and Installation
$ mkdir your-site-name; cd your-site-name
$ deno run https://deno.land/x/php_ts/php.ts init
Alternatively, you can just manually download php.ts,chmod +x
it, then run./php init
$ ./php --help
to see help contents
Then take a quick glance on the documentation.