2017 © Pedro Peláez
 

library urlprefixer

image

germania-kg/urlprefixer

  • Wednesday, September 6, 2017
  • by germania-kg
  • Repository
  • 2 Watchers
  • 0 Stars
  • 49 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Germania KG · UrlPrefixer

Prefix any URL with a base URL, if not absolute or hashtagged “jump link”., (*1)

Packagist PHP version Tests, (*2)

Installation with Composer

$ composer require germania-kg/urlprefixer

Usage

<?php
use Germania\UrlPrefixer\UrlPrefixer;

// Your prefix, normally a 'base URL'
$prefixer = new UrlPrefixer( 'https://myapp.com/project' );

echo $prefixer('/index.html');
// Result: "https://myapp.com/project/index.html"

// If URL is absolute, nothing happens:
echo $prefixer('//dist/styles.css');
// Result: "//dist/styles.css"

// If URL is hashtagged, nothing happens as well:
echo $prefixer('#navigation');
// Result: "#navigation"


Custom URL prefixes

You may pass a second parameter to the Callable to override the default prefix you set with on instantiation:, (*3)

<?php
// Your prefix, normally a 'base URL'
$prefixer = new UrlPrefixer( 'https://myapp.com/project' );

echo $prefixer('/logo.jpg', 'https://cdn.test.com');
// Result: "https://cdn.test.com/logo.jpg"

// Like above, nothing happens when URL is absolute:
echo $prefixer('//dist/styles.css', 'https://cdn.test.com');
// Result: "//dist/styles.css"

Issues

See issues list., (*4)

Development

$ git clone https://github.com/GermaniaKG/UrlPrefixer.git
$ cd UrlPrefixer
$ composer install

Unit tests

Either copy phpunit.xml.dist to phpunit.xml and adapt to your needs, or leave as is. Run PhpUnit test or composer scripts like this:, (*5)

$ composer test
# or
$ vendor/bin/phpunit

The Versions

06/09 2017

dev-develop

dev-develop

  Sources   Download

MIT

The Requires

 

The Development Requires

by Carsten Witt

06/09 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires

by Carsten Witt

11/05 2017

1.0.2

1.0.2.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Carsten Witt

11/05 2017

1.0.1

1.0.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Carsten Witt

11/05 2017

1.0.0

1.0.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Carsten Witt