Skip to main content
The Rest Generic Class package reads all configuration values from config/rest-generic-class.php, which in turn reads environment variables. This design is safe for Laravel’s configuration caching.

Logging Variables

LOG_LEVEL

LOG_LEVEL
string
default:"debug"
Sets the minimum log level for the package’s logging channel.Valid values: emergency, alert, critical, error, warning, notice, info, debugExample:
LOG_LEVEL=error

LOG_QUERY

LOG_QUERY
boolean
default:"false"
When enabled, logs all query operations to storage/logs/query.log for debugging.Use case: Debugging API filtering and query generationExample:
LOG_QUERY=true
Enabling LOG_QUERY in production can significantly increase log file sizes and I/O overhead. Use only for troubleshooting.

Filtering Variables

REST_VALIDATE_COLUMNS

REST_VALIDATE_COLUMNS
boolean
default:"true"
Validates that column names in filter conditions exist in the database table before executing queries.Security: Prevents SQL injection and information disclosureExample:
REST_VALIDATE_COLUMNS=true

REST_STRICT_COLUMNS

REST_STRICT_COLUMNS
boolean
default:"true"
Enforces strict column validation, rejecting requests with invalid column names.When false: Invalid columns are silently ignored When true: Invalid columns cause validation errorsExample:
REST_STRICT_COLUMNS=true
Both REST_VALIDATE_COLUMNS and REST_STRICT_COLUMNS should be true in production for security. Disabling these allows potentially unsafe column names in queries.

Cache Variables

REST_CACHE_ENABLED

REST_CACHE_ENABLED
boolean
default:"false"
Master switch for response caching in BaseService read operations.When enabled: list_all and get_one methods cache responsesExample:
REST_CACHE_ENABLED=true

REST_CACHE_STORE

REST_CACHE_STORE
string
default:"env('CACHE_STORE')"
Specifies which Laravel cache store to use for caching responses.Valid values: Any Laravel cache driver (redis, database, file, memcached, dynamodb, array)Example:
REST_CACHE_STORE=redis

REST_CACHE_TTL

REST_CACHE_TTL
integer
default:"60"
Default time-to-live (in seconds) for cached responses.Used when: Method-specific TTL is not definedExample:
REST_CACHE_TTL=300

REST_CACHE_TTL_LIST

REST_CACHE_TTL_LIST
integer
default:"60"
Time-to-live (in seconds) for list_all method responses.Use case: Cache list/index endpoints longer or shorter than single-item readsExample:
REST_CACHE_TTL_LIST=120

REST_CACHE_TTL_ONE

REST_CACHE_TTL_ONE
integer
default:"30"
Time-to-live (in seconds) for get_one method responses.Use case: Cache single-item reads with different TTL than listsExample:
REST_CACHE_TTL_ONE=60

Validation Cache Variables

REST_VALIDATION_CACHE_ENABLED

REST_VALIDATION_CACHE_ENABLED
boolean
default:"true"
Enables caching for database existence validation queries used by the ValidatesExistenceInDatabase trait.Performance impact: Significantly reduces database load for validationExample:
REST_VALIDATION_CACHE_ENABLED=true

REST_VALIDATION_CACHE_TTL

REST_VALIDATION_CACHE_TTL
integer
default:"3600"
Time-to-live (in seconds) for cached validation query results.Recommendation: Use longer TTL (1+ hours) since table schemas rarely changeExample:
REST_VALIDATION_CACHE_TTL=7200

REST_VALIDATION_CACHE_PREFIX

REST_VALIDATION_CACHE_PREFIX
string
default:"validation"
Prefix for validation cache keys, helping organize and identify validation-related cache entries.Example:
REST_VALIDATION_CACHE_PREFIX=rest_validation

REST_VALIDATION_CONNECTION

REST_VALIDATION_CONNECTION
string
default:"db"
Database connection name used for validation queries.Use case: Use a read replica for validation queries to reduce primary database loadExample:
REST_VALIDATION_CONNECTION=mysql_read

Example Configurations

Development Environment

# Logging
LOG_LEVEL=debug
LOG_QUERY=true

# Filtering
REST_VALIDATE_COLUMNS=true
REST_STRICT_COLUMNS=true

# Cache (disabled for development)
REST_CACHE_ENABLED=false

# Validation cache
REST_VALIDATION_CACHE_ENABLED=true
REST_VALIDATION_CACHE_TTL=3600

Production Environment

# Logging
LOG_LEVEL=error
LOG_QUERY=false

# Filtering
REST_VALIDATE_COLUMNS=true
REST_STRICT_COLUMNS=true

# Cache (Redis for production)
REST_CACHE_ENABLED=true
REST_CACHE_STORE=redis
REST_CACHE_TTL=300
REST_CACHE_TTL_LIST=300
REST_CACHE_TTL_ONE=600

# Validation cache
REST_VALIDATION_CACHE_ENABLED=true
REST_VALIDATION_CACHE_TTL=7200
REST_VALIDATION_CACHE_PREFIX=validation
REST_VALIDATION_CONNECTION=mysql_read

Staging Environment

# Logging
LOG_LEVEL=info
LOG_QUERY=false

# Filtering
REST_VALIDATE_COLUMNS=true
REST_STRICT_COLUMNS=true

# Cache (file-based for simple staging)
REST_CACHE_ENABLED=true
REST_CACHE_STORE=file
REST_CACHE_TTL=120
REST_CACHE_TTL_LIST=120
REST_CACHE_TTL_ONE=180

# Validation cache
REST_VALIDATION_CACHE_ENABLED=true
REST_VALIDATION_CACHE_TTL=3600

Configuration Caching Behavior

When you run php artisan config:cache, Laravel caches all configuration values. After caching, changes to .env files are ignored until you clear the cache with php artisan config:clear or re-cache.
This is why the package reads environment variables only from the config file, not directly via env() calls in service code. This pattern ensures compatibility with Laravel’s configuration caching.

Cache Strategy

Learn about cache stores, TTL strategies, and invalidation

Validation Config

Configure validation caching behavior

Build docs developers (and LLMs) love