Download the PHP package iceylan/urlify without Composer

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

Urlify

Urlify is a lightweight, object-oriented PHP library designed for parsing, manipulating, and reconstructing URLs in a highly modular and intuitive way.

It provides fine-grained access to every component of a URL, such as scheme, authorization, host, path, query, and fragment through dedicated classes. Unlike typical URL parsers that only offer string-based access, Urlify structures these components as first-class objects, enabling more powerful and flexible manipulations.


🧩 Why Use Urlify?

URLs are often treated as plain strings, but in modern applications, we frequently need to:

Urlify abstracts all of this with clean, readable, and immutable-friendly interfaces, while giving you full control over the inner structure of the URL.


🧱 Architecture Overview

Urlify is built around a component-based architecture, where each part of the URL is encapsulated in its own class:

Component Class Responsibility
Scheme Scheme Handles URL scheme (e.g., http, https, ftp, etc.)
Host Host Handles domain or IP address, subdomains, and port
Path Path Manages the path portion of the URL
Query Query Represents the query string as a structured, iterable object
Fragment Fragment Represents the URL fragment (#...), also compatible with Query
Entry QueryEntry Represents an individual key-value pair or flag in the query
URL Url Central orchestrator class that ties all parts together

All of these classes are designed to be loosely coupled and easily testable.


πŸ”§ Primary Features


βœ… Use Cases


πŸ“¦ Installation

Urlify can be installed via Composer, the standard PHP dependency manager.

After installation, make sure to include Composer’s autoloader in your project:

All Urlify classes are namespaced under Iceylan\Urlify. You can either import specific classes or use them directly with their fully qualified names:

ℹ️ Urlify is compatible with PHP 8.1 or higher.


⚑ Quick Example

Let’s say you have a URL where a query string is embedded inside a path segment. Let's make it more compicated and add another level of nesting with a different separation. Now let's say you want to extract a value from that messy URL.

We can easily chain the above code into a single liner:

This example shows how flexible Urlify can be:

It separates the URL structure cleanly. You can treat path segments as independent values. You can easily re-parse segments, fragments, or query strings as new Query objects.


πŸ”§ Basic Usage

The Url class is the main entry point to working with URL components. Once instantiated, it provides clean access to each part of the URL, and allows full manipulation with method chaining.

πŸ”Ή Creating a URL instance

πŸ”Ή Accessing URL Components

πŸ”Ή Modifying the URL

We can set a value for a segment and the value we give it will be parsed.

All setters return $this, so they support method chaining:

Each component (path, query, fragment) has its own powerful interface. In the next sections, we'll dive deeper into those.

πŸ”Ή String Conversion

You can also cast the URL object into string directly:

πŸ”Ή Array Conversion

Or you can also convert it to an array:

πŸ”Ή JSON Serialization

And finally, you can convert it to JSON:

and output:


🧩 Builder Mode

You can also use Urlify as a URL builder. It's a simple way to create URLs from scratch.

You can also use component methods to modify them more precisely:

We can also keep the chain alive with builder methods, for example:


πŸ”Έ Scheme

The scheme (also known as "protocol") represents the beginning of a URL and indicates how resources should be accessed, for example: http, https, ftp, etc.

The Url::$scheme property holds an instance of the Iceylan\Urlify\Scheme class, which allows both manipulation and introspection of the scheme.

πŸ“₯ Instantiating

Accessing via Url object:

Using Scheme class standalone:

Without an initial value:

πŸ‘οΈ Getting the Scheme

You can retrieve the current scheme:

If not set, it returns null or an empty string on cast.

✍️ Setting the scheme

Set the scheme value:

Or set it through Url:

Urlify reconizes the known schemes and automatically appends the correct suffix.

🧹 Cleaning the scheme

Clear the scheme completely:

Alternative methods:

πŸ” Is the scheme secure?

Check whether the scheme is marked as secure:

πŸ€” Is the scheme known?

Determine if the scheme is one of the known/registered ones:

βž• Registering a custom scheme

Custom schemes can be registered globally:

πŸ”„ JSON Serialization

Scheme objects can be serialized into JSON.

Yields:


πŸ”Έ Auth

The auth property holds an instance of the Iceylan\Urlify\Auth class which represents the authentication part of a URL (i.e., username:password@).

πŸ“₯ Instantiating

You can access the auth part directly via the Url instance:

Or use the Auth class directly:

Or even instantiate without any credentials:

πŸ‘οΈ Reading Username and Password

You can retrieve the username and password values separately.

If either is not set, null is returned.

✍️ Setting Username and Password

Credentials can be set individually or together:

Partial credentials are also supported:

🧹 Cleaning Credentials

Clear all authentication data with:

Or reset via setters:

On Url:

❓ Check If Empty

Determine whether the auth section (both username and password) is currently empty:

πŸ“€ JSON Serialization

Auth objects can be converted into JSON.

Result:


πŸ”Έ Host

The host component of a URL specifies the domain address that identifies the resource's location on the network. In Urlify, the host property is an instance of the Iceylan\Urlify\Host class, providing methods for manipulation and inspection of the host part.

This library uses a list of top-level domain names to separate the top-level domain names. It doesn't just take the latest part of a string separated by dots and treat it as the main domain. This approach tells us that co.uk is a top-level domain name.

πŸ“₯ Instantiating

Accessing host instance via Url object:

Using Host class standalone:

Without an initial value:

πŸ‘οΈ Retrieving Host Parts

After setting the host, you can retrieve host parts by meaningful methods.

If any of these is not set, null is returned.

✍️ Manupulating Host

You can manipulate the host parts with powerful methods.

Set Host As a Whole String

Sometimes setting the host with a whole string is can be enough for you. We have a method for this:

When the set method is called, parsing processes will be start for given host and all the getter methods will return the parsed values.

You can also set the host directly on the Url object:

Subdomain Manipulations

Sometimes you need to set the subdomain as a whole string. We have a method for this:

You may also need to append or prepend existing subdomains.

Primary Domain Manipulations

You can also set the primary domain name with the setPrimaryDomainName method:

Top Level Domain Manipulations

You can also set the top-level domain name with the setTopLevelDomainName method:

🧹 Clearing the Host

Clear the host completely:

πŸ“€ JSON Serialization

Host objects can be converted into JSON.

Result:


πŸ”Έ Port

The port component of a URL specifies the port number used for communication with the resource.

πŸ“₯ Instantiating

Accessing port instance via Url object:

Using Port class standalone:

Without an initial value:

πŸ‘οΈ Retrieving Port

After setting the port, you can retrieve the port with the get method:

If the port is not set, null is returned.

✍️ Setting Port

You can set the port with the set method:

Checking if Port is Defined

You can check if the port is defined with the isEmpty method:

Retrieving Effective Port

You can retrieve the effective port with the getEffective method. Effective port is the port set or the default port for the scheme if the port is not set.

Default Port

You can use Port class to query the default port for a given scheme:

🧹 Clearing the Port

Clear the port completely:

πŸ“€ JSON Serialization

Port objects can be converted into JSON.

Result:



All versions of urlify with dependencies

PHP Build Version
Package Version
Requires larapack/dd 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 iceylan/urlify contains the following files

Loading the files please wait ...