diff --git a/config/laroute.php b/config/laroute.php index 6866c49..40f818d 100644 --- a/config/laroute.php +++ b/config/laroute.php @@ -51,8 +51,17 @@ /* * Appends a prefix to URLs. By default the prefix is an empty string. - * - */ + * + */ 'prefix' => '', + /* + * Array of strings which indicate which, if any, route properties should be excluded from the compiled file. + * Intended to reduce the bundled file size by excluding rote properties not being referenced in production. + * + * The array may left empty or may include one or any of the following: + * ['host', 'methods', 'uri', 'action', 'name'] + */ + 'exclude' => [], + ]; diff --git a/src/Routes/Collection.php b/src/Routes/Collection.php index f6388c6..e4f737c 100644 --- a/src/Routes/Collection.php +++ b/src/Routes/Collection.php @@ -8,6 +8,8 @@ class Collection extends \Illuminate\Support\Collection { + protected static $routeProperties = ['host', 'methods', 'uri', 'action', 'name']; + public function __construct(RouteCollection $routes, $filter, $namespace) { $this->items = $this->parseRoutes($routes, $filter, $namespace); @@ -85,7 +87,7 @@ protected function getRouteInformation(Route $route, $filter, $namespace) break; } - return compact('host', 'methods', 'uri', 'name', 'action'); + return compact(array_diff(static::$routeProperties, config('laroute.exclude'))); } }