diff --git a/.env.example b/.env.example index b9084e5..2c9d79a 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,6 @@ APP_NAME=Laravel APP_ENV=local -APP_KEY= +APP_KEY=base64:yul3qSY4NPlQvHdVuOgBu3aS+IK2CjYyW18JBvo0IWM= APP_DEBUG=true APP_TIMEZONE=UTC APP_URL=http://localhost @@ -21,12 +21,16 @@ LOG_STACK=single LOG_DEPRECATIONS_CHANNEL=null LOG_LEVEL=debug -DB_CONNECTION=mongodb -# DB_HOST=127.0.0.1 -# DB_PORT=3306 -# DB_DATABASE=laravel -# DB_USERNAME=root -# DB_PASSWORD= +DB_CONNECTION=sqlite +REDIS_HOST=redis +REDIS_PORT=6379 +REDIS_PASSWORD= +REDIS_DB= +REDIS_CACHE_DB= +CACHE_STORE=redis +REDIS_CACHE_CONNECTION=cache +REDIS_CACHE_LOCK_CONNECTION=default +CACHE_PREFIX=2 SESSION_DRIVER=database SESSION_LIFETIME=120 @@ -38,15 +42,13 @@ BROADCAST_CONNECTION=log FILESYSTEM_DISK=local QUEUE_CONNECTION=database -CACHE_STORE=database -CACHE_PREFIX= MEMCACHED_HOST=127.0.0.1 REDIS_CLIENT=phpredis -REDIS_HOST=127.0.0.1 -REDIS_PASSWORD=null -REDIS_PORT=6379 +#REDIS_HOST=127.0.0.1 +#REDIS_PASSWORD=null +#REDIS_PORT=6379 MAIL_MAILER=log MAIL_SCHEME=null @@ -64,14 +66,14 @@ AWS_BUCKET= AWS_USE_PATH_STYLE_ENDPOINT=false VITE_APP_NAME="${APP_NAME}" -MONGODB_CONNECTION=mongodb -MONGODB_HOST=mongodb -MONGODB_PORT=27017 -MONGODB_DATABASE=kit -MONGODB_URI="mongodb://localhost:27017" -MONGODB_USERNAME= -MONGODB_PASSWORD= -MONGODB_AUTHENTICATION_DATABASE=admin +#MONGODB_CONNECTION=mongodb +#MONGODB_HOST=mongodb +#MONGODB_PORT=27017 +#MONGODB_DATABASE=kit +#MONGODB_URI="mongodb://localhost:27017" +#MONGODB_USERNAME=root +#MONGODB_PASSWORD=123456789 +#MONGODB_AUTHENTICATION_DATABASE=admin #https://cabinet-new.tk-kit.com/developers/get-token TK_KIT_API_URL=https://capi.tk-kit.com diff --git a/app/Jobs/UpdateKitGeographyData.php b/app/Jobs/UpdateKitGeographyData.php index 71bc362..4ba8256 100644 --- a/app/Jobs/UpdateKitGeographyData.php +++ b/app/Jobs/UpdateKitGeographyData.php @@ -4,7 +4,7 @@ namespace App\Jobs; -use App\Models\Terminal; +use App\Repositories\TerminalRepository; use App\Services\KitDeliveryService; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; @@ -20,7 +20,7 @@ class UpdateKitGeographyData implements ShouldQueue use Queueable; use SerializesModels; - public function handle(KitDeliveryService $kitService) + public function handle(KitDeliveryService $kitService, TerminalRepository $terminalRepository) { try { Log::info('Starting synchronization with KIT API...'); @@ -28,32 +28,44 @@ public function handle(KitDeliveryService $kitService) $start = microtime(true); $terminals = $kitService->getTerminals(); - $terminalIds = []; + Log::info('Retrieved ' . count($terminals) . ' terminals from API'); + + if (count($terminals) === 0) { + Log::warning('No terminals returned from KIT API'); + return; + } + + $processedTerminals = []; foreach ($terminals as $terminal) { if (is_object($terminal)) { - Terminal::updateOrCreate( - ['id' => $terminal->id], - [ - 'geography_city_id' => $terminal->geography_city_id, - 'lat' => $terminal->lat, - 'lon' => $terminal->lon, - 'address_code' => $terminal->address_code, - 'city_name' => $terminal->city_name, - 'phone' => $terminal->phone, - 'email' => $terminal->email, - 'value' => $terminal->value, - ] - ); - $terminalIds[] = $terminal->id; + // Convert object to array for caching + $processedTerminals[] = [ + 'id' => $terminal->id, + 'geography_city_id' => $terminal->geography_city_id, + 'lat' => $terminal->lat, + 'lon' => $terminal->lon, + 'address_code' => $terminal->address_code, + 'city_name' => $terminal->city_name, + 'phone' => $terminal->phone, + 'email' => $terminal->email, + 'value' => $terminal->value, + ]; } } - Terminal::whereNotIn('id', $terminalIds)->delete(); + Log::info('Processed ' . count($processedTerminals) . ' terminals for caching'); + + // Store all terminals in cache + $terminalRepository->cacheTerminals($processedTerminals); + + // Verify data was cached by reading it back + $cachedCount = count($terminalRepository->getAllTerminals()); + Log::info("Verification: found {$cachedCount} terminals in cache after storing"); $duration = round(microtime(true) - $start, 2); - Log::info("Synchronization completed in {$duration} seconds"); + Log::info("Synchronization completed in {$duration} seconds. Cached " . count($processedTerminals) . " terminals."); } catch (\Exception $e) { Log::error("Synchronization failed: {$e->getMessage()}"); Log::error($e->getTraceAsString()); diff --git a/app/Models/Terminal.php b/app/Models/Terminal.php index 9354ca3..c895958 100644 --- a/app/Models/Terminal.php +++ b/app/Models/Terminal.php @@ -5,13 +5,13 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; -use MongoDB\Laravel\Eloquent\Model; +use Illuminate\Database\Eloquent\Model; class Terminal extends Model { use HasFactory; - protected $collection = 'terminals'; + protected $table = 'terminals'; protected $fillable = [ 'id', @@ -24,8 +24,4 @@ class Terminal extends Model 'email', 'value', ]; -// public function city() -// { -// return $this->belongsTo(City::class, 'city_id', 'city_id'); -// } -} +} \ No newline at end of file diff --git a/app/Repositories/TerminalRepository.php b/app/Repositories/TerminalRepository.php index ea3c612..39d26b9 100644 --- a/app/Repositories/TerminalRepository.php +++ b/app/Repositories/TerminalRepository.php @@ -4,20 +4,18 @@ namespace App\Repositories; -use App\Models\Terminal; -use Illuminate\Support\Facades\DB; -use MongoDB\Collection; +use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\Log; class TerminalRepository { - private Collection $collection; - - public function __construct() - { - $this->collection = Terminal::raw(); - } + private const CACHE_TTL = 86400; // Cache for 24 hours + private const CACHE_KEY_PREFIX = 'terminals:'; + private const CACHE_ALL_KEY = 'terminals:all'; /** + * Search terminals by query string + * * @param string|null $query * @return array */ @@ -25,15 +23,68 @@ public function search(?string $query = null): array { $query = $query ?? ''; - $result = DB::connection('mongodb') - ->table('terminals') - ->where(function($q) use ($query) { - $q->where('city_name', 'like', '%' . $query . '%') - ->orWhere('address_code', 'like', '%' . $query . '%'); - }) - ->limit(10) - ->get(); + if (empty($query)) { + return $this->getAllTerminals(); + } + + $allTerminals = $this->getAllTerminals(); + + return array_filter($allTerminals, function($terminal) use ($query) { + $query = strtolower($query); + return stripos(strtolower($terminal['city_name'] ?? ''), $query) !== false || + stripos(strtolower($terminal['address_code'] ?? ''), $query) !== false; + }); + } + + /** + * Get all terminals from cache + * + * @return array + */ + public function getAllTerminals(): array + { + return Cache::get(self::CACHE_ALL_KEY, []); + } + + /** + * Cache terminals from API + * + * @param array $terminals + * @return void + */ + public function cacheTerminals(array $terminals): void + { + Cache::put(self::CACHE_ALL_KEY, $terminals, self::CACHE_TTL); - return $result->toArray(); + foreach ($terminals as $terminal) { + if (isset($terminal['id'])) { + Cache::put( + self::CACHE_KEY_PREFIX . $terminal['id'], + $terminal, + self::CACHE_TTL + ); + } + } + } + + /** + * Get terminal by ID + * + * @param string $id + * @return array|null + */ + public function find(string $id): ?array + { + return Cache::get(self::CACHE_KEY_PREFIX . $id); + } + + /** + * Clear terminal cache + * + * @return void + */ + public function clearCache(): void + { + Cache::forget(self::CACHE_ALL_KEY); } -} +} \ No newline at end of file diff --git a/composer.json b/composer.json index b0d80b6..1640326 100644 --- a/composer.json +++ b/composer.json @@ -10,8 +10,7 @@ "kitdelivery/sdk-kit-api": "dev-main", "laravel/framework": "^11.31", "symfony/finder": "^7.0.7", - "laravel/tinker": "^2.9", - "mongodb/laravel-mongodb": "^5.1" + "laravel/tinker": "^2.9" }, "repositories": [ { diff --git a/composer.lock b/composer.lock index 163c0d0..4f3d59e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "59321bf0b0662c7a5c00e8730ea74873", + "content-hash": "e515ac432eb6db3c17d964b0155f06b8", "packages": [ { "name": "brick/math", @@ -1549,16 +1549,16 @@ }, { "name": "laravel/framework", - "version": "v11.44.0", + "version": "v11.44.1", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "e9a33da34815ac1ed46c7e4c477a775f4592f0a7" + "reference": "0883d4175f4e2b5c299e7087ad3c74f2ce195c6d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/e9a33da34815ac1ed46c7e4c477a775f4592f0a7", - "reference": "e9a33da34815ac1ed46c7e4c477a775f4592f0a7", + "url": "https://api.github.com/repos/laravel/framework/zipball/0883d4175f4e2b5c299e7087ad3c74f2ce195c6d", + "reference": "0883d4175f4e2b5c299e7087ad3c74f2ce195c6d", "shasum": "" }, "require": { @@ -1666,7 +1666,7 @@ "league/flysystem-read-only": "^3.25.1", "league/flysystem-sftp-v3": "^3.25.1", "mockery/mockery": "^1.6.10", - "orchestra/testbench-core": "^9.9.4", + "orchestra/testbench-core": "^9.11.2", "pda/pheanstalk": "^5.0.6", "php-http/discovery": "^1.15", "phpstan/phpstan": "^2.0", @@ -1760,7 +1760,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2025-02-24T13:08:54+00:00" + "time": "2025-03-05T15:34:10+00:00" }, { "name": "laravel/prompts", @@ -2613,187 +2613,6 @@ }, "time": "2024-07-19T16:01:23+00:00" }, - { - "name": "mongodb/laravel-mongodb", - "version": "5.1.1", - "source": { - "type": "git", - "url": "https://github.com/mongodb/laravel-mongodb.git", - "reference": "cc7e5ffd0e8e3a9acfebd7aa5a5aabac2fc5eac4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/mongodb/laravel-mongodb/zipball/cc7e5ffd0e8e3a9acfebd7aa5a5aabac2fc5eac4", - "reference": "cc7e5ffd0e8e3a9acfebd7aa5a5aabac2fc5eac4", - "shasum": "" - }, - "require": { - "composer-runtime-api": "^2.0.0", - "ext-mongodb": "^1.15", - "illuminate/cache": "^10.36|^11", - "illuminate/container": "^10.0|^11", - "illuminate/database": "^10.30|^11", - "illuminate/events": "^10.0|^11", - "illuminate/support": "^10.0|^11", - "mongodb/mongodb": "^1.18", - "php": "^8.1" - }, - "conflict": { - "illuminate/bus": "< 10.37.2" - }, - "replace": { - "jenssegers/mongodb": "self.version" - }, - "require-dev": { - "doctrine/coding-standard": "12.0.x-dev", - "league/flysystem-gridfs": "^3.28", - "league/flysystem-read-only": "^3.0", - "mockery/mockery": "^1.4.4", - "mongodb/builder": "^0.2", - "orchestra/testbench": "^8.0|^9.0", - "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^10.3", - "rector/rector": "^1.2", - "spatie/laravel-query-builder": "^5.6" - }, - "suggest": { - "league/flysystem-gridfs": "Filesystem storage in MongoDB with GridFS", - "mongodb/builder": "Provides a fluent aggregation builder for MongoDB pipelines" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "MongoDB\\Laravel\\MongoDBServiceProvider", - "MongoDB\\Laravel\\MongoDBBusServiceProvider" - ] - } - }, - "autoload": { - "psr-4": { - "MongoDB\\Laravel\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Andreas Braun", - "email": "andreas.braun@mongodb.com", - "role": "Leader" - }, - { - "name": "Jérôme Tamarelle", - "email": "jerome.tamarelle@mongodb.com", - "role": "Maintainer" - }, - { - "name": "Jeremy Mikola", - "email": "jmikola@gmail.com", - "role": "Maintainer" - }, - { - "name": "Jens Segers", - "homepage": "https://jenssegers.com", - "role": "Creator" - } - ], - "description": "A MongoDB based Eloquent model and Query builder for Laravel", - "homepage": "https://github.com/mongodb/laravel-mongodb", - "keywords": [ - "database", - "eloquent", - "laravel", - "model", - "mongo", - "mongodb" - ], - "support": { - "issues": "https://www.mongodb.com/support", - "security": "https://www.mongodb.com/security", - "source": "https://github.com/mongodb/laravel-mongodb/tree/5.1.1" - }, - "time": "2025-01-06T09:22:28+00:00" - }, - { - "name": "mongodb/mongodb", - "version": "1.19.1", - "source": { - "type": "git", - "url": "https://github.com/mongodb/mongo-php-library.git", - "reference": "afe425b629075fa597fa2d5645045cb20dc93d95" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/mongodb/mongo-php-library/zipball/afe425b629075fa597fa2d5645045cb20dc93d95", - "reference": "afe425b629075fa597fa2d5645045cb20dc93d95", - "shasum": "" - }, - "require": { - "composer-runtime-api": "^2.0", - "ext-hash": "*", - "ext-json": "*", - "ext-mongodb": "^1.18.0", - "php": "^7.4 || ^8.0", - "psr/log": "^1.1.4|^2|^3", - "symfony/polyfill-php80": "^1.27", - "symfony/polyfill-php81": "^1.27" - }, - "require-dev": { - "doctrine/coding-standard": "^12.0", - "rector/rector": "^1.1", - "squizlabs/php_codesniffer": "^3.7", - "symfony/phpunit-bridge": "^5.2", - "vimeo/psalm": "^5.13" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "files": [ - "src/functions.php" - ], - "psr-4": { - "MongoDB\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "Andreas Braun", - "email": "andreas.braun@mongodb.com" - }, - { - "name": "Jeremy Mikola", - "email": "jmikola@gmail.com" - }, - { - "name": "Jérôme Tamarelle", - "email": "jerome.tamarelle@mongodb.com" - } - ], - "description": "MongoDB driver library", - "homepage": "https://jira.mongodb.org/browse/PHPLIB", - "keywords": [ - "database", - "driver", - "mongodb", - "persistence" - ], - "support": { - "issues": "https://github.com/mongodb/mongo-php-library/issues", - "source": "https://github.com/mongodb/mongo-php-library/tree/1.19.1" - }, - "time": "2024-06-13T14:30:04+00:00" - }, { "name": "monolog/monolog", "version": "3.8.1", @@ -4476,16 +4295,16 @@ }, { "name": "ramsey/collection", - "version": "2.0.0", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/ramsey/collection.git", - "reference": "a4b48764bfbb8f3a6a4d1aeb1a35bb5e9ecac4a5" + "reference": "3c5990b8a5e0b79cd1cf11c2dc1229e58e93f109" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/collection/zipball/a4b48764bfbb8f3a6a4d1aeb1a35bb5e9ecac4a5", - "reference": "a4b48764bfbb8f3a6a4d1aeb1a35bb5e9ecac4a5", + "url": "https://api.github.com/repos/ramsey/collection/zipball/3c5990b8a5e0b79cd1cf11c2dc1229e58e93f109", + "reference": "3c5990b8a5e0b79cd1cf11c2dc1229e58e93f109", "shasum": "" }, "require": { @@ -4493,25 +4312,22 @@ }, "require-dev": { "captainhook/plugin-composer": "^5.3", - "ergebnis/composer-normalize": "^2.28.3", - "fakerphp/faker": "^1.21", + "ergebnis/composer-normalize": "^2.45", + "fakerphp/faker": "^1.24", "hamcrest/hamcrest-php": "^2.0", - "jangregor/phpstan-prophecy": "^1.0", - "mockery/mockery": "^1.5", + "jangregor/phpstan-prophecy": "^2.1", + "mockery/mockery": "^1.6", "php-parallel-lint/php-console-highlighter": "^1.0", - "php-parallel-lint/php-parallel-lint": "^1.3", - "phpcsstandards/phpcsutils": "^1.0.0-rc1", - "phpspec/prophecy-phpunit": "^2.0", - "phpstan/extension-installer": "^1.2", - "phpstan/phpstan": "^1.9", - "phpstan/phpstan-mockery": "^1.1", - "phpstan/phpstan-phpunit": "^1.3", - "phpunit/phpunit": "^9.5", - "psalm/plugin-mockery": "^1.1", - "psalm/plugin-phpunit": "^0.18.4", - "ramsey/coding-standard": "^2.0.3", - "ramsey/conventional-commits": "^1.3", - "vimeo/psalm": "^5.4" + "php-parallel-lint/php-parallel-lint": "^1.4", + "phpspec/prophecy-phpunit": "^2.3", + "phpstan/extension-installer": "^1.4", + "phpstan/phpstan": "^2.1", + "phpstan/phpstan-mockery": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^10.5", + "ramsey/coding-standard": "^2.3", + "ramsey/conventional-commits": "^1.6", + "roave/security-advisories": "dev-latest" }, "type": "library", "extra": { @@ -4549,19 +4365,9 @@ ], "support": { "issues": "https://github.com/ramsey/collection/issues", - "source": "https://github.com/ramsey/collection/tree/2.0.0" + "source": "https://github.com/ramsey/collection/tree/2.1.0" }, - "funding": [ - { - "url": "https://github.com/ramsey", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/ramsey/collection", - "type": "tidelift" - } - ], - "time": "2022-12-31T21:50:55+00:00" + "time": "2025-03-02T04:48:29+00:00" }, { "name": "ramsey/uuid", @@ -6393,82 +6199,6 @@ ], "time": "2024-09-09T11:45:10+00:00" }, - { - "name": "symfony/polyfill-php81", - "version": "v1.31.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php81.git", - "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", - "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "type": "library", - "extra": { - "thanks": { - "url": "https://github.com/symfony/polyfill", - "name": "symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php81\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.31.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-09T11:45:10+00:00" - }, { "name": "symfony/polyfill-php83", "version": "v1.31.0", @@ -8291,16 +8021,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.70.0", + "version": "v3.71.0", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "2ecd5aae0edc937f0d5aa4a22d1d705c6b2e084e" + "reference": "3825ffdc69501e1c9230291b79f036a0c0d8749d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/2ecd5aae0edc937f0d5aa4a22d1d705c6b2e084e", - "reference": "2ecd5aae0edc937f0d5aa4a22d1d705c6b2e084e", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/3825ffdc69501e1c9230291b79f036a0c0d8749d", + "reference": "3825ffdc69501e1c9230291b79f036a0c0d8749d", "shasum": "" }, "require": { @@ -8382,7 +8112,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.70.0" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.71.0" }, "funding": [ { @@ -8390,7 +8120,7 @@ "type": "github" } ], - "time": "2025-02-22T23:30:51+00:00" + "time": "2025-03-07T23:06:56+00:00" }, { "name": "hamcrest/hamcrest-php", @@ -8523,16 +8253,16 @@ }, { "name": "laravel/pint", - "version": "v1.21.0", + "version": "v1.21.1", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "531fa0871fbde719c51b12afa3a443b8f4e4b425" + "reference": "c44bffbb2334e90fba560933c45948fa4a3f3e86" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/531fa0871fbde719c51b12afa3a443b8f4e4b425", - "reference": "531fa0871fbde719c51b12afa3a443b8f4e4b425", + "url": "https://api.github.com/repos/laravel/pint/zipball/c44bffbb2334e90fba560933c45948fa4a3f3e86", + "reference": "c44bffbb2334e90fba560933c45948fa4a3f3e86", "shasum": "" }, "require": { @@ -8543,9 +8273,9 @@ "php": "^8.2.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.68.5", - "illuminate/view": "^11.42.0", - "larastan/larastan": "^3.0.4", + "friendsofphp/php-cs-fixer": "^3.70.2", + "illuminate/view": "^11.44.1", + "larastan/larastan": "^3.1.0", "laravel-zero/framework": "^11.36.1", "mockery/mockery": "^1.6.12", "nunomaduro/termwind": "^2.3", @@ -8585,7 +8315,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2025-02-18T03:18:57+00:00" + "time": "2025-03-11T03:22:21+00:00" }, { "name": "laravel/sail", @@ -9010,16 +8740,16 @@ }, { "name": "phpstan/phpstan", - "version": "2.1.6", + "version": "2.1.8", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "6eaec7c6c9e90dcfe46ad1e1ffa5171e2dab641c" + "reference": "f9adff3b87c03b12cc7e46a30a524648e497758f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/6eaec7c6c9e90dcfe46ad1e1ffa5171e2dab641c", - "reference": "6eaec7c6c9e90dcfe46ad1e1ffa5171e2dab641c", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/f9adff3b87c03b12cc7e46a30a524648e497758f", + "reference": "f9adff3b87c03b12cc7e46a30a524648e497758f", "shasum": "" }, "require": { @@ -9064,7 +8794,7 @@ "type": "github" } ], - "time": "2025-02-19T15:46:42+00:00" + "time": "2025-03-09T09:30:48+00:00" }, { "name": "phpunit/php-code-coverage", @@ -9391,16 +9121,16 @@ }, { "name": "phpunit/phpunit", - "version": "11.5.10", + "version": "11.5.12", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "d5df2b32d729562ff8db634678d71085ee579006" + "reference": "d42785840519401ed2113292263795eb4c0f95da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d5df2b32d729562ff8db634678d71085ee579006", - "reference": "d5df2b32d729562ff8db634678d71085ee579006", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d42785840519401ed2113292263795eb4c0f95da", + "reference": "d42785840519401ed2113292263795eb4c0f95da", "shasum": "" }, "require": { @@ -9414,14 +9144,14 @@ "phar-io/manifest": "^2.0.4", "phar-io/version": "^3.2.1", "php": ">=8.2", - "phpunit/php-code-coverage": "^11.0.8", + "phpunit/php-code-coverage": "^11.0.9", "phpunit/php-file-iterator": "^5.1.0", "phpunit/php-invoker": "^5.0.1", "phpunit/php-text-template": "^4.0.1", "phpunit/php-timer": "^7.0.1", "sebastian/cli-parser": "^3.0.2", "sebastian/code-unit": "^3.0.2", - "sebastian/comparator": "^6.3.0", + "sebastian/comparator": "^6.3.1", "sebastian/diff": "^6.0.2", "sebastian/environment": "^7.2.0", "sebastian/exporter": "^6.3.0", @@ -9472,7 +9202,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.10" + "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.12" }, "funding": [ { @@ -9488,7 +9218,7 @@ "type": "tidelift" } ], - "time": "2025-02-25T06:11:48+00:00" + "time": "2025-03-07T07:31:03+00:00" }, { "name": "react/cache", @@ -10188,16 +9918,16 @@ }, { "name": "sebastian/comparator", - "version": "6.3.0", + "version": "6.3.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "d4e47a769525c4dd38cea90e5dcd435ddbbc7115" + "reference": "24b8fbc2c8e201bb1308e7b05148d6ab393b6959" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/d4e47a769525c4dd38cea90e5dcd435ddbbc7115", - "reference": "d4e47a769525c4dd38cea90e5dcd435ddbbc7115", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/24b8fbc2c8e201bb1308e7b05148d6ab393b6959", + "reference": "24b8fbc2c8e201bb1308e7b05148d6ab393b6959", "shasum": "" }, "require": { @@ -10216,7 +9946,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "6.2-dev" + "dev-main": "6.3-dev" } }, "autoload": { @@ -10256,7 +9986,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", "security": "https://github.com/sebastianbergmann/comparator/security/policy", - "source": "https://github.com/sebastianbergmann/comparator/tree/6.3.0" + "source": "https://github.com/sebastianbergmann/comparator/tree/6.3.1" }, "funding": [ { @@ -10264,7 +9994,7 @@ "type": "github" } ], - "time": "2025-01-06T10:28:19+00:00" + "time": "2025-03-07T06:57:01+00:00" }, { "name": "sebastian/complexity", @@ -11078,6 +10808,82 @@ ], "time": "2024-10-20T05:08:20+00:00" }, + { + "name": "symfony/polyfill-php81", + "version": "v1.31.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php81.git", + "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", + "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php81\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php81/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" + }, { "name": "symfony/stopwatch", "version": "v7.2.4", diff --git a/config/cache.php b/config/cache.php index 925f7d2..4ebabf2 100644 --- a/config/cache.php +++ b/config/cache.php @@ -15,7 +15,7 @@ | */ - 'default' => env('CACHE_STORE', 'database'), + 'default' => env('CACHE_STORE', 'redis'), /* |-------------------------------------------------------------------------- diff --git a/config/database.php b/config/database.php index 86da3a8..09bc9ce 100644 --- a/config/database.php +++ b/config/database.php @@ -16,7 +16,7 @@ | */ - 'default' => env('DB_CONNECTION', 'mongodb'), + 'default' => env('DB_CONNECTION', 'sqlite'), /* |-------------------------------------------------------------------------- diff --git a/docker-compose.yaml b/docker-compose.yaml index d8e0dc8..ea58aa8 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -21,25 +21,23 @@ services: volumes: - .:/var/www/html depends_on: - - mongodb + - redis networks: - kit-network - shared-network container_name: kit_app - mongodb: - image: mongo:latest + redis: + container_name: kit-api-redis ports: - - "27017:27017" - environment: - MONGO_INITDB_ROOT_USERNAME: root - MONGO_INITDB_ROOT_PASSWORD: secret + - "6379:6379" + image: redis:latest volumes: - - mongodb_data:/data/db + - ./data/redis:/data + command: redis-server --appendonly yes --requirepass "${REDIS_PASSWORD}" networks: - kit-network - shared-network - container_name: kit_mongodb networks: shared-network: @@ -48,6 +46,3 @@ networks: kit-network: name: "kit-network" driver: bridge - -volumes: - mongodb_data: \ No newline at end of file diff --git a/docker/app.dockerfile b/docker/app.dockerfile index 034fd07..41c8273 100644 --- a/docker/app.dockerfile +++ b/docker/app.dockerfile @@ -17,10 +17,9 @@ RUN apt-get update && apt-get install -y \ # Install PHP extensions RUN docker-php-ext-install pdo mbstring exif pcntl bcmath gd -# Install MongoDB extension -RUN pecl install mongodb-1.18.0 \ - && echo "extension=mongodb.so" > /usr/local/etc/php/conf.d/mongodb.ini \ - && docker-php-ext-enable mongodb +# Install Redis extension +RUN pecl install redis \ + && docker-php-ext-enable redis # Install Composer COPY --from=composer:latest /usr/bin/composer /usr/bin/composer