PHP code example of yiisoft / aliases

1. Go to this page and download the library: Download yiisoft/aliases 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/ */

    

yiisoft / aliases example snippets


use Yiisoft\Aliases\Aliases;

$aliases = new Aliases([
    '@root' => __DIR__,
]);
$aliases->set('@vendor', '@root/vendor');
$aliases->set('@bin', '@vendor/bin');

echo $aliases->get('@bin/phpunit');

$aliases = new Aliases([
    '@root' => '/my/app',
]);

// Value will be ['src' => '/my/app/src', 'tests' => '/my/app/tests']
$directories = $aliases->getAll(['src' => '@root/src', 'tests' => '@root/tests']);

use Yiisoft\Aliases\Aliases;

$aliases = new Aliases([
    '@vendor' => __DIR__ . '/vendor',
    '@vendor/test' => '/special/location'    
]);
echo $aliases->get('@vendor/test');

use Yiisoft\Aliases\Aliases;

$aliases = new Aliases([
    '@root' => __DIR__,
]);
$aliases->remove('@root');