Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

folders exclude feature #21

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
<p align="center"><img src="https://cloud.githubusercontent.com/assets/11228182/23066989/3dd8f21c-f543-11e6-8f74-f64ccf814d51.png"></p>

<p align="center">
<a href="https://packagist.org/packages/lubusin/laravel-decomposer"><img src="https://poser.pugx.org/lubusin/laravel-decomposer/v/stable" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/lubusin/laravel-decomposer"><img src="https://poser.pugx.org/lubusin/laravel-decomposer/downloads" alt="Total Downloads"></a>
<a href="https://github.com/lubusin/laravel-decomposer/blob/master/LICENSE.txt"><img src="https://poser.pugx.org/lubusin/laravel-decomposer/license" alt="License"></a>
<a href="https://github.com/lubusin/laravel-decomposer/blob/master/contributing.md"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="PRs"></a>
<a href="https://packagist.org/packages/laravel-vietnam/laravel-decomposer"><img src="https://poser.pugx.org/laravel-vietnam/laravel-decomposer/v/stable" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel-vietnam/laravel-decomposer"><img src="https://poser.pugx.org/laravel-vietnam/laravel-decomposer/downloads" alt="Total Downloads"></a>
<a href="https://github.com/laravel-vietnam/laravel-decomposer/blob/master/LICENSE.txt"><img src="https://poser.pugx.org/laravel-vietnam/laravel-decomposer/license" alt="License"></a>
<a href="https://github.com/laravel-vietnam/laravel-decomposer/blob/master/contributing.md"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="PRs"></a>
</p>

## Introduction

