PHP code example of violinist-dev / slug-from-url

1. Go to this page and download the library: Download violinist-dev/slug-from-url 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/ */

    

violinist-dev / slug-from-url example snippets




use Violinist\Slug\Slug;

// Probably uou want to use this directly from a URL somehow. Like so:
$slug = Slug::createFromUrl('https://github.com/violinist-dev/slug-from-url');
// Maybe you want the github slug:
$gh_slug = $slug->getSlug();       // Returns violinist-dev/slug-from-url
// Or maybe you want to get the username:
$username = $slug->getUserName();  // Returns violinist-dev
// ...or here is the repo name.
$repo = $slug->getUserRepo();      // Returns slug-from-url