Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/attitude/phpx
- Owner: attitude
- License: mit
- Created: 2021-03-07T23:04:07.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-13T09:29:23.000Z (7 months ago)
- Last Synced: 2024-04-13T23:55:12.770Z (7 months ago)
- Topics: jsx, php, php8, templating, transpiler
- Language: PHP
- Homepage:
- Size: 103 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.
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.
forever!
>
PHPX);
```---
*Enjoy!*
Created by [martin_adamko](https://www.threads.net/@martin_adamko)