2017 © Pedro Peláez
 

library actus

PHP virtual path library

image

sunkan/actus

PHP virtual path library

  • Thursday, February 1, 2018
  • by sunkan
  • Repository
  • 0 Watchers
  • 0 Stars
  • 614 Installations
  • 2 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 2 % Grown

The README.md

JBZoo Path

This is a fork of https://github.com/JBZoo/Path. I needed it to be easy to configure with DI, (*1)

Virtual file system

License Latest Stable Version, (*2)

How to use

require_once './vendor/autoload.php'; // composer autoload.php

//  Get needed classes.
use Actus\Path;

//  Get path instance.
$path = new Path();

//  Setup root directory.
$path->setRoot(__DIR__);

// Set multiple aliases
$path->setAliases([
  'less' => [
    __DIR__ . 'styles/folder/less',
    __DIR__ . 'theme/styles/less',
  ],
  'css' => [
    __DIR__ . 'styles/folder/css',
    __DIR__ . 'theme/styles/css',
  ]
]);

//  Add paths.
$path->add(__DIR__ . '/styles/css', 'css');
$path->add(__DIR__ . '/simple/styles/css', 'css');

//  Add array paths.
$path->add(array(
    __DIR__ . 'styles/folder/less',
    __DIR__ . 'theme/styles/less',
), 'less');

/**
 * Add paths by virtual.
 * If you already added at least one one way, you can use the virtual paths
 */
$path->add('less:assets/less');
$path->add('css:assets/less');

//  Get added path list by key.
var_dump($path->getPaths('css:'));
var_dump($path->getPaths('less:'));

/**
 * Get full path for the first file found, if file exits.
 */
echo $path->get('css:styles.css');           //  result: C:/Server/jbzoo/styles/css/styles.css
echo $path->get('less:path/to/styles.less'); //  result: C:/Server/jbzoo/styles/folder/less/path/to/styles.less

/**
 * Get url for the first file found, if file exits.
 * If - "C:/Server/jbzoo" is root dir we have...
 */
$path->url('css:styles.css');           //  http://my-site.com/styles/css/styles.css
$path->url('less:path/to/styles.less')  //  http://my-site.com/styles/css/folder/less/path/to/styles.less

echo '<link rel="stylesheet" href="' . $path->url('css:styles.css') . '">';

/**
 * Need remove added path?
 * Second parameter is the key of the paths array.
 */
$path->remove('less:', array(1));

//  or use string
$path->remove('less:', 1);

//  Clean path.
$path->clean('C:\server/folder\\\file.txt'); // result: 'C:/server/folder/file.txt'
$path->clean('path\\to//simple\\folder')    //  result: 'path/to/simple/folder'

The Versions

01/02 2018

dev-develop

dev-develop https://bitbucket.org/sunkan/actus

PHP virtual path library

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

The Development Requires

by Sergey Kalistratov
by Andreas Sundqvist

01/02 2018

dev-master

9999999-dev https://bitbucket.org/sunkan/actus

PHP virtual path library

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

The Development Requires

by Sergey Kalistratov
by Andreas Sundqvist

01/02 2018

2.0.0

2.0.0.0 https://bitbucket.org/sunkan/actus

PHP virtual path library

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

The Development Requires

by Sergey Kalistratov
by Andreas Sundqvist

16/03 2016

1.1.0

1.1.0.0

PHP virtual path library

  Sources   Download

MIT

The Requires

  • php >=5.3.10

 

The Development Requires

by Sergey Kalistratov
by Andreas Sundqvist

16/03 2016

1.0.1

1.0.1.0

PHP virtual path library

  Sources   Download

MIT

The Requires

  • php >=5.3.10

 

The Development Requires

by Sergey Kalistratov
by Andreas Sundqvist