Repository: Hi-Folks/lara-lens
Branch: develop
Commit: f323ffc47f52
Files: 42
Total size: 85.6 KB
Directory structure:
gitextract_66wvtac2/
├── .editorconfig
├── .gitattributes
├── .github/
│ └── workflows/
│ ├── php-code-quality.yml
│ └── php-lint.yml
├── .gitignore
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE.md
├── README.md
├── composer.json
├── config/
│ └── config.php
├── phpcs.xml
├── phpstan.neon
├── phpunit.xml.dist
├── phpunit.xml.dist.bak
├── pint.json
├── psalm.xml
├── rector.php
├── resources/
│ └── views/
│ └── laralens/
│ ├── index.blade.php
│ └── term/
│ ├── checks.blade.php
│ └── table.blade.php
├── routes/
│ └── web.php
├── src/
│ ├── Console/
│ │ └── LaraLensCommand.php
│ ├── Http/
│ │ └── Controllers/
│ │ ├── Controller.php
│ │ └── LaraLensController.php
│ ├── LaraLensFacade.php
│ ├── LaraLensServiceProvider.php
│ ├── Lens/
│ │ ├── LaraHttp.php
│ │ ├── LaraLens.php
│ │ ├── Objects/
│ │ │ └── LaraHttpResponse.php
│ │ └── Traits/
│ │ ├── BaseTraits.php
│ │ ├── ConfigLens.php
│ │ ├── DatabaseLens.php
│ │ ├── FilesystemLens.php
│ │ ├── HttpConnectionLens.php
│ │ ├── OperatingSystemLens.php
│ │ ├── RuntimeLens.php
│ │ └── TermOutput.php
│ └── ResultLens.php
└── tests/
├── Feature/
│ └── ConsistencyTest.php
├── Pest.php
└── TestCase.php
================================================
FILE CONTENTS
================================================
================================================
FILE: .editorconfig
================================================
; This file is for unifying the coding style for different editors and IDEs.
; More information at http://editorconfig.org
root = true
[*]
charset = utf-8
indent_size = 4
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
================================================
FILE: .gitattributes
================================================
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
# Ignore all test and documentation with "export-ignore".
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/phpunit.xml.dist export-ignore
/.scrutinizer.yml export-ignore
/tests export-ignore
/.editorconfig export-ignore
================================================
FILE: .github/workflows/php-code-quality.yml
================================================
name: Code Quality Workflow
on:
push:
branches:
- develop
- features/**
- feature/**
- upgrade/**
pull_request:
branches: [ develop ]
jobs:
laravel-tests:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: [ '8.4', '8.3', '8.2', '8.1' ]
dependency-stability: [ 'prefer-stable','prefer-lowest' ]
runs-on: ${{ matrix.operating-system }}
name: Test P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}
steps:
- uses: actions/checkout@v4
- name: Install PHP versions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Update Dependencies with latest stable
if: matrix.dependency-stability == 'prefer-stable'
run: composer update --prefer-stable
- name: Update Dependencies with lowest stable
if: matrix.dependency-stability == 'prefer-lowest'
run: composer update --prefer-stable --prefer-lowest
# Code quality
- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
SESSION_DRIVER: array
run: composer test
laravel-check:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: [ '8.3' ]
runs-on: ${{ matrix.operating-system }}
name: Check P${{ matrix.php-versions }} - ${{ matrix.operating-system}}
steps:
- uses: actions/checkout@v4
- name: Install PHP versions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Execute Code Sniffer via phpcs
run: |
composer style-fix
- name: Execute Code Static Analysis (PHP Stan + Larastan)
run: |
composer phpstan
================================================
FILE: .github/workflows/php-lint.yml
================================================
name: PHP Syntax Checker (Lint)
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate composer.json and composer.lock
run: composer validate
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Run test suite
run: composer run-script test
- name: PHP Syntax Checker (Lint)
uses: StephaneBour/actions-php-lint@8.3
with:
dir: './src'
================================================
FILE: .gitignore
================================================
build
docs
composer.lock
vendor
coverage
.phpunit.result.cache
.phpunit.cache/
.idea
.php_cs.cache
.vscode
================================================
FILE: CHANGELOG.md
================================================
# Changelog
## 1.0.1 - 2024-11-29
- Upgrade to PHP 8.4
## 1.0.0 - 2024-03-13
- upgrading packages
## 0.5.2 - 2024-03-12
- Updating hints for missing lang directory
## 0.5.1 - 2024-03-07
- Detect dependencies for Laravel 11
## 0.5.0 - 2024-03-07
- Support for Laravel 11
## 0.4.1 - 2023-11-18
- Testing with PHP 8.3
- Adding title helper in the TermOutput
- Adding RectorPHP in the code quality tools
## 0.4.0 - 2023-02-04
- Support for Laravel 10
- Add requirements check for Laravel 10
- GitHub Actions Workflows: cleaning and fine-tuning
- Using Pint for Check styleguide (PSR12)
- Using PestPHP for testing
- Removing Makefile and using composer scripts to launching code quality tools
- migrating tests from PHPUnit to PestPHP, thanks to @dansysanalyst
- Fix skip-database option, now with works with all "show" options. Before the fix it worked only with "show all" option.
## 0.3.1- 2022-07-17
- Fine tuning dependencies for PHP 8.1, and Symfony / Doctrine packages
- Drop supprt for PHP7.4, for older PHP and Laravel, use Laralens v0.2.x
## 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
- Drop support for PHP7.3
- Some fine tuning for Static Code analysis
## 0.2.6 - 2021-10-03
Hacktoberfest!!!
We would like to say thank you to @tweichart and @martijnengler for the contributions.
### Add
- Add --all option for showing all information (verbose output). Thanks to @tweichart
- Add --large option for using 120 chars width. Thanks to @martijnengler
## 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 )
## 0.2.3 - 2021-04-10
### Add
- Check DEBUG and ENV configuration for production (if production avoid having debug on);
- Check Storage Links and show the user a waring if some directory links are missing
### Change
- improve tests and checks script for Workflows
## 0.2.2 - 2020-11-05
### Add
- Add configuration parameters (config/lara-lens.php) for managing webview: LARALENS_PREFIX, LARALENS_MIDDLEWARE, LARALENS_WEB_ENABLED, thanks to @yogendra-revanna, @JexPY, @Zuruckt;
- Initial support for PHP8-rc;
## 0.2.1 - 2020-09-22
### Add
- Show available PHP extension via --show=php-ext option (thanks to https://github.com/yogendra-revanna);
- Show PHP ini configuration via --show=php-ini (thanks to https://github.com/yogendra-revanna).
### Change
- Managing default show options. Before this change the default was to show all options. Now we have a lot of option to show (also the long list of PHP extension and PHP ini configuration), so by default LaraLens shows: configuration, runtime, HTTP connection, database, migrations.
## 0.2.0 - 2020-09-20
### Add
- You can watch your LaraLens report with your browser (not just with your terminal);
- Makefile to manage development tasks;
- Add a _timeout_ when checking HTTP connection;
- CI/CD: Add Caching vendors in GitHub actions pipeline.
### Change
- DOCS: Update README, add some docs about skip database connection and database.
## 0.1.20 - 2020-09-11
### Fix
Thanks to [phpstan](https://github.com/phpstan/phpstan) :
- using $line instead of $row
- initialize correctly $show
- re throw exception for HTTP connection
## 0.1.19 - 2020-09-11
### Add
- Add --skip-database in order to execute all checks except database and migration status (it is useful for example if the application it doesn't need the database);
### Change
- Code more PSR2 compliant (phpcs);
- Fix LaraHttpResponse::status(). The method returns the http status code. Close #19
## 0.1.18 - 2020-09-05
### Add
- Support for Laravel 8
## 0.1.17 - 2020-08-30
### Add
- Adding support for Laravel 6
- Check server requirements for PHP modules needed by Laravel;
- Check server requirements for PHP Version (based on the Laravel version);
- Adding PORT display for Database connection;
- List PHP modules installed, needed by Laravel;
### Change
- Updating test cases
## 0.1.16 - 2020-08-19
### Add
- Adding php linter in CI/CD. We use php 7.2 linter for incoming support to Laravel 6.
### Fix
- Fix syntax in DatabaseLens.php. Close #17 ;
## 0.1.15 - 2020-08-09
### Add
- Add --url-path for using a specific path during HTTP connection. For example --url-path=test (for checking "test" path)
### Change
- Refactor logic with traits for: database connection, configuration, runtime parameters, filesystem, http connections (issue #11);
- Improve the HTTP Connection check (configuration url, url generated)
## 0.1.14 - 2020-08-04
- Refactoring "check" functionality
- add warning messages
- show report check
- add alert green
- managing multiple type of message (warning / error / hint)
- try catch for db connection, for checking files, for scanning directories
- check PDO for database connection
## 0.1.13 - 2020-07-31
### Add
- Add hints for database tables (table exists, column exists)
### Change
- Fix typo in banner. ( close #6 )
- updated tests
## 0.1.12 - 2020-07-25
### Add
- When a check is not working properly, now it is displayed some hints;
- Add hints for database connection;
- Add hints for HTTP connections.
## 0.1.11 - 2020-07-12
### Add
### Change
- Improved list of languages;
- Update readme
## 0.1.10 - 2020-06-25
### Add
New function for check files.
- check .env file
- check language storage
- list languages available
## 0.1.9 - 2020-06-18
### Add
New runtime config about some paths:
* "langPath" =>"Path to the language files",
* "publicPath" =>" Path to the public / web directory",
* "storagePath" => "Storage directory",
* "resourcePath" =>"Resources directory",
* "getCachedServicesPath" => "Path to the cached services.php",
* "getCachedPackagesPath" => "Path to the cached packages.php",
* "getCachedConfigPath" => "Path to the configuration cache",
* "getCachedRoutesPath" => "Path to the routes cache",
* "getCachedEventsPath" => "Path to the events cache file",
* "getNamespace" => "Application namespace"
## 0.1.8 - 2020-06-18
### Add
:nail_care: Style output table via --style option. You can choose one of these styles (box-double is the default used by LaraLens):
* default
* borderless
* compact
* symfony-style-guide
* box
* box-double
:eyeglasses: Runtime config:
* environmentPath
* environmentFile
* environmentFilePath
### Change
* Refactor for App::"function"()
* update tests
* update readme
* update help (-h)
## 0.1.7 - 2020-06-16
### Add
Database connection:
* connection name
* getQueryGrammar
* getDriverName
* getDatabaseName
* getTablePrefix
* database server version
Runtime configuration:
* Laravel version
* PHP version
## 0.1.6 - 2020-06-01
### Add
* Add show option --show (all|config|runtime|connection|database|migration)
## 0.1.5 - 2020-05-29
### Improve
* managing a better output
* extracting long message from tables
* settings width for columns tables
## 0.1.4 - 2020-05-28
### Fix
* Catch HTTP connection exception
## 0.1.3 - 2020-05-27
### Add
* detect DB connection type;
* get tables for mysql;
* get tables for sqlite;
* count and retrieve last row from a table. Table and column name are as input parameters;
* test database diagnostics;
* update readme for documentation.
## 0.1.2 - 2020-05-22
### Add
* Add new argument as input (it is optional):
- overview: you can see configuration, http connection, db connection etc.;
- allconfigs: you can see the verbose configuration from Laravel application. Try to use 'php artisan laralens:diagnostic allconfigs' in your laravel application. You will see the dump of all configuration parameters in json format.
## 0.1.1 - 2020-05-22
### Add
* Add runtime config:
* App::getLocale()
* App::environment())
* Generated url via asset() and url() helpers
* Invoke migrate:status
## 0.1.0 - 2020-05-21
* :tada: initial release
* Add laralens:diagnostic artisan command (Laravel)
* Check config parameter like app.url, app.locale, app.url and database.*
* Check the http connection with "app.url" defined in base configuration
* Check the connection with DB and counts the row for a specific table (users by default)
================================================
FILE: CONTRIBUTING.md
================================================
# Contributing
Contributions are **welcome** and will be fully **credited**.
Please read and understand the contribution guide before creating an issue or pull request.
## Etiquette
This project is open source, and as such, the maintainers give their free time to build and maintain the source code
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
extremely unfair for them to suffer abuse or anger for their hard work.
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
world that developers are civilized and selfless people.
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
## Viability
When requesting or submitting new features, first consider whether it might be useful to others. Open
source projects are used by many developers, who may have entirely different needs to your own. Think about
whether or not your feature is likely to be used by other users of the project.
## Procedure
Before filing an issue:
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
- Check to make sure your feature suggestion isn't already present within the project.
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
- Check the pull requests tab to ensure that the feature isn't already in progress.
Before submitting a pull request:
- Check the codebase to ensure that your feature doesn't already exist.
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
## Open a Pull Request
In order to maintain consistency in the source code we are following PSR12 coding standard, and using PHP stan for static code analysis.
You can use the command:
```
make allcheck
```
to launch
- **[PSR-12 Coding Standard](https://www.php-fig.org/psr/psr-12/)**, under the hood is used [PintPHP](https://laravel.com/docs/9.x/pint);
- **PHPstan** with [level 5](https://phpstan.org/user-guide/rule-levels)
- **PestPHP** to execute all tests from ./tests/*
I suggest to launch *composer all* before to commit or before to create PR.
If you want to work on a PR, I suggest you to creating a new branch starting from **develop branch**, and use it also when you will submit your new **P**ull **R**equest on the original repository.
If you want to contribute with an high quality PR, I suggest you to focus not just on the source code but also:
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
**Happy coding**!
================================================
FILE: LICENSE.md
================================================
MIT License
Copyright (c) Roberto Butti
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# LaraLens





## What
**LaraLens** is a _Laravel_ artisan command to show you the current configuration of your
application. It is useful to show in your terminal the status of:
* some useful configuration variable;
* the database connection;
* the tables in the database;
* the connection via HTTP request;
* the server requirements (PHP version, PHP modules required and installed, Laravel version etc.).

## Why
When I have a new Laravel Application deployed on the target server, usually I perform a list of commands in order to check the configuration, the connection to database, inspect some tables, the response of the web server.
I tried to show more information in just one command.
This is useful also when the installation of your Laravel application is on premises, and someone else takes care about the configuration. So, in this scenario usually, as developer, your first question is: "how is configured the application?".
## Installation
You can install the package via composer:
```shell script
composer require hi-folks/lara-lens
```
The Packagist page is:
https://packagist.org/packages/hi-folks/lara-lens
## Usage
```shell script
php artisan laralens:diagnostic
```
### Usage: control database connection
You can see Database Connection information, and you can choose the table to check, and the column used for the "order by" (default created_at):
```shell script
php artisan laralens:diagnostic --table=migrations --column-sort=id
```
To take the last **created** user:
```shell script
php artisan laralens:diagnostic --table=users --column-sort=created_at
```
To take the last **updated** user:
```shell script
php artisan laralens:diagnostic --table=users --column-sort=updated_at
```
### Usage: control the output
You can control the output via the _show_ option. You can define:
* config
* connection
* database
* runtime
* migration
* php-ext
* php-ini
* all
The default for _--show_ option (if you avoid specifying _--show_) is to display: config, connection, database, runtime, migration.
```shell script
php artisan laralens:diagnostic --show=config --show=connection --show=database --show=runtime --show=migration
```
If you want to see only database information:
```shell script
php artisan laralens:diagnostic --show=database
```
If you want to see a verbose output (with also PHP extensions and PHP INI values):
```shell script
php artisan laralens:diagnostic --show=all
```
or better:
```shell script
php artisan laralens:diagnostic --all
```
If you want to see only PHP extensions:
```shell script
php artisan laralens:diagnostic --show=php-ext
```
If you want to see only PHP INI values:
```shell script
php artisan laralens:diagnostic --show=php-ini
```
### Usage: skip database connection and database diagnostics
If your Laravel application doesn't use the database, you can skip the database inspection with --skip-database option.
```shell script
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:
* default
* borderless
* compact
* symfony-style-guide
* box
* box-double
For example:
```sh
php artisan laralens:diagnostic --style=borderless
```
### Usage: change the width of the output table
To use 120 characters (wide terminal), you can use --large option
```sh
php artisan laralens:diagnostic --large
```
### Testing
``` bash
composer test
```
### Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Usage as Web Page
LaraLens provides information with the command line via terminal as shown above.
You have also the opportunity to see the information via your web browser.
You can enable web view via the configuration.
Publish default configuration for LaraLens in your Laravel Application:
```shell script
php artisan vendor:publish --provider="HiFolks\LaraLens\LaraLensServiceProvider" --tag="config"
```
After that,you will have a new configuration file in your config directory. The file is: config/lara-lens.php
Add `LARALENS_WEB_ENABLED=on` option to your .env file. You may also override the default parameters for `LARALENS_PREFIX` and `LARALENS_MIDDLEWARE`
```
# Wether Web Report should be enabled or not
LARALENS_WEB_ENABLED=on
# Path prefix in order to acess the Web Report via browser
LARALENS_PREFIX="laralens"
# Which middleware should be used when acessing the Web Report, separete more with ;
LARALENS_MIDDLEWARE="web;auth.basic"
```
For example, with the configuration above you would have enabled the web view (_web-enabled_ parameter) under _/laralens_test/_ path and with the `web` and `auth.basic` middleware
```php
return [
'prefix' => env('LARALENS_PREFIX', 'laralens'), // URL prefix (default=laralens)
'middleware' => explode(';', env('LARALENS_MIDDLEWARE', 'web')), // middleware (default=web) more separate with ;
'web-enabled' => env('LARALENS_WEB_ENABLED', 'off') // Activate web view (default=off)
];
```
### Web view configuration hint
LaraLens shows some internal configuration of your Laravel application, so I suggest you to disable it in a production environment.
To disable LaraLens web view, make sure to remove LARALENS_WEB_ENABLED config from .env file or set it to _off_
```
LARALENS_WEB_ENABLED=off
```
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
### Submit ideas or feature requests or issues
* Take a look if your request is already there [https://github.com/Hi-Folks/lara-lens/issues](https://github.com/Hi-Folks/lara-lens/issues)
* If it is not present, you can create a new one [https://github.com/Hi-Folks/lara-lens/issues/new](https://github.com/Hi-Folks/lara-lens/issues/new)
## Credits
- [Roberto Butti](https://github.com/hi-folks)
- [All Contributors](https://github.com/Hi-Folks/lara-lens/graphs/contributors)
- [Laravel Package Boilerplate](https://laravelpackageboilerplate.com)
## Who talks about LaraLens
- [Laravel News](https://laravel-news.com/inspect-application-configuration-with-laralens)
- [Medium Article](https://levelup.gitconnected.com/laralens-a-laravel-command-for-inspecting-configuration-2bbb4e714cf7)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
================================================
FILE: composer.json
================================================
{
"name": "hi-folks/lara-lens",
"description": "Laravel Diagnostic command for configuration, db connection, http request",
"keywords": [
"laravel",
"diagnostic",
"cli",
"package",
"command-line",
"console",
"hi-folks",
"lara-lens"
],
"homepage": "https://github.com/hi-folks/lara-lens",
"license": "MIT",
"type": "library",
"authors": [
{
"name": "Roberto Butti",
"role": "Developer"
}
],
"require": {
"php": "^8.0|^8.1|^8.2|^8.3|^8.4",
"ext-json": "*",
"guzzlehttp/guzzle": "^7.8",
"nunomaduro/termwind": "^1.15|^2.0"
},
"require-dev": {
"doctrine/dbal": "^3.0|^4.0",
"larastan/larastan": "^2.0",
"laravel/pint": "^1.4",
"orchestra/testbench": "^7.0|^8.0|^9.0",
"pestphp/pest": "^2.34",
"pestphp/pest-plugin-laravel": "^1.2|^2.3",
"phpunit/phpunit": "^10.5",
"rector/rector": "^0.14|^1.0"
},
"autoload": {
"psr-4": {
"HiFolks\\LaraLens\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"HiFolks\\LaraLens\\Tests\\": "tests"
}
},
"scripts": {
"all": [
"@style-fix",
"@phpstan",
"@test"
],
"style-fix": "pint",
"style-check": "pint --test",
"phpstan": "phpstan analyse -c ./phpstan.neon --no-progress",
"test": "./vendor/bin/pest --order-by random",
"rector": "rector process --dry-run"
},
"scripts-descriptions": {
"test": "Run all tests, via PespPHP",
"style-fix": "Fix the code style with PSR12",
"style-check": "Check the code style with PSR12",
"phpstan": "Run static code analysis via PHPStan",
"rector": "Suggest refactoring to be more PHP 8 compliant",
"all": "Execute tasks for fixing code style, static code analysis and tests"
},
"config": {
"sort-packages": true,
"allow-plugins": {
"composer/package-versions-deprecated": false,
"pestphp/pest-plugin": true
}
},
"extra": {
"laravel": {
"providers": [
"HiFolks\\LaraLens\\LaraLensServiceProvider"
],
"aliases": {
"LaraLens": "HiFolks\\LaraLens\\LaraLensFacade"
}
}
}
}
================================================
FILE: config/config.php
================================================
env('LARALENS_PREFIX', 'laralens'), // URL prefix (default=laralens)
'middleware' => explode(';', env('LARALENS_MIDDLEWARE', 'web')), // middleware (default=web) more separate with ;
'web-enabled' => env('LARALENS_WEB_ENABLED', 'off') // Activate web view (default=off)
];
================================================
FILE: phpcs.xml
================================================
PHPCS configuration file.src*/exclude/*
================================================
FILE: phpstan.neon
================================================
includes:
- ./vendor/larastan/larastan/extension.neon
parameters:
reportUnmatchedIgnoredErrors: false
ignoreErrors:
- '#Parameter .1 \$separator of function explode expects non-empty-string, string given.#'
level: 5
paths:
- src
================================================
FILE: phpunit.xml.dist
================================================
testssrc/
================================================
FILE: phpunit.xml.dist.bak
================================================
src/tests
================================================
FILE: pint.json
================================================
{
"preset": "psr12"
}
================================================
FILE: psalm.xml
================================================
================================================
FILE: rector.php
================================================
paths([
__DIR__ . '/src'
]);
// register a single rule
// $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_80
]);
};
================================================
FILE: resources/views/laralens/index.blade.php
================================================
LaraLens
@foreach( $data as $item)
{{$item['title']}}
{{$item['description']}}
@foreach( $item['data'] as $line)
{{ $line['label'] }}
{{ $line['value'] }}
@endforeach
@endforeach
@foreach( $checks as $item)
@if(\Illuminate\Support\Arr::get($item, "lineType", \HiFolks\LaraLens\ResultLens::LINE_TYPE_DEFAULT) === \HiFolks\LaraLens\ResultLens::LINE_TYPE_HINT)
");
}
}
================================================
FILE: src/ResultLens.php
================================================
reset();
}
public function reset(): void
{
$this->result = collect();
$this->idx = -1;
}
public function addError($label, $value): void
{
$this->add($label, $value, true, self::LINE_TYPE_ERROR);
}
public function addWarning($label, $value): void
{
$this->add($label, $value, true, self::LINE_TYPE_WARNING);
}
public function addInfo($label, $value): void
{
$this->add($label, $value, true, self::LINE_TYPE_INFO);
}
public function addHint($value): void
{
$this->add("*** HINT", $value, true, self::LINE_TYPE_HINT);
}
public function addErrorAndHint($label, $errorMessage, $hintMessage): void
{
$this->addError($label, $errorMessage);
$this->addHint($hintMessage);
}
public function addWarningAndHint($label, $warningMessage, $hintMessage): void
{
$this->addWarning($label, $warningMessage);
$this->addHint($hintMessage);
}
public function addInfoAndHint($label, $infoMessage, $hintMessage): void
{
$this->addInfo($label, $infoMessage);
$this->addHint($hintMessage);
}
public function add($label, $value, $forceLine = false, $lineType = self::LINE_TYPE_DEFAULT): void
{
$this->result->push(
[
"label" => $label,
"value" => $value,
"isLine" => $forceLine,
"lineType" => $lineType
]
);
$this->idx++;
}
/**
* @return bool
*/
public static function isMessageLine(string $lineType)
{
return (($lineType === self::LINE_TYPE_ERROR) ||
($lineType === self::LINE_TYPE_WARNING) ||
($lineType === self::LINE_TYPE_INFO));
}
public static function isHintLine($lineType): bool
{
return ($lineType === self::LINE_TYPE_HINT);
}
public function toArray()
{
return $this->result->toArray();
}
}
================================================
FILE: tests/Feature/ConsistencyTest.php
================================================
getConfigs()
->toArray()
->toBeArray()
->toHaveCount(14)
->checksBag->toArray()
->toBeArray()
->toBeEmpty(); //test check config length 0
config(['app.debug' => true]);
config(['app.env' => "production"]);
expect(laralens())->getConfigs()
->toArray()
->toBeArray()
->toHaveCount(14)
->checksBag->toArray()
->toBeArray()
->toHaveCount(2); // 2 = 1 for the warning , 1 for the hint
});
it('can retrieve runtimeconfig as array of 22 items')
->expect(fn () => laralens())
->getRuntimeConfigs()->toArray()
->toBeArray()
->toHaveCount(22);
it('can retrieve databases as array with 8-13 items')
->expect(fn () => laralens())
->getDatabase()->toArray()
->toBeArray()
->toHaveCountBetween(8, 13);
test('facade', function () {
$this->assertIsObject($this->app["lara-lens"], "Test object facade");
});
test('Credits returned as non-empty array')
->expect(fn () => laralens())
->getCredits()->toArray()
->toBeArray()
->not()->toBeEmpty();
it('can retrieve PHP extensions as array')
->expect(fn () => laralens())
->getPhpExtensions()->toArray()
->toBeArray()
->not()->toBeEmpty();
it('can retrieve PHP ini as array')
->expect(fn () => laralens())
->getPhpIniValues()->toArray()
->toBeArray()
->not()->toBeEmpty();
it('can retrieve OS config as array')
->expect(fn () => laralens())
->getOsConfigs()->toArray()
->toBeArray()
->toHaveCountBetween(0, 8);
test('connection_array', function () {
Http::fake();
expect(fn () => laralens())
->getConnections()->toArray()
->toBeArray()
->toHaveCount(3);
})->skip();
================================================
FILE: tests/Pest.php
================================================
in('Feature');
/*
|--------------------------------------------------------------------------
| Expectations
|--------------------------------------------------------------------------
|
| When you're writing tests, you often need to check that values meet certain conditions. The
| "expect()" function gives you access to a set of "expectations" methods that you can use
| to assert different things. Of course, you may extend the Expectation API at any time.
|
*/
expect()->extend('toHaveCountBetween', function (int $min, int $max) {
expect(count($this->value))->toBeGreaterThanOrEqual($min)
->toBeLessThanOrEqual($max);
return $this;
});
/*
|--------------------------------------------------------------------------
| Functions
|--------------------------------------------------------------------------
|
| While Pest is very powerful out-of-the-box, you may have some testing code specific to your
| project that you don't want to repeat in every file. Here you can also expose helpers as
| global functions to help you to reduce the number of lines of code in your test files.
|
*/
/**
* Returns a new instance of Laralens
*
* @return LaraLens
*/
function laralens(): LaraLens
{
return new LaraLens();
}
================================================
FILE: tests/TestCase.php
================================================