PHP code example of wispx / slug

1. Go to this page and download the library: Download wispx/slug library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wispx / slug example snippets




$config = [
    'appKey' => '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');