PHP code example of germania-kg / pathserviceprovider

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

    

germania-kg / pathserviceprovider example snippets



use Germania\PathServiceProvider\PathServiceProvider;

// A. Use with Slim or Pimple
$app = new \Slim\App;
$dic = $app->getContainer();
$dic = new Pimple\Container;

// B. Register Service Provider. Paths array is optional.
$sp = new PathServiceProvider;
$sp = new PathServiceProvider( [
	'var',
	'templates'	
]);

$dic->register( $sp  );

// C. Pass optional callable
$sp = new PathServiceProvider( $paths, function( $path ) {
	return '/path/to/project/' . $path;
});
$dic->register( $sp  );

$paths = $dic['Paths'];
// array(
// 	'var',
// 	'templates'	
// )

$prefixer = $dic['Paths.Prefixer'];

$absolute_paths = $dic['Paths.absolute'];