Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/attitude/phpx

PHPX is to PHP what JSX is to JS
https://github.com/attitude/phpx

jsx php php8 templating transpiler

Last synced: about 6 hours ago
JSON representation

PHPX is to PHP what JSX is to JS

Awesome Lists containing this project

README

        

# PHPX is to PHP what JSX is to JS

> [!WARNING]
> **Experimental project – give it a try**

## Turn PHPX syntax into PHP code

**Source input:**

```jsx
<>

Hello, {$name ?? ucfirst($type)}!



Welcome to the world of PHPX, where you can write PHP code in a JSX-like syntax.
Happy coding! forever!


>
```

**Compiled output:**

```php
[
['$', 'h1', ['className'=>"title"], ['Hello, ', ($name ?? ucfirst($type)), '!']],
['$', 'p', null, [
'Welcome to the world of PHPX, where you can write PHP code in a JSX-like syntax.',
['$', 'img', ['src'=>"about:blank", 'alt'=>"Happy coding!"]], ' forever!',
]],
]
```

## Installation

> [!IMPORTANT]
> This project is not yet published to Packagist. You need to add the repository manually or clone the repository as a submodule.

### Option 1: Add as a Git submodule

```shell
$ git submodule add [email protected]:attitude/phpx.git path/to/phpx
```

### Option 2: Add as a dependency using Composer

Update `composer.json` of your project:

```json
{
...,
"repositories": [
{
"type": "vcs",
"url": "https://github.com/attitude/phpx"
}
],
"require": {
"attitude/phpx": "dev-main"
}
}
```

```shell
$ composer install
```

### Option 3: Download the repository as a ZIP

---

## Usage

```php
compile(<<<'PHPX'
<>

Hello, {$name ?? ucfirst($type)}!



Welcome to the world of PHPX, where you can write PHP code in a JSX-like syntax.
Happy coding! forever!


>
PHPX);
```

---

*Enjoy!*

Created by [martin_adamko](https://www.threads.net/@martin_adamko)