PHP code example of devdot / cli-directory-project

1. Go to this page and download the library: Download devdot/cli-directory-project 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/ */

    

devdot / cli-directory-project example snippets


use Devdot\Cli\Command as CliCommand;
use Devdot\Cli\DirectoryProject\WorkingDirectoryTrait;

class Command extends CliCommand
{
    use WorkingDirectoryTrait;

    public function __construct()
    {
        parent::__construct();
    }

    protected function handle(): int
    {
        $this->output->writeln($this->getWorkingDirectory());

        $cwd = $this->getWorkingDirectoryInterface();
        $this->output->writeln($cwd->formatPath('somewhere/relative'));

        return self::SUCCESS;
    }
}


// src/Kernel.php

final class Kernel extends BaseKernel
{
    // ...

    protected array $providers = [
        \Devdot\Cli\DirectoryProject\WorkingDirectoryServiceProvider::class,
        // ..
    ];

    // ..
}