Skip to content

Commit

Permalink
Small changes to cachign command
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenvanassche committed Dec 21, 2023
1 parent 9ee1b25 commit 9046387
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
19 changes: 11 additions & 8 deletions config/data.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

return [
/*
/**
* The package will use this format when working with dates. If this option
* is an array, it will try to convert from the first format that works,
* and will serialize dates using the first format from the array.
*/
'date_format' => DATE_ATOM,

/*
/**
* Global transformers will take complex types and transform them into simple
* types.
*/
Expand All @@ -18,7 +18,7 @@
BackedEnum::class => Spatie\LaravelData\Transformers\EnumTransformer::class,
],

/*
/**
* Global casts will cast values into complex types when creating a data
* object from simple types.
*/
Expand All @@ -27,7 +27,7 @@
BackedEnum::class => Spatie\LaravelData\Casts\EnumCast::class,
],

/*
/**
* Rule inferrers can be configured here. They will automatically add
* validation rules to properties of a data object based upon
* the type of the property.
Expand All @@ -54,7 +54,7 @@
Spatie\LaravelData\Normalizers\JsonNormalizer::class,
],

/*
/**
* Data objects can be wrapped into a key like 'data' when used as a resource,
* this key can be set globally here for all data objects. You can pass in
* `null` if you want to disable wrapping.
Expand All @@ -69,11 +69,14 @@
*/
'var_dumper_caster_mode' => 'development',

/*
* The package will cache the reflection of data objects to improve performance.
/**
* It is possible to skip the PHP reflection analysis of data objects
* when running in production. This will speed up the package. You
* can configure where data objects are stored and which cache
* store should be used.
*/
'structure_caching' => [
'directories' => [app_path('data')],
'directories' => [app_path('Data')],
'cache' => [
'store' => env('CACHE_DRIVER', 'file'),
'prefix' => 'laravel-data',
Expand Down
12 changes: 10 additions & 2 deletions src/Commands/DataStructuresCacheCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class DataStructuresCacheCommand extends Command
{
protected $signature = 'data:cache-structures';
protected $signature = 'data:cache-structures {--show-classes : Show the data classes cached}';

protected $description = 'Cache the internal data structures';

Expand Down Expand Up @@ -40,6 +40,14 @@ public function handle(

$progressBar->finish();

$this->components->info('Cached '.count($dataClasses).' data classes!');
$this->line(PHP_EOL);
$this->line('Cached '.count($dataClasses).' data classes');

if ($this->option('show-classes')) {
$this->table(
['Data Class'],
array_map(fn (string $dataClass) => [$dataClass], $dataClasses)
);
}
}
}

0 comments on commit 9046387

Please sign in to comment.