This "project" is a simple CLI slugger
Last active
April 11, 2024 21:52
-
-
Save lyrixx/5107964fb9b231d69c548e0f128fe8ea to your computer and use it in GitHub Desktop.
slugger CLI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
// # Installation instruction | |
// # Clone the symfony/string repository | |
// $ git clone [email protected]:symfony/string $HOME/dev/github.com/symfony/string | |
// $ cd $HOME/dev/github.com/symfony/string | |
// # Install the dependencies | |
// $ composer up | |
// # Then create a file slug.php with the content of this file. | |
// # Make it executable | |
// $ chmod +x slug.php | |
// # Create a symlink in your $PATH with | |
// $ ln -s $HOME/dev/github.com/symfony/string/slug.php $HOME/.local/bin/slug | |
// # Usage | |
// $ echo "Hello my little 🐰" | slug | |
// hello-my-little-rabbit | |
// $ echo "Bonjour mon petit 🐰" | LOCALE=fr slug | |
// bonjour-mon-petit-lapin | |
require "{$_SERVER['HOME']}/dev/github.com/symfony/string/vendor/autoload.php"; | |
use Symfony\Component\String\Slugger\AsciiSlugger; | |
echo (new AsciiSlugger($_SERVER['LOCALE'] ?? 'en')) | |
->withEmoji($_SERVER['LOCALE'] ?? 'text') | |
->slug(stream_get_contents(STDIN)) | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment