Download the PHP package mtymek/mini-url without Composer

On this page you can find all versions of the php package mtymek/mini-url. 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 mini-url

MiniUrl - PSR-7 link minifier

Simple URL shortener written in PHP, using PSR-7 & middleware.

It can be used as a free, open-source replacement for bit.ly's core functionality: creating short links and redirecting users.

Build Status Coverage Status

Installation

Install this library using composer:

Usage

There are many ways of using MiniUrl, depending on your needs. You can incorporate it into your app and use it as a part of your business logic, or you can use provided middleware to create a website that exposes link shortening directly to your users.

Before you start, you need to create new instance of ShortUrlService, pass base URL used for link generation (your short domain) and repository that will take care of storing short URLs:

Short URL service

ShortUrlService is the foundation of MiniUrl - it is what you want to use when you need to shorten URLs inside your application logic.

Shorten link

Expand

Middleware

Typically, URL shortener should expose two functionalities: generating short links and redirecting users to full URLs. MiniUrl comes with handy middleware which makes it extremely easy. Based on PSR-7 standard, they can be easily wrapped inside other middleware that handles authentication or routing.

RedirectMiddleware

When user opens short link in his browser, he is expected to be redirected to destination URL. This can be easily done using RedirectMiddleware. It takes the incoming request, extracts a path part from URI (domain and query are ignored), finds matching long URL and finally redirect user. If link cannot be found in the repository, response with 404 code is returned.

Example usage:

ShortenApiMiddleware

ShortenApiMiddleware provides implementation of API for shortening links.

Example usage:

You can test it using PHP built-in HTTP server:

$ cd path-to-api
$ php -S localhost:8080 shorten-api.php

Create short link using CURL:

Typically, you will want to wrap ShortenApi into another middleware that authorizes your users.

ExpandApiMiddleware

ExpandApiMiddleware provides implementation of API for expanding short links.

Example usage:

You can test it using PHP built-in HTTP server:

$ cd path-to-api
$ php -S localhost:9090 expand-api.php

Expand short link:

See examples directory for working code.

Repositories

MiniUrl can be plugged into existing applications using RepositoryInterface, that handles storing and retrieving ShortUrl objects:

PdoRepository

PdoRepository is a universal repository that allows using MiniUrl with any database (queries are very simple...). In order to use it, you have to pass PDO database handle to repository constructor.

Repository will assume that it can access short_urls table, with following structure:

You can create an empty SQLite database using schema file:


All versions of mini-url with dependencies

PHP Build Version
Package Version
Requires ircmaxell/random-lib Version ~1.1
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 mtymek/mini-url contains the following files

Loading the files please wait ....