Skip to content

Commit 452ad92

Browse files
committed
🎉 Initial Commit
0 parents  commit 452ad92

17 files changed

+3627
-0
lines changed

.github/workflows/php.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: PHP Composer
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
17+
- name: Validate composer.json and composer.lock
18+
run: composer validate --strict
19+
20+
- name: Cache Composer packages
21+
id: composer-cache
22+
uses: actions/cache@v2
23+
with:
24+
path: vendor
25+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
26+
restore-keys: |
27+
${{ runner.os }}-php-
28+
29+
- name: Install dependencies
30+
run: composer install --prefer-dist --no-progress
31+
32+
- name: Run test suite
33+
run: composer run-script test

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
.phpunit.result.cache
3+
.composer/
4+
vendor/

Dockerfile

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM php:8-fpm
2+
3+
ARG user=sammy
4+
ARG uid=1000
5+
6+
# Install system dependencies
7+
RUN apt-get update && apt-get install -y \
8+
git \
9+
curl \
10+
vim \
11+
libpng-dev \
12+
libonig-dev \
13+
libxml2-dev \
14+
zip \
15+
unzip
16+
17+
# Clear cache
18+
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
19+
20+
# Install PHP extensions
21+
RUN docker-php-ext-install mbstring exif gd
22+
23+
# Get latest Composer
24+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
25+
26+
# Create system user to run Composer and Artisan Commands
27+
RUN useradd -G www-data,root -u $uid -d /home/$user $user
28+
RUN mkdir -p /home/$user/.composer && \
29+
chown -R $user:$user /home/$user
30+
31+
WORKDIR /home/$user
32+
33+
COPY .. /home/$user
34+
35+
RUN chmod +x /home/$user/runner.sh
36+
37+
USER $user
38+
39+
ENTRYPOINT ["/home/sammy/runner.sh"]

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Alpha Olomi
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Minicli Application Template
2+
3+
This repository is an application template for building command-line applications in PHP with [Minicli](https://github.com/minicli/minicli).
4+
5+
Please check [the official documentation](https://docs.minicli.dev) for more information on how to use this application template.

app/.gitkeep

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace App\Command\Demo;
4+
5+
use Minicli\App;
6+
use Minicli\Command\CommandController;
7+
8+
class DefaultController extends CommandController
9+
{
10+
public function handle(): void
11+
{
12+
$this->getPrinter()->info('Run ./minicli help for usage help.');
13+
}
14+
}

app/Command/Demo/TableController.php

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace App\Command\Demo;
4+
5+
use Minicli\Command\CommandController;
6+
use Minicli\Output\Filter\ColorOutputFilter;
7+
use Minicli\Output\Helper\TableHelper;
8+
9+
class TableController extends CommandController
10+
{
11+
public function handle(): void
12+
{
13+
$this->getPrinter()->display('Testing Tables');
14+
15+
$table = new TableHelper();
16+
$table->addHeader(['Header 1', 'Header 2', 'Header 3']);
17+
18+
for($i = 1; $i <= 10; $i++) {
19+
$table->addRow([(string)$i, (string)rand(0, 10), "other string $i"]);
20+
}
21+
22+
$this->getPrinter()->newline();
23+
$this->getPrinter()->rawOutput($table->getFormattedTable(new ColorOutputFilter()));
24+
$this->getPrinter()->newline();
25+
}
26+
}

app/Command/Demo/TestController.php

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace App\Command\Demo;
4+
5+
use Minicli\Command\CommandController;
6+
7+
class TestController extends CommandController
8+
{
9+
public function handle(): void
10+
{
11+
$name = $this->hasParam('user') ? $this->getParam('user') : 'World';
12+
$this->getPrinter()->display(sprintf("Hello, %s!", $name));
13+
14+
print_r($this->getParams());
15+
}
16+
}

composer.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "minicli/application",
3+
"description": "Minicli Application Template",
4+
"license": "MIT",
5+
"homepage": "https://github.com/minicli/application",
6+
"keywords": ["cli","command-line", "template"],
7+
"autoload": {
8+
"psr-4": {
9+
"App\\": "app/"
10+
}
11+
},
12+
"require": {
13+
"minicli/minicli": "^3.0",
14+
"minicli/command-help": "^0.1.0"
15+
},
16+
"require-dev": {
17+
"pestphp/pest": "^1.21"
18+
},
19+
"scripts": {
20+
"test" : ["pest"]
21+
},
22+
"config": {
23+
"allow-plugins": {
24+
"pestphp/pest-plugin": true
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)