• Время чтения ~0 мин
  • 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