zero-to-prod/validate-url-cli

A CLI for Validating a Url.

v1.1.0 2025-01-28 00:00 UTC

This package is auto-updated.

Last update: 2025-09-02 11:34:27 UTC


README

Repo GitHub Actions Workflow Status GitHub Actions Workflow Status GitHub Actions Workflow Status Packagist Downloads php Packagist Version License wakatime Hits-of-Code

Contents

Introduction

A CLI for Validating a Url.

Requirements

  • PHP 8.1 or higher.

Installation

Install Zerotoprod\ValidateUrlCli via Composer:

composer require zero-to-prod/validate-url-cli

This will add the package to your project's dependencies and create an autoloader entry for it.

Documentation Publishing

You can publish this README to your local documentation directory.

This can be useful for providing documentation for AI agents.

This can be done using the included script:

# Publish to default location (./docs/zero-to-prod/validate-url)
vendor/bin/zero-to-prod-validate-url

# Publish to custom directory
vendor/bin/zero-to-prod-validate-url /path/to/your/docs

Automatic Documentation Publishing

You can automatically publish documentation by adding the following to your composer.json:

{
    "scripts": {
        "post-install-cmd": [
            "zero-to-prod-validate-url"
        ],
        "post-update-cmd": [
            "zero-to-prod-validate-url"
        ]
    }
}

Usage

Run this command to see the available commands:

vendor/bin/validate-url-cli list

Available Commands

validate-url-cli:src

Display the project's GitHub repository URL.

Usage:

vendor/bin/validate-url-cli validate-url-cli:src

Arguments: None

Example:

vendor/bin/validate-url-cli validate-url-cli:src

Output:

https://github.com/zero-to-prod/validate-url-cli

validate-url-cli:validate

Validates a URL and returns the URL if valid, empty output otherwise.

Usage:

vendor/bin/validate-url-cli validate-url-cli:validate <url>

Arguments:

  • url (required): The URL to validate

Example:

vendor/bin/validate-url-cli validate-url-cli:validate "https://example.com"

Output (valid URL):

https://example.com

Example with invalid URL:

vendor/bin/validate-url-cli validate-url-cli:validate "not-a-url"

Output (invalid URL):


validate-url-cli:show-regex

Display the regular expression pattern used to validate URLs.

Usage:

vendor/bin/validate-url-cli validate-url-cli:show-regex

Arguments: None

Example:

vendor/bin/validate-url-cli validate-url-cli:show-regex

Output:

/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/

Docker Image

You can also run the cli using the docker image:

docker run --rm davidsmith3/validate-url-cli

Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page if you want to contribute.

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Commit changes (git commit -m 'Add some feature').
  4. Push to the branch (git push origin feature-branch).
  5. Create a new Pull Request.