## Getting started with PHP
[![license](http://img.shields.io/badge/license-BSD3-brightgreen.svg?style=flat)](https://github.com/Tencent/VasSonic/blob/master/LICENSE)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Tencent/VasSonic/pulls)
[![wiki](https://img.shields.io/badge/Wiki-open-brightgreen.svg)](https://github.com/Tencent/VasSonic/wiki)
---
## How to use for Server
Download and import ```sonic.php```.
```PHP
require_once(PATH."/sonic.php");
```
Then add following code.
```
if (isset($_GET['sonic']) && $_GET['sonic'] == '1') {
// Check if Sonic is needed or not
util_sonic::start();
$this->_index_v5($uin);
util_sonic::end();
}
```
## How to use for front-end
Here is a simple demo shows how to use Sonic for front-end.
```Html
demo
// step 1: specify template and data by inserting different comment anchor.
data3
// step 2: Receives diff data from mobile client through Javascript interface.
```
### Step 1:
Specify template and data by inserting different comment anchor. The data will be wrapped with anchor `````` ``````. The other part of html is template.
```Html
data3
```
### Step 2:
Receives diff data from mobile client through JavaScript interface. The JavaScript interface of demo was involved when websites are finish. But the time when inferface was involved is not immutable, websites can decide whenever they want.
```Html
```
### Step 3:
Handle different status received from mobile client. The demo shows how to find and replace the data of specified anchor according to the diff data come from mobile client, then the website is updated.
```Html
//step 3 Handle the response from mobile client which include Sonic response code and diff data.
function getDiffDataCallback(result){
}
//step 3 Handle the response from mobile client which include Sonic response code and diff data.
function handleSonicDiffData(sonicStatus, sonicUpdateData){
}
```
## Support
Any problem?
1. Learn more from [sample](https://github.com/Tencent/VasSonic/tree/master/sonic-php/sample).
2. Contact us for help.
## License
VasSonic is under the BSD license. See the [LICENSE](https://github.com/Tencent/VasSonic/blob/master/LICENSE) file for details.
[1]: https://github.com/Tencent/VasSonic/blob/master/article/20170705120005424.gif
[2]: https://github.com/Tencent/VasSonic/blob/master/article/20170705120029897.gif