From 511275ee1816c8dd822df52409c4b9bb5b211a92 Mon Sep 17 00:00:00 2001 From: Roberto B Date: Mon, 19 Apr 2021 07:21:01 +0200 Subject: [PATCH 1/3] deleting some unused CICD configurations --- .scrutinizer.yml | 19 ------------------- .styleci.yml | 4 ---- .travis.yml | 21 --------------------- 3 files changed, 44 deletions(-) delete mode 100755 .scrutinizer.yml delete mode 100755 .styleci.yml delete mode 100755 .travis.yml diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100755 index df16b68..0000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,19 +0,0 @@ -filter: - excluded_paths: [tests/*] - -checks: - php: - remove_extra_empty_lines: true - remove_php_closing_tag: true - remove_trailing_whitespace: true - fix_use_statements: - remove_unused: true - preserve_multiple: false - preserve_blanklines: true - order_alphabetically: true - fix_php_opening_tag: true - fix_linefeed: true - fix_line_ending: true - fix_identation_4spaces: true - fix_doc_comments: true - diff --git a/.styleci.yml b/.styleci.yml deleted file mode 100755 index f4d3cbc..0000000 --- a/.styleci.yml +++ /dev/null @@ -1,4 +0,0 @@ -preset: laravel - -disabled: - - single_class_element_per_statement diff --git a/.travis.yml b/.travis.yml deleted file mode 100755 index 24c2d6c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -language: php - -php: - - 7.1 - - 7.2 - - 7.3 - -env: - matrix: - - COMPOSER_FLAGS="--prefer-lowest" - - COMPOSER_FLAGS="" - -before_script: - - travis_retry composer self-update - - travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source - -script: - - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover - -after_script: - - php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover From 74f71b061c753c8f80371e9370d57d49ef9194c8 Mon Sep 17 00:00:00 2001 From: Roberto B Date: Fri, 18 Jun 2021 07:18:51 +0200 Subject: [PATCH 2/3] Adding Show Operating System information - PHP script owner's UID - Current User - Operating System - Hostname - Release name - Machine Name - Version info --- src/Console/LaraLensCommand.php | 10 ++++-- src/Lens/LaraLens.php | 3 ++ src/Lens/Traits/OperatingSystemLens.php | 46 +++++++++++++++++++++++++ tests/ConsistencyTest.php | 11 +++++- 4 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 src/Lens/Traits/OperatingSystemLens.php diff --git a/src/Console/LaraLensCommand.php b/src/Console/LaraLensCommand.php index 187765a..b933fa9 100644 --- a/src/Console/LaraLensCommand.php +++ b/src/Console/LaraLensCommand.php @@ -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 . ')} @@ -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() @@ -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()); } @@ -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; diff --git a/src/Lens/LaraLens.php b/src/Lens/LaraLens.php index 8b27864..6d1f62a 100755 --- a/src/Lens/LaraLens.php +++ b/src/Lens/LaraLens.php @@ -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; @@ -16,6 +18,7 @@ class LaraLens use HttpConnectionLens; use RuntimeLens; use FilesystemLens; + use OperatingSystemLens; /** * @var ResultLens diff --git a/src/Lens/Traits/OperatingSystemLens.php b/src/Lens/Traits/OperatingSystemLens.php new file mode 100644 index 0000000..15e340d --- /dev/null +++ b/src/Lens/Traits/OperatingSystemLens.php @@ -0,0 +1,46 @@ + "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; + } +} diff --git a/tests/ConsistencyTest.php b/tests/ConsistencyTest.php index 9fae2d9..1e30911 100644 --- a/tests/ConsistencyTest.php +++ b/tests/ConsistencyTest.php @@ -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(); @@ -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())); + } + } From 52b1c0477c39d4f2c1cc0c3904682187eadbe7f0 Mon Sep 17 00:00:00 2001 From: Roberto B Date: Fri, 18 Jun 2021 07:22:05 +0200 Subject: [PATCH 3/3] Changelog and readme for Operating system information --- CHANGELOG.md | 12 ++++++++++++ README.md | 15 +++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8874062..adea9ff 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ) diff --git a/README.md b/README.md index 523cd14..4177fcd 100755 --- a/README.md +++ b/README.md @@ -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: