Supported Environment
- PHP 5 >= 5.3.0, PHP 7
npm i san san-ssr san-ssr-target-php
Note: ts2php requires a specific external TypeScript, you'll need npm i typescript@3.4
, see searchfe/ts2php/issues/93.
Command line interface:
san-ssr --target php --compile '{"nsPrefix":"demo\\"}' ./component.ts > ssr.php
Pass 'php'
as the second parameter of SanProject
[SanProject#compile(filepath, target, options)][.compile()] method.
TypeScript:
import { Target, SanProject } from 'san-project'
import { writeFileSync } from 'fs'
const project = new SanProject()
const targetCode = project.compile('src/component.ts', 'php')
writeFileSync('ssr.php', targetCode)
Or in JavaScript:
const { SanProject } = require('san-project')
import { writeFileSync } from 'fs'
const project = new SanProject()
const targetCode = project.compile('src/component.ts', 'php')
writeFileSync('ssr.php', targetCode)
THIS SECTION IS FOR MAINTAINERS ONLY
- noDataOutput 控制的数据输出中,对象序列化使用 json_encode 实现,属性顺序和 JavaScript 中可能不同
Development Prerequisites:
- Node.js>=8
- PHP 7
- composer
Install dependencies and run tests:
npm install
composer install
npm test
Debug a single case (e.g. test/cases/array-literal
):
./bin/debug array-literal
source ./bin/auto-complete
to make zsh to auto complete test case names.