PHP code example of micropackage / filesystem

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

    

micropackage / filesystem example snippets


use Micropackage\Filesystem\Filesystem;

$filesystem = new Filesystem( __DIR__ );

echo $filesystem->path();
// /var/www/html/wp-content/plugins/my-plugin/

echo $filesystem->path( 'src/templates/full-width.php' );
// /var/www/html/wp-content/plugins/my-plugin/src/templates/full-width.php

echo $filesystem->url();
// https://my.plugin/wp-content/plugins/my-plugin/

echo $filesystem->url( 'assets/images/logo.svg' );
// https://my.plugin/wp-content/plugins/my-plugin/assets/images/logo.svg

printf( '<img src="%s">', $filesystem->image_to_base64( 'assets/images/logo.svg' ) );
// <img src="data:image/svg+xml;base64,m8q76v7wy4guiev...">