PHP code example of ghostwriter / root

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

    

ghostwriter / root example snippets


use Ghostwriter\Root\AbstractRootDirectory;

$appRootDirectory = new readonly class('/tmp/app') extends AbstractRootDirectory {}

// returns the absolute path to the root directory
$appRootDirectory->toString(); // /tmp/app

// returns the absolute path to the src directory
$appRootDirectory->path('src'); // /tmp/app/src

// returns the absolute path to the src/Foo/Bar.php file
$appRootDirectory->path('src', 'Foo', 'Bar.php'); // /tmp/app/src/Foo/Bar.php