PHP code example of vinogradsoft / path

1. Go to this page and download the library: Download vinogradsoft/path library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vinogradsoft / path example snippets

 


use Vinograd\Path\Path;

AME__Scanner/__NAME2__Driver');

$path->replaceAll([
    '__NAME__' => 'User',
    '__NAME2__' => 'Filesystem',
]);
$path->updateSource();
echo '<br>', $path;
$path->setAll(['path','to','file.txt']);

$path->updateSource();
echo '<br>', $path;
 

Vinograd\Path\Url;

$url = Url::createBlank();

$url->setScheme('https')
    ->setUser('grigor')
    ->setPassword('pass@word')
    ->setHost('host.ru')
    ->setPort('8088')
    ->setPath('/user/index')
    ->setSuffix('.php')
    ->setArrayQuery([
        'key1' => 'value1',
        'key2' => 'value2'
    ])->setFragment('fragment');

$url->updateSource();

printUrl($url);
echo '<br><br>####################################';

$url = new Url('https://grigor:pass%[email protected]:8088/user/index?key1=value1&key2=value2#fragment');
$url->setSuffix('.php');
$url->updateSource();

printUrl($url);

function printUrl($url)
{
    echo '<br><b>Authority:</b> ', $url->getAuthority();
    echo '<br><b>BaseUrl:</b> ', $url->getBaseUrl();
    echo '<br><b>RelativeUrl:</b> ', $url->getRelativeUrl();
    echo '<br><b>AbsoluteUrl:</b> ', $url; //$url->getSource();
    echo '<br>';

    echo '<br><b>getScheme:</b> ', $url->getScheme();
    echo '<br><b>getUser:</b> ', $url->getUser();
    echo '<br><b>getPassword:</b> ', $url->getPassword();
    echo '<br><b>getHost:</b> ', $url->getHost();
    echo '<br><b>getPort:</b> ', $url->getPort();
    echo '<br><b>getPath:</b> ', $url->getPath();
    echo '<br><b>getSuffix:</b> ', $url->getSuffix();
    echo '<br><b>getQuery:</b> ', $url->getQuery();
    echo '<br><b>getFragment:</b> ', $url->getFragment();
}

php composer 
 
Authority: grigor:pass%[email protected]:8088
BaseUrl: https://grigor:pass%[email protected]:8088
RelativeUrl: /user/index.php?key1=value1&key2=value2#fragment
AbsoluteUrl: https://grigor:pass%[email protected]:8088/user/index.php?key1=value1&key2=value2#fragment

getScheme: https
getUser: grigor
getPassword: pass@word
getHost: host.ru
getPort: 8088
getPath: /user/index.php
getSuffix: .php
getQuery: key1=value1&key2=value2
getFragment: fragment

####################################
Authority: grigor:pass%[email protected]:8088
BaseUrl: https://grigor:pass%[email protected]:8088
RelativeUrl: /user/index.php?key1=value1&key2=value2#fragment
AbsoluteUrl: https://grigor:pass%[email protected]:8088/user/index.php?key1=value1&key2=value2#fragment

getScheme: https
getUser: grigor
getPassword: pass@word
getHost: host.ru
getPort: 8088
getPath: /user/index.php
getSuffix: .php
getQuery: key1=value1&key2=value2
getFragment: fragment