Skip to content

tinkerun/php-form

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Jun 13, 2021
f23ff91 · Jun 13, 2021

History

37 Commits
May 6, 2021
Jun 13, 2021
May 8, 2021
May 5, 2021
May 12, 2021
May 5, 2021
May 12, 2021
Jun 13, 2021
May 12, 2021
May 12, 2021
Jun 12, 2021
Jun 12, 2021
May 3, 2021
May 3, 2021
May 8, 2021
May 8, 2021
Jun 13, 2021
May 12, 2021
May 4, 2021

Repository files navigation

php-form

a lib that can modify the php code via javascript

Install

yarn add php-form

API

The full API for php-form is contained within the TypeScript declaration file

Example Usage

import {instance} from 'php-form'

(async () => {

  const form = await instance()

  let code = `<?php
  $form_email = [
    'label' => 'Email',
    'value' => 'user1@example.com',
  ];
  
  $form_name = 'billy'
  `
  
  const fields = await form.parse(code)
  // [{name: '$form_email', label: 'Email', value: 'user1@example.com'}, {name: '$form_name', value: 'billy'}]
  
  fields[0].value = 'user2@example.com'
  fields[1].value = 'magic'
  
  code = await form.stringify(fields)
  // <?php $form_email = [
  //   'label' => 'Email',
  //   'value' => 'user2@example.com',
  // ];
  // 
  // $form_name = 'magic'
})

License

MIT

About

a lib that can modify the PHP code via javascript

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published