Download the PHP package yorcreative/laravel-urlshortener without Composer

On this page you can find all versions of the php package yorcreative/laravel-urlshortener. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-urlshortener



Laravel URL Shortener

GitHub license GitHub stars GitHub issues GitHub forks Packagist Downloads PHPUnit

A Laravel URL Shortener package that provides URL redirects with optionally protected URL password, URL expiration, open limits before expiration, ability to set feature activation dates, click tracking, custom vanity identifiers, event dispatching, and soft delete/restore out of the box for your Laravel applications.

Requirements

Installation

install the package via composer:

Publish the packages assets.

You can also publish assets by tag.

Run migrations.

Upgrade Guides

Upgrading to v3.x from v2.x

Upgrading to v2.x from v1.x

Usage

Building Short Urls

Finding Existing Short Urls

Deleting & Restoring Short Urls

Getting Click Information

Getting Click Information and Filtering on Ownership

Filter on Outcome

Filter on the Click's YorShortUrl Status

Filtered on YorShortUrl Identifier(s)

Filtered Clicks by UTM parameter(s). These Can be filtered together or individually.

Iterate Through Results With Batches

Putting it all Together

UTM Support

When creating a Short URL, the following UTM parameters are available to attach to the Short URL for advanced tracking of your Short Urls.

UTM information is hidden in the Short URL identifier and clicks are filterable by UTM parameters.

Events

The package dispatches events that you can listen to in your application:

Event Dispatched When Payload
ShortUrlCreated A new short URL is built ShortUrl $shortUrl, string $builtUrl
ShortUrlClicked A short URL is clicked string $identifier, int $outcomeId, string $requestIp, ?string $domain
ShortUrlExpired An expired short URL is accessed ShortUrl $shortUrl, string $identifier, ?string $domain

Multi-Domain Support

v3 introduces multi-domain support, allowing you to host short URLs on multiple domains with per-domain configuration.

Enabling Multi-Domain

Set the environment variable or update your config:

Configuration

Building Short URLs for Specific Domains

Domain-Aware Lookups

Same Identifier on Different Domains

With multi-domain enabled, the same identifier can exist on different domains pointing to different URLs:

Routing

Middleware

The package's routes run through the web middleware group by default. Override this to apply your own stack -- rate limiting the redirect endpoint is the common case:

A single middleware may be given as a string. When multi-domain support is enabled, the domain resolution middleware is appended automatically, so you do not need to list it.

Disabling the Default Routes

Set routing.enabled to false to stop the package registering its routes, then wire the redirect action into your own route file:

The urlshortener.attempt.protected route name is required -- the password-protected view posts to it.

Match the prefix you serve. Generated URLs take their prefix from branding.prefix, not from the routes you register, so serving go/{identifier} while branding.prefix is still something/pretty/cool means every link the package hands back points somewhere you do not serve. Set the prefix to match:

Alternatively, build individual URLs with ->withPrefix('go') and list go under routing.additional_prefixes, which is what that setting is for -- it gates withPrefix() validation, and does not affect the default prefix.

Keep the domain middleware when using multi-domain. ResolveDomain is what enforces domains.validate_domain; without it, requests on unconfigured hosts resolve a domain and redirect rather than returning a 404. Include it in your own stack:

Database Connection

By default the package's models and migrations follow your application's default database connection. To isolate them on their own connection, name it in config:

The named connection must exist in your application's config/database.php. Leaving this null preserves the default behaviour.

Security Features

URL Validation

v3 includes built-in URL validation to prevent open redirect and SSRF attacks. This is disabled by default for backwards compatibility, but recommended for new installations.

Protected against:

When DNS private IP checks are enabled, hostnames are resolved during URL creation and any private or reserved resolved IP is rejected. DNS lookup failures or hosts with no IP records are allowed, so add known internal hostnames to blocked_hosts when they should always be rejected.

Rate Limiting for Password-Protected URLs

Brute-force protection is automatically enabled for password-protected short URLs:

After exceeding the maximum attempts, users receive a 429 Too Many Requests response with a Retry-After header.

Environment Variables

Variable Default Description
URL_SHORTENER_MULTI_DOMAIN false Enable multi-domain support
URL_SHORTENER_DEFAULT_DOMAIN APP_URL Default domain for short URLs
URL_SHORTENER_RESOLUTION_STRATEGY host How to resolve domain from request
URL_SHORTENER_VALIDATE_DOMAIN true Validate requests against configured domains
URL_SHORTENER_DOMAINS_DATABASE false Store domain config in database
URL_SHORTENER_REGISTER_ROUTES true Register the package's redirect routes
URL_SHORTENER_DB_CONNECTION null Database connection for package tables
URL_SHORTENER_VALIDATE_URLS false Enable URL validation (recommended)
URL_SHORTENER_BLOCK_PRIVATE_IPS true Block private/internal IPs
URL_SHORTENER_RESOLVE_DNS_PRIVATE_IPS false Resolve hostnames and block private/reserved IP results
URL_SHORTENER_BLOCK_METADATA true Block cloud metadata endpoints
URL_SHORTENER_PASSWORD_MAX_ATTEMPTS 5 Max password attempts before rate limit
URL_SHORTENER_PASSWORD_DECAY_MINUTES 1 Minutes until rate limit resets

Testing

Credits


All versions of laravel-urlshortener with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/contracts Version ^10.0|^11.0|^12.0|^13.0
stevebauman/location Version ^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package yorcreative/laravel-urlshortener contains the following files

Loading the files please wait ...