Skip to content

Commit

Permalink
Merge pull request #54 from Hi-Folks/develop
Browse files Browse the repository at this point in the history
v0.2.5
  • Loading branch information
roberto-butti authored Jun 18, 2021
2 parents 7a7fbec + 7d84eb0 commit 25647ba
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 47 deletions.
19 changes: 0 additions & 19 deletions .scrutinizer.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .styleci.yml

This file was deleted.

21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# Changelog

## 0.2.5 - 2021-06-18
### Add
- Add some Operating System information:
- PHP script owner's UID
- Current User
- Operating System
- Hostname
- Release name
- Machine Name
- Version info

## 0.2.4 - 2021-04-18
### Add
- In runtime information, added upload_max_filesize and post_max_size from php configuration ( thanks to @yogendra-revanna )
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,21 @@ If your Laravel application doesn't use the database, you can skip the database
php artisan laralens:diagnostic --skip-database
```

### Usage: show some oprating system information
You can show some operating system information like:
- PHP script owner's UID
- Current User
- Operating System
- Hostname
- Release name
- Machine Name
- Version info

using _"--show os"_ option or _"--show all"_ option
```shell
php artisan laralens:diagnostic --show os
```

### Usage: change the style of output table
You can choose one of these styles via *--style=* option:

Expand Down
10 changes: 8 additions & 2 deletions src/Console/LaraLensCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class LaraLensCommand extends Command
{--table=users : name of the table, default users}
{--column-sort=created_at : column name used for sorting}
{--url-path=' . self::DEFAULT_PATH . ' : default path for checking URL}
{--show=* : show (all|config|runtime|connection|database|migration|php-ext|php-ini)}
{--show=* : show (all|config|runtime|connection|database|migration|php-ext|php-ini|os)}
{--width-label=' . self::DEFAULT_WIDTH . ' : width of column for label}
{--width-value=' . self::DEFAULT_WIDTH . ' : width of column for value}
{--style=' . self::DEFAULT_STYLE . ' : style for output table (' . self::TABLE_STYLES . ')}
Expand All @@ -42,7 +42,8 @@ class LaraLensCommand extends Command
public const OPTION_SHOW_MIGRATION = 0b00010000;
public const OPTION_SHOW_PHPEXTENSIONS = 0b00100000;
public const OPTION_SHOW_PHPINIVALUES = 0b01000000;
public const OPTION_SHOW_ALL = 0b01111111;
public const OPTION_SHOW_OS = 0b10000000;
public const OPTION_SHOW_ALL = 0b11111111;
public const OPTION_SHOW_DEFAULT = 0b00011111;

private function allConfigs()
Expand Down Expand Up @@ -205,6 +206,10 @@ private function overview($checkTable = "users", $columnSorting = "created_at",
$output = $ll->getPhpIniValues();
$this->printOutput(["PHP ini config", "Values"], $output->toArray());
}
if ($show & self::OPTION_SHOW_OS) {
$output = $ll->getOsConfigs();
$this->printOutput(["Operating System", "Values"], $output->toArray());
}
$this->printChecks($ll->checksBag->toArray());
}

Expand Down Expand Up @@ -241,6 +246,7 @@ public function handle()
$show = (in_array("migration", $showOptions)) ? $show | self::OPTION_SHOW_MIGRATION : $show ;
$show = (in_array("php-ext", $showOptions)) ? $show | self::OPTION_SHOW_PHPEXTENSIONS : $show ;
$show = (in_array("php-ini", $showOptions)) ? $show | self::OPTION_SHOW_PHPINIVALUES : $show ;
$show = (in_array("os", $showOptions)) ? $show | self::OPTION_SHOW_OS : $show ;
}
} else {
$show = self::OPTION_SHOW_DEFAULT;
Expand Down
3 changes: 3 additions & 0 deletions src/Lens/LaraLens.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use HiFolks\LaraLens\Lens\Traits\DatabaseLens;
use HiFolks\LaraLens\Lens\Traits\FilesystemLens;
use HiFolks\LaraLens\Lens\Traits\HttpConnectionLens;
use HiFolks\LaraLens\Lens\Traits\OperatingSystemLens;
use HiFolks\LaraLens\Lens\Traits\OperationSystemLens;
use HiFolks\LaraLens\Lens\Traits\RuntimeLens;
use HiFolks\LaraLens\ResultLens;

Expand All @@ -16,6 +18,7 @@ class LaraLens
use HttpConnectionLens;
use RuntimeLens;
use FilesystemLens;
use OperatingSystemLens;

/**
* @var ResultLens
Expand Down
46 changes: 46 additions & 0 deletions src/Lens/Traits/OperatingSystemLens.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace HiFolks\LaraLens\Lens\Traits;

use HiFolks\LaraLens\ResultLens;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;

trait OperatingSystemLens
{


private function getUnameValues($results)
{
$modes = [
"s" => "Operating System",
"n" => "Hostname",
"r" => "Release name",
"v" => "Version info",
"m" => "Machine Name",
"a" => "Full infos"
];

foreach ($modes as $key => $title) {
$results->add(
$title,
php_uname($key)
);
}
}

public function getOsConfigs()
{
$results = new ResultLens();
$results->add(
"PHP script owner's UID",
getmyuid()
);
$results->add(
"Current User",
get_current_user()
);
$this->getUnameValues($results);
return $results;
}
}
11 changes: 10 additions & 1 deletion tests/ConsistencyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function test_config_array()
$this->assertIsArray($a->toArray());
$this->assertCount(14, $a->toArray());
$arrayChecks = $l->checksBag->toArray();

$this->assertCount(0, $arrayChecks, "test check config length 0");

$l = new LaraLens();
Expand Down Expand Up @@ -105,4 +105,13 @@ public function test_php_ini_array()
$this->assertGreaterThan(0, count($a->toArray()));
}

/** @test */
public function test_os_config_array()
{
$l = new LaraLens();
$a = $l->getOsConfigs();
$this->assertIsArray($a->toArray());
$this->assertLessThanOrEqual(8, count($a->toArray()));
}

}

0 comments on commit 25647ba

Please sign in to comment.