• Час читання ~1 хв
  • 25.08.2022

Коротка URL-адреса від Ash Allen — це пакет Laravel для створення скорочених URL-адрес у ваших програмах Laravel. Щоб розпочати, ви можете легко створити нову коротку URL-адресу за допомогою такого коду:

use AshAllenDesign\ShortURL\Classes\Builder;
 
$builder = new Builder();
 
$shortURLObject = $builder->destinationUrl('https://destination.com')->make();
$shortURL = $shortURLObject->default_short_url;

Ви самі повинні налаштувати та створити короткі URL-адреси навколо наявних даних;наприклад, ви можете створити коротку URL-адресу, коли публікується нова модель публікації.

Цей пакет містить усі основи та низку розширених функцій, щоб почати створювати короткі, URL-адреси для ваших програм, якими можна поділитися. Його основні функції включають:

  • Custom URL Keys
  • Single-use short URLs
  • Enforce HTTPS
  • Configure redirect status code (302 found instead of 301 permanent)
  • Make a short URL active and inactive on a certain date
  • Track Visitors:
    • IP Address
    • Browser Name
    • Browser Version
    • Operating System Name
    • Operating System Version
    • Referrer URL (the URL that the visitor originally came from)
    • Device Type (can be: desktop/mobile/tablet/robot)

Ось більше прикладів роботи з існуючими екземплярами моделі ShortURL із README:

use \AshAllenDesign\ShortURL\Models\ShortURL;
 
// Find URL by key
$shortURL = ShortURL::findByKey('abc123');
 
// Find by destination
$shortURLs = ShortURL::findByDestinationURL('https://destination.com');
 
// Enable tracking to an existing short URL instance
$shortURL->trackingEnabled();
 
// Get model properties, such as visits
$shortURL = ShortURL::find(1);
$visits = $shortURL->visits;
 
// Single-use short URL
$builder = new \AshAllenDesign\ShortURL\Classes\Builder();
 
$shortURLObject = $builder
    ->destinationUrl('https://destination.com')
    ->singleUse()
    ->make();
< h2>Докладніше

Ви можете дізнатися більше про цей пакет, отримати повні інструкції зі встановлення та переглянути вихідний код на GitHub. README містить повну документацію з усім необхідним для налаштування та запуску взаємодіючи з короткими URL-адресами.

Comments

No comments yet
Yurij Finiv

Yurij Finiv

Full stack

Про мене

Professional Fullstack Developer with extensive experience in website and desktop application development. Proficient in a wide range of tools and technologies, including Bootstrap, Tailwind, HTML5, CSS3, PUG, JavaScript, Alpine.js, jQuery, PHP, MODX, and Node.js. Skilled in website development using Symfony, MODX, and Laravel. Experience: Contributed to the development and translation of MODX3 i...

Про автора CrazyBoy49z
WORK EXPERIENCE
Контакти
Ukraine, Lutsk
+380979856297