Home
Quick start
Documentation
Forum
GitHub
Home
Quick start
Documentation
Forum
GitHub
  • Quick Start

    • Introduction
    • Why Phico
    • Installation
  • Example app

    • Scaffolding
    • Routes
    • Requests
    • Responses
    • Events
  • Phico

    • CLI
    • Config
    • Container
    • Filesystem
    • Logger
    • Middleware
    • Request
    • Response
    • Router
    • Support
    • View
  • Libraries

    • Authentication
    • Cache
    • CDN
    • Database
    • Http client
    • Locale
    • Mailer
    • Profiler
    • Query
    • Queue
    • Validation
    • Session
    • View
  • Works

    • Introduction

Phico is a work in progress

Phico is currently a work in progress, errors, omissions and changes are to be expected.

CLI

Lightweight terminal support.

Installation

Using composer

composer require phico/cli

Usage

CLI provides a handful of useful methods for terminal interaction.

It is useful when creating your own commands.

Cli

Write a line to the terminal

write('Hello world');
Continue on the same line
write(', this is Phico', $newline = false);
Colour support

Use error(), info(), success(), warning() to display different highlight colours.

Request user input

$input = prompt('What is your name? ');
Limit choices in response
// only one of red, blue or green is accepted
$input = prompt('What is your favourite colour? ', [
    'red',
    'blue',
    'green
]);

Write a title

$input = title('This will be underlined');

// This will be underlined
// =======================

Draw a table


$data = [
    ['Kermit', 'Green'],
    ['Fozzy Bear', 'Brown'],
    ['Miss Piggy', 'Pink'],
    ['Gonzo', 'Blue'],
];
$headings = [ 'Name', 'Colour' ];

table($data, $headings);

Args

Args handles terminal input by organising it into flags (short or long), arguments and values.

Flags

Specify single character flags with a single dash

phico -v

Multiple single flags can be set with a single dash

phico -vrt

Use has() to check if a flag is set

phico -vrt
$args->has('v'); // true
$args->has('r'); // true
$args->has('t'); // true

$args->has('a'); // false
Last Updated:
Contributors: indgy
Next
Config