From 9fe558dc56c8d3dacb8fd0a345449f52fb69c3e2 Mon Sep 17 00:00:00 2001 From: Chris Kankiewicz Date: Sat, 14 Dec 2019 23:52:25 -0700 Subject: [PATCH] Hide app files from listing by default with a configuration option to override --- app/Bootstrap/FilesComposer.php | 7 ++++++- app/config/app.php | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/Bootstrap/FilesComposer.php b/app/Bootstrap/FilesComposer.php index 99a44ef..224e95a 100644 --- a/app/Bootstrap/FilesComposer.php +++ b/app/Bootstrap/FilesComposer.php @@ -11,6 +11,9 @@ use Tightenco\Collect\Support\Collection; class FilesComposer { + /** @const Application paths to be hidden */ + protected const APP_FILES = ['app', 'vendor', 'index.php']; + /** @var Config Application config */ protected $config; @@ -27,7 +30,9 @@ class FilesComposer $this->hiddenFiles = Collection::make( $this->config->get('hidden_files', []) - )->map(function (string $file) { + )->when($config->get('hide_app_files', true), function ($collection) { + return $collection->merge(self::APP_FILES); + })->map(function (string $file) { return glob($file, GLOB_BRACE | GLOB_NOSORT); })->flatten()->map(function (string $file) { return realpath($file); diff --git a/app/config/app.php b/app/config/app.php index a608923..c9d940b 100644 --- a/app/config/app.php +++ b/app/config/app.php @@ -31,6 +31,13 @@ return [ */ 'date_format' => 'Y-m-d H:i:s', + /** + * Whether or not to hide application files/directories form the listing. + * + * Default value: true + */ + 'hide_app_files' => true, + /** * Description here... *