https://github.com/0xxb/slug
SEO friendly URL structure.
https://github.com/0xxb/slug
php seo slug translation url you-dao youdao-fanyi-api
Last synced: 6 months ago
JSON representation
SEO friendly URL structure.
- Host: GitHub
- URL: https://github.com/0xxb/slug
- Owner: 0xxb
- License: mit
- Created: 2019-03-20T10:00:44.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-21T02:45:02.000Z (over 7 years ago)
- Last Synced: 2026-01-14T13:55:22.297Z (6 months ago)
- Topics: php, seo, slug, translation, url, you-dao, youdao-fanyi-api
- Language: PHP
- Homepage:
- Size: 6.84 KB
- Stars: 4
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Slug
[](http://php.net)
[](https://packagist.org/packages/wispx/slug)
[](https://packagist.org/packages/wispx/slug)
[](https://packagist.org/packages/wispx/slug)
> 使用有道翻译实现的中文转英文、友好的、利于 SEO 的 URL 结构。
## 开始
注册有道智云:https://ai.youdao.com/?keyfrom=old-openapi
注册之后,创建一个应用,然后你会得到下面两个配置信息:
```
1. appKey
2. appSecret
```
## 安装
通过下面的命令行来安装:
```bash
composer require wispx/slug
```
或者在你的 `composer.json` 文件中添加:
```json
"wispx/slug": "~1.0"
```
然后执行 `composer update`
### 使用
```php
'your appKey',
'appSecret' => 'your appSecret'
];
$slug = new \Slug\Slug($config);
echo $slug->translate('代码是艺术的一部分');
// Code is part of the art
echo $slug->translug('代码是艺术的一部分');
// code-is-part-of-the-art
echo $slug->translug('代码是艺术的一部分', '_');
// code_is_part_of_the_art
// Facade
\Slug\Facade\Slug::setConfig($config);
// setConfig方法支持链式操作
\Slug\Facade\Slug::setConfig($config)->translug('代码是艺术的一部分');
// code-is-part-of-the-art
// 还可以这样
\slug($config)->translug('2333');
// or
\slug()->setConfig($config)->translug('2333');
```
### License
- MIT