Skip to content

Commit b2acea1

Browse files
authored
Merge pull request #3 from Jeroen-G/php-cache-file
PHP cache file instead of JSON
2 parents b1a891f + e96f97c commit b2acea1

4 files changed

Lines changed: 11 additions & 4 deletions

File tree

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## Unreleased
88

9+
## [1.3.0]
10+
11+
## Changed
12+
- Cache is now saves as a PHP file instead of JSON
13+
914
## [1.2.0]
1015

1116
### Added

src/AutowireServiceProvider.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ public function register(): void
2626
$this->mergeConfigFrom(__DIR__.'/../config/autowire.php', 'autowire');
2727

2828
try {
29-
$file = File::get(App::bootstrapPath('cache/autowire.json'));
30-
$cache = json_decode($file, true, 512, JSON_THROW_ON_ERROR);
29+
$cache = File::getRequire(App::bootstrapPath('cache/autowire.php'));
3130
$this->loadFromCache($cache);
3231
} catch (FileNotFoundException | JsonException) {
3332
$this->crawlAndLoad();

src/Console/AutowireCacheCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ public function handle(): int
4646
'configure' => $configureCache,
4747
];
4848

49-
File::put(App::bootstrapPath('cache/autowire.json'), json_encode($cache, JSON_THROW_ON_ERROR));
49+
File::put(
50+
App::bootstrapPath('cache/autowire.php'),
51+
'<?php return '.var_export($cache, true).';'.PHP_EOL
52+
);
5053

5154
$this->info('Autowire cache created!');
5255
return 0;

src/Console/AutowireClearCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class AutowireClearCommand extends Command
1616

1717
public function handle(): int
1818
{
19-
$deleted = File::delete(App::bootstrapPath('cache/autowire.json'));
19+
$deleted = File::delete(App::bootstrapPath('cache/autowire.php'));
2020

2121
if (!$deleted) {
2222
$this->error('Could not clear cache.');

0 commit comments

Comments
 (0)