diff --git a/.github/workflows/check-php81.yml b/.github/workflows/check-php81.yml
index b24cf77..ed7bb50 100644
--- a/.github/workflows/check-php81.yml
+++ b/.github/workflows/check-php81.yml
@@ -17,7 +17,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
- php-versions: [ '8.0','7.4','8.1' ]
+ php-versions: [ '8.0','8.1' ]
dependency-stability: [ 'prefer-none' ]
name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}
diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml
index c78568a..e13fd80 100644
--- a/.github/workflows/php.yml
+++ b/.github/workflows/php.yml
@@ -25,6 +25,6 @@ jobs:
run: composer run-script test
- name: PHP Syntax Checker (Lint)
- uses: StephaneBour/actions-php-lint@7.2
+ uses: StephaneBour/actions-php-lint@8.0
with:
dir: './src'
diff --git a/.github/workflows/test-template.yaml b/.github/workflows/test-template.yaml
index 7c036df..13b50e8 100644
--- a/.github/workflows/test-template.yaml
+++ b/.github/workflows/test-template.yaml
@@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
- php-versions: [ '8.1', '8.0','7.4' ]
+ php-versions: [ '8.1', '8.0' ]
dependency-stability: [ prefer-stable ]
name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 308bab2..d97598b 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
- php-versions: [ '8.1', '8.0','7.4','7.3' ]
+ php-versions: [ '8.1', '8.0' ]
dependency-stability: [ prefer-stable ]
name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3231c9f..7e9d3f7 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
# Changelog
+## 0.3.0 - 2022-07-17
+- Add Termwind package
+- Review console output, thanks also to @exodusanto
+- Support for PHP 8.0 and greater
+
## 0.2.7 - 2022-01-23
- Add Support for Laravel 9
- Add tests for PHP8.1
diff --git a/composer.json b/composer.json
index 61d2f41..73a53e4 100755
--- a/composer.json
+++ b/composer.json
@@ -22,13 +22,14 @@
}
],
"require": {
- "php": "^7.2|^8.0",
+ "php": "^7.4|^8.0|^8.1",
+ "ext-json": "*",
"guzzlehttp/guzzle": "^6.0|^7.0",
"illuminate/support": "^6.0|^7.0|^8.0|^9.0",
- "ext-json": "*"
+ "nunomaduro/termwind": "^1.13"
},
"require-dev": {
- "nunomaduro/larastan": "^0.7.2",
+ "nunomaduro/larastan": "^0.7.2|^1.0.0",
"orchestra/testbench": "4.*|5.*|6.*|7.*",
"phpunit/phpunit": "^8.0|^9.3",
"psalm/plugin-laravel": "^1.5",
diff --git a/resources/views/laralens/term/checks.blade.php b/resources/views/laralens/term/checks.blade.php
new file mode 100644
index 0000000..02dc11a
--- /dev/null
+++ b/resources/views/laralens/term/checks.blade.php
@@ -0,0 +1,50 @@
+
+ @if (sizeof($rows) > 0)
+
+ CHECK: issues found
+
+
+ @else
+
+ CHECK: everything looks good
+
+
+ @endif
+
+ @foreach ($rows as $row)
+ @php
+ $lineType = Arr::get($row, "lineType", HiFolks\LaraLens\ResultLens::LINE_TYPE_DEFAULT);
+ $label = Arr::get($row, "label", "");
+ @endphp
+ @if ($label === "*** HINT")
+
+ 💡 Hint:
+
+
+ {{ Arr::get($row, "value", "") }}
+
+
+
+ @else
+
$lineType === HiFolks\LaraLens\ResultLens::LINE_TYPE_ERROR,
+ 'bg-yellow text-black' => $lineType === HiFolks\LaraLens\ResultLens::LINE_TYPE_WARNING,
+ 'bg-green text-white' => $lineType !== HiFolks\LaraLens\ResultLens::LINE_TYPE_ERROR
+ && $lineType !== HiFolks\LaraLens\ResultLens::LINE_TYPE_WARNING,
+ ])>
+ {{ Arr::get($row, "label", "")}}
+
+
+ @if ($lineType === HiFolks\LaraLens\ResultLens::LINE_TYPE_ERROR)
+ {{ Arr::get($row, "value", "")}}
+ @elseif ($lineType === HiFolks\LaraLens\ResultLens::LINE_TYPE_WARNING)
+ {{ Arr::get($row, "value", "")}}
+ @else
+ {{ Str::replace("\\", "/", Arr::get($row, "value", "")) }}
+ @endif
+
+ @endif
+ @endforeach
+
+
diff --git a/resources/views/laralens/term/table.blade.php b/resources/views/laralens/term/table.blade.php
new file mode 100644
index 0000000..8064cca
--- /dev/null
+++ b/resources/views/laralens/term/table.blade.php
@@ -0,0 +1,52 @@
+
+
+ {{ $title }}
+
+
+
+
+ @foreach ($rows as $row)
+ @php
+ $lineType = Arr::get($row, "lineType", HiFolks\LaraLens\ResultLens::LINE_TYPE_DEFAULT);
+ $label = Arr::get($row, "label", "");
+ @endphp
+ @if ($label === "*** HINT")
+
+
Hint:
+
+
+
+ {{ Arr::get($row, "value", "") }}
+
+
+
+ @else
+
+
+ {{ Arr::get($row, "label", "")}}
+
+
+
+
+
+ @if ($lineType === HiFolks\LaraLens\ResultLens::LINE_TYPE_ERROR)
+
+ {{ Arr::get($row, "value", "")}}
+
+ @elseif ($lineType === HiFolks\LaraLens\ResultLens::LINE_TYPE_WARNING)
+
+ {{ Arr::get($row, "value", "")}}
+
+ @else
+
+ {{ Str::replace("\\", "/", Arr::get($row, "value", "")) }}
+
+ @endif
+
+
+ @endif
+ @endforeach
+
+
+
+
diff --git a/src/Console/LaraLensCommand.php b/src/Console/LaraLensCommand.php
index 2475ae5..0a4004b 100644
--- a/src/Console/LaraLensCommand.php
+++ b/src/Console/LaraLensCommand.php
@@ -3,6 +3,7 @@
namespace HiFolks\LaraLens\Console;
use HiFolks\LaraLens\Lens\LaraLens;
+use HiFolks\LaraLens\Lens\Traits\TermOutput;
use HiFolks\LaraLens\ResultLens;
use Illuminate\Console\Command;
use Illuminate\Support\Arr;
@@ -10,6 +11,8 @@
class LaraLensCommand extends Command
{
+ use TermOutput;
+
private const TABLE_STYLES = 'default|borderless|compact|symfony-style-guide|box|box-double';
private const DEFAULT_STYLE = 'box-double';
private const DEFAULT_PATH = '';
@@ -54,138 +57,30 @@ private function allConfigs(): void
$this->info(json_encode(config()->all(), JSON_PRETTY_PRINT));
}
- private function formatCell($string, $width)
- {
- $retVal = "";
- if (strlen($string) > $width) {
- $retVal = Str::limit($string, $width, '');
- } elseif (strlen($string) < $width) {
- $retVal = str_pad($string, $width);
- } else {
- $retVal = $string;
- }
- return $retVal;
- }
-
- private function printOutput(array $headers, array $rows): void
- {
- $rowsTable = [];
- $rowsLine = [];
- foreach ($rows as $key => $row) {
- $label = Arr::get($row, "label", "");
- $value = Arr::get($row, "value", "");
- if (is_array($value)) {
- $value = implode(",", $value);
- }
- $isLine = Arr::get($row, "isLine", false);
- $lineType = Arr::get($row, "lineType", ResultLens::LINE_TYPE_DEFAULT);
- if (
- strlen($value) > $this->widthValue ||
- $isLine ||
- $lineType === ResultLens::LINE_TYPE_ERROR ||
- $lineType === ResultLens::LINE_TYPE_WARNING
- ) {
- $rowsLine[] = $row;
- } else {
- $row["label"] = $this->formatCell($label, $this->widthLabel);
- $row["value"] = $this->formatCell($value, $this->widthValue);
- $rowsTable[] = [ $row["label"], $row["value"] ];
- }
- }
- /*
- * table style:
- * 'default'
- * 'borderless'
- * 'compact'
- * 'symfony-style-guide'
- * 'box'
- * 'box-double'
- */
- $this->table($headers, $rowsTable, $this->styleTable);
- foreach ($rowsLine as $key => $line) {
- $label = Arr::get($line, "label", "");
- $value = Arr::get($line, "value", "");
- $lineType = Arr::get($line, "lineType", ResultLens::LINE_TYPE_DEFAULT);
- if ($label != "") {
- $this->info($label . ":");
- }
- if ($lineType === ResultLens::LINE_TYPE_ERROR) {
- $this->error($value);
- } elseif ($lineType === ResultLens::LINE_TYPE_WARNING) {
- $this->warn($value);
- } else {
- $this->line($value);
- }
- }
- }
-
- private function alertGreen($string): void
- {
- $length = Str::length(strip_tags($string)) + 12;
- $this->info(str_repeat('*', $length));
- $this->info('* ' . $string . ' *');
- $this->info(str_repeat('*', $length));
- $this->output->newLine();
- }
-
- private function printChecks(array $rows): void
- {
- if (sizeof($rows) == 0) {
- $this->alertGreen("CHECK: everything looks good");
- } else {
- $this->alert("CHECK: issues found");
- }
- $idx = 0;
- foreach ($rows as $key => $row) {
- $label = Arr::get($row, "label", "");
- $value = Arr::get($row, "value", "");
- $isLine = Arr::get($row, "isLine", false);
- $lineType = Arr::get($row, "lineType", ResultLens::LINE_TYPE_DEFAULT);
- if (
- ($label !== "") &&
- (($lineType === ResultLens::LINE_TYPE_ERROR) ||
- ResultLens::isMessageLine($lineType))
- ) {
- $idx++;
- $this->warn("--- " . $idx . " ------------------");
- $this->warn("*** " . $label);
- }
- if ($lineType === ResultLens::LINE_TYPE_ERROR) {
- $this->error($value);
- } elseif ($lineType === ResultLens::LINE_TYPE_WARNING) {
- $this->warn($value);
- } elseif ($lineType === ResultLens::LINE_TYPE_INFO) {
- $this->info($value);
- } else {
- $this->comment($value);
- }
- }
- }
-
private function overview($checkTable = "users", $columnSorting = "created_at", $show = self::OPTION_SHOW_ALL): void
{
$ll = new LaraLens();
if ($show & self::OPTION_SHOW_CONFIGS) {
$output = $ll->getConfigs();
- $this->printOutput(["Config keys via config()", "Values"], $output->toArray());
+ $this->printOutputTerm("Config keys via config()", $output->toArray());
}
if ($show & self::OPTION_SHOW_RUNTIMECONFIGS) {
$output = $ll->getRuntimeConfigs();
- $this->printOutput(["Runtime Configs", "Values"], $output->toArray());
+ $this->printOutputTerm("Runtime Configs", $output->toArray());
$output = $ll->checkServerRequirements();
- $this->printOutput(["Laravel Requirements", "Values"], $output->toArray());
+ $this->printOutputTerm("Laravel Requirements", $output->toArray());
}
if ($show & self::OPTION_SHOW_RUNTIMECONFIGS) {
$output = $ll->checkFiles();
- $this->printOutput(["Check files", "Values"], $output->toArray());
+ $this->printOutputTerm("Check files", $output->toArray());
}
if ($show & self::OPTION_SHOW_CONNECTIONS) {
$output = $ll->getConnections($this->urlPath);
- $this->printOutput(["Connections", "Values"], $output->toArray());
+ $this->printOutputTerm("Connections", $output->toArray());
}
if ($show & self::OPTION_SHOW_DATABASE) {
$output = $ll->getDatabase($checkTable, $columnSorting);
- $this->printOutput(["Database", "Values"], $output->toArray());
+ $this->printOutputTerm("Database", $output->toArray());
}
if ($show & self::OPTION_SHOW_MIGRATION) {
try {
@@ -201,22 +96,22 @@ private function overview($checkTable = "users", $columnSorting = "created_at",
$e->getMessage(),
"Check the Database configuration"
);
- $this->printOutput(["Migration" , "result"], $r->toArray());
+ $this->printOutputTerm("Migration", $r->toArray());
}
}
if ($show & self::OPTION_SHOW_PHPEXTENSIONS) {
$output = $ll->getPhpExtensions();
- $this->printOutput(["PHP Extensions"], $output->toArray());
+ $this->printOutputTerm("PHP Extensions", $output->toArray());
}
if ($show & self::OPTION_SHOW_PHPINIVALUES) {
$output = $ll->getPhpIniValues();
- $this->printOutput(["PHP ini config", "Values"], $output->toArray());
+ $this->printOutputTerm("PHP ini config", $output->toArray());
}
if ($show & self::OPTION_SHOW_OS) {
$output = $ll->getOsConfigs();
- $this->printOutput(["Operating System", "Values"], $output->toArray());
+ $this->printOutputTerm("Operating System", $output->toArray());
}
- $this->printChecks($ll->checksBag->toArray());
+ $this->printChecksTerm($ll->checksBag->toArray());
}
diff --git a/src/Lens/Traits/TermOutput.php b/src/Lens/Traits/TermOutput.php
new file mode 100644
index 0000000..aca7e07
--- /dev/null
+++ b/src/Lens/Traits/TermOutput.php
@@ -0,0 +1,29 @@
+ $title,
+ 'rows' => $rows
+ ])
+ );
+ }
+
+ public function printChecksTerm(array $rows): void
+ {
+ render(
+ view('lara-lens::laralens.term.checks', [
+ 'rows' => $rows
+ ])
+ );
+ }
+}