Laravel Decomposer decomposes and lists all the installed packages and their dependencies along with the Laravel & the Server environment details your app is running in. Decomposer also generates a [markdown report](https://github.com/lubusIN/laravel-decomposer/blob/master/report.md) from those details that can be used for troubleshooting purposes, also it allows you to generate the same report [as an array](https://github.com/lubusIN/laravel-decomposer/wiki/Get-Report-as-an-array) and also [as JSON](https://github.com/lubusIN/laravel-decomposer/wiki/Get-Report-as-JSON) anywhere in your code. Laravel Package & app devs you can also [add your own personal extra stats specific for your package or your app](https://github.com/lubusIN/laravel-decomposer/wiki/Add-your-extra-stats). All these just on the hit of a single route as shown below in the gif.
Laravel Decomposer decomposes and lists all the installed packages and their dependencies along with the Laravel & the Server environment details your app is running in. Decomposer also generates a [markdown report](https://github.com/laravel-vietnam/laravel-decomposer/blob/master/report.md) from those details that can be used for troubleshooting purposes, also it allows you to generate the same report [as an array](https://github.com/laravel-vietnam/laravel-decomposer/wiki/Get-Report-as-an-array) and also [as JSON](https://github.com/laravel-vietnam/laravel-decomposer/wiki/Get-Report-as-JSON) anywhere in your code. Laravel Package & app devs you can also [add your own personal extra stats specific for your package or your app](https://github.com/laravel-vietnam/laravel-decomposer/wiki/Add-your-extra-stats). All these just on the hit of a single route as shown below in the gif.

**Screenshot**

![Laravel Decomposer](https://cloud.githubusercontent.com/assets/11228182/23458894/0ffe7992-fea4-11e6-8441-e7550f6c3139.gif)

> **Kind Attention :**
You can have a look at the [Roadmap](https://github.com/lubusIN/laravel-decomposer#roadmap). If you have any suggestions for code improvements, new optional or core features or enhancements, create an issue so you,us or any open source believer can start working on it.
You can have a look at the [Roadmap](https://github.com/laravel-vietnam/laravel-decomposer#roadmap). If you have any suggestions for code improvements, new optional or core features or enhancements, create an issue so you,us or any open source believer can start working on it.

## Features
- This can be used by your non-tech client/user of your laravel app or non-experienced dev who still dosen't uses CLI to generate the system report & send over to you so you can know the entire details of his environment.
- To see the list of all installed packages & their dependencies in the laravel app directly from the browser
- To get the Laravel & Server environment details on the same page with the packages list
- To check whether all the pre configurations & extensions asked by Laravel are applied and loaded or not
- Suppose suddenly or after some changes your app broke, you can install Laravel Decomposer, generate & copy the [report](https://github.com/lubusIN/laravel-decomposer/blob/master/report.md) and paste it in the issue box of the respective repo you are reporting the issue to.
- Suppose suddenly or after some changes your app broke, you can install Laravel Decomposer, generate & copy the [report](https://github.com/laravel-vietnam/laravel-decomposer/blob/master/report.md) and paste it in the issue box of the respective repo you are reporting the issue to.
- For package/laravel app developers this can be very useful when collecting the information from the users reporting the issues. As the report gives them complete info about the environment the issue is being raised in.
- It can also help you in other ways like suppose you have a package installed that is using illuminate/support v5.1, and an another package using illuminate/support v5.3, so getting these facts quickly by just hitting to a route can make you aware of possible unstability & conflicts so you can report that to the respective package developer.
- It cuts down the troubleshooting time. For eg: Sometimes after trying all possible solutions at the end the user says 'I forgot to say I am on PHP 4'. Here Decomposer acts as the precaution & removes the dependency of querying the user for every single thing.

## Roadmap

- ~Allow Decomposer report to be accessed via code~ _Released in [v1.1](https://github.com/lubusIN/laravel-decomposer#helpers)_
- ~Allow users and other packages to add their own stats in the Decomposer report~ _Released in [v1.2](https://github.com/lubusIN/laravel-decomposer/wiki/Add-your-extra-stats)_
- ~Allow Decomposer report to be accessed via code~ _Released in [v1.1](https://github.com/laravel-vietnam/laravel-decomposer#helpers)_
- ~Allow users and other packages to add their own stats in the Decomposer report~ _Released in [v1.2](https://github.com/laravel-vietnam/laravel-decomposer/wiki/Add-your-extra-stats)_
- Add a config file to allow user to control what he/she wants to see in the view
- Check for updates of the installed packages & show if any available for the respective packages or their dependencies
- Compare same dependency versions for different packages & warn user about the possible conflict. (Can be achieved even now as the search results highlighting is enabled, but sure it can be done in more better way)
- Make UI more informative & UX more better
- Let us know if you want anything to be added in the decomposer. After all the user makes the packages worth :)
- We have created the [issues](https://github.com/lubusIN/laravel-decomposer/issues) & [labels](https://github.com/lubusIN/laravel-decomposer/labels) with the appropriate titles , where you can contribute your ideas & suggestions or let us know if you are working on a PR for that. Always more than happy to hear & learn new things from the community.
- We have created the [issues](https://github.com/laravel-vietnam/laravel-decomposer/issues) & [labels](https://github.com/laravel-vietnam/laravel-decomposer/labels) with the appropriate titles , where you can contribute your ideas & suggestions or let us know if you are working on a PR for that. Always more than happy to hear & learn new things from the community.

## Installation

You can install this package via composer:

```bash
composer require lubusin/laravel-decomposer
composer require laravel-vietnam/laravel-decomposer
```

Next, add the service provider:
Expand All @@ -69,11 +69,11 @@ Go to http://yourapp/decompose or the route you configured above in the routes f

## Docs

The Docs can be found in the [Wiki](https://github.com/lubusIN/laravel-decomposer/wiki) but to save you one more click, here's the index
- [Add your own extra stats for your package or app](https://github.com/lubusIN/laravel-decomposer/wiki/Add-your-extra-stats)
- [Get Decomposer report as markdown](https://github.com/lubusIN/laravel-decomposer/wiki/Get-Markdown-Report)
- [Get Decomposer report as an array](https://github.com/lubusIN/laravel-decomposer/wiki/Get-Report-as-an-array)
- [Get Decomposer report as JSON](https://github.com/lubusIN/laravel-decomposer/wiki/Get-Report-as-JSON)
The Docs can be found in the [Wiki](https://github.com/laravel-vietnam/laravel-decomposer/wiki) but to save you one more click, here's the index
- [Add your own extra stats for your package or app](https://github.com/laravel-vietnam/laravel-decomposer/wiki/Add-your-extra-stats)
- [Get Decomposer report as markdown](https://github.com/laravel-vietnam/laravel-decomposer/wiki/Get-Markdown-Report)
- [Get Decomposer report as an array](https://github.com/laravel-vietnam/laravel-decomposer/wiki/Get-Report-as-an-array)
- [Get Decomposer report as JSON](https://github.com/laravel-vietnam/laravel-decomposer/wiki/Get-Report-as-JSON)

## Contributing

Expand All @@ -94,4 +94,4 @@ If you discover any security related issues, please email to [[email protected]](m
Laravel Decomposer is open-sourced software licensed under the [MIT license](LICENSE.txt)

## Changelog
Please see the [Changelog](https://github.com/lubusIN/laravel-decomposer/blob/master/changelog.md) for the details
Please see the [Changelog](https://github.com/laravel-vietnam/laravel-decomposer/blob/master/changelog.md) for the details
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
},
"require": {
"php": ">=5.6",
"illuminate/support": "^5.0"
"illuminate/support": "^5.0 || ^6.0 || ^7.0"
},
"require-dev": {
"illuminate/routing": "^5.0",
"illuminate/http": "^5.0"
"illuminate/routing": "^5.0 || ^6.0 || ^7.0",
"illuminate/http": "^5.0 || ^6.0 || ^7.0"
},
"extra": {
"laravel": {
Expand Down
10 changes: 10 additions & 0 deletions config/decomposer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
return [
'folders_exclude' => [
base_path() . '/bootstrap',
base_path() . '/node_modules',
base_path() . '/vendor',
base_path() . '/storage',
base_path() . '/folder/path',
],
];
12 changes: 7 additions & 5 deletions src/Decomposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public static function addLaravelStats(array $laravelStatsArray)
self::$laravelExtras = array_merge(self::$laravelExtras, $laravelStatsArray);
}


/**
* Add Server specific stats by app or any other package dev
* @param $serverStatsArray
Expand Down Expand Up @@ -146,7 +145,7 @@ public static function getPackagesAndDependencies($packagesArray)
'name' => $key,
'version' => $value,
'dependencies' => $dependencies,
'dev-dependencies' => $devDependencies
'dev-dependencies' => $devDependencies,
];
}
}
Expand All @@ -170,7 +169,7 @@ public static function getLaravelEnv($decomposerVersion)
'storage_dir_writable' => is_writable(base_path('storage')),
'cache_dir_writable' => is_writable(base_path('bootstrap/cache')),
'decomposer_version' => $decomposerVersion,
'app_size' => self::sizeFormat(self::folderSize(base_path()))
'app_size' => self::sizeFormat(self::folderSize(base_path())),
], self::getLaravelExtras());
}

Expand All @@ -192,7 +191,7 @@ public static function getServerEnv()
'pdo' => extension_loaded('pdo'),
'mbstring' => extension_loaded('mbstring'),
'tokenizer' => extension_loaded('tokenizer'),
'xml' => extension_loaded('xml')
'xml' => extension_loaded('xml'),
], self::getServerExtras());
}

Expand Down Expand Up @@ -265,7 +264,10 @@ private static function checkSslIsInstalled()
private static function folderSize($dir)
{
$size = 0;
foreach (glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $each) {
foreach (glob(rtrim($dir, '/') . '/*', GLOB_NOSORT) as $each) {
if (!is_file($each) && in_array($each, config('decomposer.folders_exclude'))) {
continue;
}
$size += is_file($each) ? filesize($each) : self::folderSize($each);
}
return $size;
Expand Down
26 changes: 20 additions & 6 deletions src/DecomposerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,30 @@
class DecomposerServiceProvider extends ServiceProvider
{

/**
* Boot up the package. Load the views from the correct directory.
*/
/**
* Boot up the package. Load the views from the correct directory.
*/
public function boot()
{
$this->loadViewsFrom(__DIR__ . '/views', 'Decomposer');
$this->loadViewsFrom(__DIR__.'/views', 'decomposer');
$this->publishes([
$this->getConfigFile() => config_path('decomposer.php'),
], 'config');
}

public function register()
{
// Don't register anything for now
$this->mergeConfigFrom(
$this->getConfigFile(),
'decomposer'
);
}

/**
* @return string
*/
protected function getConfigFile()
{
return __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'decomposer.php';
}
}