PHP code example of riidme / laravel
1. Go to this page and download the library: Download riidme/laravel 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/ */
riidme / laravel example snippets
use Riidme\Laravel\Facades\Riidme;
$shortUrl = Riidme::shorten('https://example.com/very/long/url');
echo $shortUrl->getShortUrl(); // https://riid.me/abc123
// or simply
echo $shortUrl; // https://riid.me/abc123
use Riidme\Laravel\RiidmeManager;
class UrlController
{
public function __construct(
private RiidmeManager $riidme
) {}
public function shorten(Request $request)
{
$shortUrl = $this->riidme->shorten($request->url);
return response()->json([
'short_url' => $shortUrl->getShortUrl()
]);
}
}
bash
php artisan vendor:publish --tag="riidme-config"