It worked for me...

This commit is contained in:
2025-05-13 18:23:37 -04:00
parent 3d94baf410
commit e2b10097aa
8 changed files with 154 additions and 15 deletions

View File

@@ -14,8 +14,11 @@ Unit Tests:
script: | script: |
echo "Running unit tests..." echo "Running unit tests..."
composer run tests:unit:coverage composer run tests:unit:coverage
coverage: '/^\s*Lines:\s*\d+.\d+\%/'
artifacts: artifacts:
expire_in: 1 day expire_in: 1 day
reports:
junit: tests/reports/junit.xml
paths: paths:
- tests/reports/ - tests/reports/

View File

@@ -13,6 +13,7 @@ http:
destroy_timeout: 5s destroy_timeout: 5s
stream_timeout: 5s stream_timeout: 5s
num_workers: ${WORKERS:-4} num_workers: ${WORKERS:-4}
debug: ${DEBUG:-false}
address: 0.0.0.0:${HTTP_PORT:-9501} address: 0.0.0.0:${HTTP_PORT:-9501}
access_logs: ${ACCESS_LOGS:-true} access_logs: ${ACCESS_LOGS:-true}

View File

@@ -20,7 +20,6 @@ docker run --rm -v $(PWD):/app siteworxpro/migrate:v4.18.3 create -ext sql -dir
```text ```text
postgres://siteworxpro:password@localhost:5432/siteworxpro?sslmode=disable postgres://siteworxpro:password@localhost:5432/siteworxpro?sslmode=disable
``` ```
```
```shell ```shell
docker run --rm -v $(PWD):/app siteworxpro/migrate:v4.18.3 -database "postgres://siteworxpro:password@localhost:5432/siteworxpro?sslmode=disable" -path /app/db/migrations up docker run --rm -v $(PWD):/app siteworxpro/migrate:v4.18.3 -database "postgres://siteworxpro:password@localhost:5432/siteworxpro?sslmode=disable" -path /app/db/migrations up

View File

@@ -15,7 +15,8 @@
"nyholm/psr7": "^1.8", "nyholm/psr7": "^1.8",
"illuminate/support": "^v12.10.2", "illuminate/support": "^v12.10.2",
"roadrunner-php/app-logger": "^1.2", "roadrunner-php/app-logger": "^1.2",
"siteworxpro/config": "^1.1" "siteworxpro/config": "^1.1",
"predis/predis": "^3.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^12.1", "phpunit/phpunit": "^12.1",
@@ -35,15 +36,15 @@
"phpunit --colors=always --display-deprecations tests" "phpunit --colors=always --display-deprecations tests"
], ],
"tests:unit:coverage": [ "tests:unit:coverage": [
"phpunit --colors=always --display-deprecations --coverage-html tests/reports/html tests " "phpunit --coverage-text --colors=never --display-deprecations --log-junit tests/reports/junit.xml --coverage-html tests/reports/html tests "
], ],
"tests:lint": [ "tests:lint": [
"phpcs ./src --standard=PSR12 --colors -v", "phpcs ./src/**/*.php --standard=PSR12 --colors -v",
"phpcs ./tests --standard=PSR12 --colors -v" "phpcs ./tests/**/*.php --standard=PSR12 --colors -v"
], ],
"tests:lint:fix": [ "tests:lint:fix": [
"phpcbf ./src --standard=PSR12 --colors -v", "phpcbf ./src/**/*.php --standard=PSR12 --colors -v",
"phpcbf ./tests --standard=PSR12 --colors -v" "phpcbf ./tests/**/*.php --standard=PSR12 --colors -v"
], ],
"tests:license": [ "tests:license": [
"composer-license-checker" "composer-license-checker"

65
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "597f3c330fcbd311310b6c23e67f82ad", "content-hash": "df37f9da9922c8145a3adf10809cee4c",
"packages": [ "packages": [
{ {
"name": "brick/math", "name": "brick/math",
@@ -1050,6 +1050,69 @@
], ],
"time": "2024-09-09T07:06:30+00:00" "time": "2024-09-09T07:06:30+00:00"
}, },
{
"name": "predis/predis",
"version": "v3.0.0",
"source": {
"type": "git",
"url": "https://github.com/predis/predis.git",
"reference": "7d86f7afb37940bfc7aaa2909147616881377667"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/predis/predis/zipball/7d86f7afb37940bfc7aaa2909147616881377667",
"reference": "7d86f7afb37940bfc7aaa2909147616881377667",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0",
"psr/http-message": "^1.0|^2.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.3",
"phpstan/phpstan": "^1.9",
"phpunit/phpcov": "^6.0 || ^8.0",
"phpunit/phpunit": "^8.0 || ~9.4.4"
},
"suggest": {
"ext-relay": "Faster connection with in-memory caching (>=0.6.2)"
},
"type": "library",
"autoload": {
"psr-4": {
"Predis\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Till Krüss",
"homepage": "https://till.im",
"role": "Maintainer"
}
],
"description": "A flexible and feature-complete Redis/Valkey client for PHP.",
"homepage": "http://github.com/predis/predis",
"keywords": [
"nosql",
"predis",
"redis"
],
"support": {
"issues": "https://github.com/predis/predis/issues",
"source": "https://github.com/predis/predis/tree/v3.0.0"
},
"funding": [
{
"url": "https://github.com/sponsors/tillkruss",
"type": "github"
}
],
"time": "2025-05-02T23:18:59+00:00"
},
{ {
"name": "psr/clock", "name": "psr/clock",
"version": "1.0.0", "version": "1.0.0",

View File

@@ -28,5 +28,11 @@ return [
'allowed_origins' => Env::get('CORS_ALLOWED_ORIGINS', 'localhost:3000'), 'allowed_origins' => Env::get('CORS_ALLOWED_ORIGINS', 'localhost:3000'),
'allow_credentials' => Env::get('CORS_ALLOW_CREDENTIALS', true, 'bool'), 'allow_credentials' => Env::get('CORS_ALLOW_CREDENTIALS', true, 'bool'),
'max_age' => Env::get('CORS_MAX_AGE', ''), 'max_age' => Env::get('CORS_MAX_AGE', ''),
],
'redis' => [
'host' => Env::get('REDIS_HOST', 'localhost'),
'port' => Env::get('REDIS_PORT', 6379, 'int'),
'database' => Env::get('REDIS_DATABASE', 0, 'int'),
] ]
]; ];

View File

@@ -1,7 +1,16 @@
volumes: volumes:
pgdata: {} redisdata: {}
services: services:
composer-runtime:
volumes:
- .:/app
image: siteworxpro/composer
entrypoint: "/bin/sh -c 'while true; do sleep 30; done;'"
environment:
PHP_IDE_CONFIG: serverName=localhost
dev-runtime: dev-runtime:
ports: ports:
- "9501:9501" - "9501:9501"
@@ -11,13 +20,18 @@ services:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
entrypoint: "/bin/sh -c 'while true; do sleep 30; done;'" entrypoint: "/bin/sh -c 'while true; do sleep 30; done;'"
environment:
PHP_IDE_CONFIG: serverName=localhost
WORKERS: 1
DEBUG: 1
REDIS_HOST: redis
migrations: redis:
image: siteworxpro/migrate:v4.18.3 image: redis:latest
restart: no ports:
- "6379:6379"
volumes: volumes:
- .:/app - redisdata:/data
command: "-database 'postgres://${DB_DATABASE-siteworxpro}:${DB_PASSWORD-password}@${DB_HOST-postgres}:5432/siteworxpro?sslmode=disable' -path /app/db/migrations up"
postgres: postgres:
image: postgres:latest image: postgres:latest

52
src/Facades/Redis.php Normal file
View File

@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
namespace Siteworxpro\App\Facades;
use Illuminate\Support\Facades\Facade;
use Predis\Client;
use Predis\Response\Status;
/**
* Facade for the Redis client.
*
* This class provides a static interface to interact with the Redis client.
*
* @method static array scan($cursor, ?array $options = null)
* @method static string|null get(string $key)
* @method static Status|null set(string $key, $value, $expireResolution = null, $expireTTL = null, $flag = null)
* @method static array keys(string $pattern)
* @method static int del(string $key)
*/
class Redis extends Facade
{
public static function getFacadeRoot(): Client
{
if (self::$resolvedInstance !== null) {
$redis = self::resolveFacadeInstance(self::getFacadeAccessor());
if ($redis instanceof Client) {
return $redis;
}
}
// Create a new Redis client instance if not already resolved
return new Client([
'scheme' => 'tcp',
'host' => Config::get('redis.host'),
'port' => Config::get('redis.port'),
'database' => Config::get('redis.database'),
]);
}
/**
* Get the registered name of the component.
*
* @return string The name of the component.
*/
protected static function getFacadeAccessor(): string
{
return Client::class;
}
}