robbiep / afterthedeadline
Afterthedeadline API 包装器
0.0.13
2016-01-16 16:49 UTC
Requires
- php: >=5.5.0
- guzzlehttp/guzzle: ~5.0
- illuminate/support: ^5.0
- rquadling/lalit: 1.*
Requires (Dev)
- mockery/mockery: dev-master@dev
README
这是一个 After the Deadline API 的 PHP 包装器
After the Deadline 是一个网络语言检查器,具有:上下文拼写检查、高级样式检查和智能语法检查
安装
通过 Composer 安装此包。
将以下内容添加到您的 composer.json
依赖项中
"require": { "robbiep/afterthedeadline": "^0.0" }
运行 composer install
下载所需文件。
使用方法
require_once('vendor/autoload.php'); $atd = new \RobbieP\Afterthedeadline\Afterthedeadline(['key' => md5('<unique string>')]); $atd->checkDocument("I started my schooling as the majority did in my area, at the local primarry school."); # `getResults` will return an array of objects (Spelling, Grammar, Suggestion) or `false` if there were no results $results = $atd->getResults(); # (Optionally) you can get formatted text back where the results have been wrapped with # <span class="atd-{type}" data-suggestions="{suggestions}">word</span> echo $atd->getFormatted();
结果为
<div id="atd-content">I started my schooling as the <span class="atd-suggestion" data-info="" data-suggestions="['greatest','most']">majority</span> did in my area, at the local <span class="atd-spelling" data-suggestions="['primary','primacy','primarily','remarry']">primarry</span> school.</div>
(实验性) 我使用 jQuery 和 Bootstrap 编写了一些基本的 JavaScript,以提供一个简单的 UI 来纠正/忽略结果
echo $m->getFormatted()->getStylesAndScript(); ?>
对其他语言的支持
目前 After the Deadline 默认支持英语,但还支持德语 de
、法语 fr
、西班牙语 es
和葡萄牙语 pt
您可以在构造函数中设置它
$atd = new \RobbieP\Afterthedeadline\Afterthedeadline(['key' => md5('<unique string>'), 'lang' => 'de']); # You must use 2 letter country code
或者您可以在线设置它
$atd = new \RobbieP\Afterthedeadline\Afterthedeadline(['key' => md5('<unique string>')]); $atd->setLanguage(\RobbieP\Afterthedeadline\Language::GERMAN);
如果您在 Laravel 中使用它...
我包含了一个 ServiceProvider 类和一个配置,如果您需要更改任何选项。您需要将 ServiceProvider 添加到 config/app.php
'providers' => array( ... RobbieP\Afterthedeadline\AfterthedeadlineServiceProvider::class )
如果您想使用 Facade...
'aliases' => array( ... 'Afterthedeadline' => RobbieP\Afterthedeadline\Facades\Afterthedeadline::class, )
您需要发布配置 php artisan vendor:publish
将您自行生成的 API 密钥放在那里。
Laravel 中的使用方法
$results = \Afterthedeadline::checkDocument("some content") ->getResults();
贡献
- 分叉它
- 创建您的功能分支:
git checkout -b my-new-feature
- 提交您的更改:
git commit -am '添加一些功能'
- 推送到分支:
git push origin my-new-feature
- 提交拉取请求