Skip to main content

Overview

Sistema de Ventas uses Laravel’s environment-based configuration system. All sensitive and environment-specific settings are stored in the .env file, which should never be committed to version control.

Initial Setup

1

Copy the example file

Create your environment configuration from the template:
cp .env.example .env
2

Generate application key

Generate a secure encryption key:
php artisan key:generate
This will set the APP_KEY in your .env file.
3

Configure your environment

Edit .env and update the values according to your environment.
Never commit your .env file to version control. It contains sensitive credentials and configuration that should remain private.

Application Settings

Core Application Variables

.env
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

APP_NAME

Type: String
Default: Laravel
Required: Yes
The name of your application. Used in email notifications and other areas where the application needs to identify itself.
APP_NAME="Sistema de Ventas"

APP_ENV

Type: String
Default: local
Required: Yes
Options: local, development, staging, production
Determines the environment your application is running in. Affects error reporting, caching behavior, and other environment-specific features.
APP_ENV=local

APP_KEY

Type: String (Base64 encoded)
Required: Yes
The encryption key used by Laravel’s encrypter service. Must be a 32-character random string.
Never use the same APP_KEY across multiple environments. Each environment should have its own unique key.
Generate automatically:
php artisan key:generate

APP_DEBUG

Type: Boolean
Default: true
Required: Yes
Enables detailed error messages with stack traces. Should be true for development and false for production.
APP_DEBUG=true
Always set APP_DEBUG=false in production to prevent exposing sensitive application details in error messages.

APP_URL

Type: URL
Default: http://localhost
Required: Yes
The URL of your application. Used for generating URLs from the command line (emails, notifications, etc.).
APP_URL=https://ventas.example.com

Database Configuration

.env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=sisreservacita
DB_USERNAME=root
DB_PASSWORD=

DB_CONNECTION

Type: String
Default: mysql
Required: Yes
Options: mysql, pgsql, sqlite, sqlsrv
The database driver to use. Sistema de Ventas is designed for MySQL.
DB_CONNECTION=mysql

DB_HOST

Type: String/IP
Default: 127.0.0.1
Required: Yes
The hostname or IP address of your database server.
DB_HOST=127.0.0.1

DB_PORT

Type: Integer
Default: 3306
Required: Yes
The port your database server is listening on.
DB_PORT=3306

DB_DATABASE

Type: String
Default: sisreservacita
Required: Yes
The name of your database. The SQL schema uses tutorial_sistema_ventas.
DB_DATABASE=tutorial_sistema_ventas
The .env.example file shows sisreservacita, but you should use tutorial_sistema_ventas to match the provided SQL schema.

DB_USERNAME

Type: String
Default: root
Required: Yes
The database user with access to your database.
DB_USERNAME=root

DB_PASSWORD

Type: String
Default: (empty)
Required: No (for local development)
The password for your database user.
DB_PASSWORD=

Logging Configuration

.env
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

LOG_CHANNEL

Type: String
Default: stack
Required: No
Options: stack, single, daily, slack, syslog, errorlog
Determines how log messages are written.
LOG_CHANNEL=stack

LOG_LEVEL

Type: String
Default: debug
Options: debug, info, notice, warning, error, critical, alert, emergency
The minimum level of log messages to record.
LOG_LEVEL=debug

Cache & Session Configuration

.env
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_CONNECTION=sync

CACHE_DRIVER

Type: String
Default: file
Required: No
Options: file, database, redis, memcached, array
Determines where cached data is stored.
CACHE_DRIVER=file

SESSION_DRIVER

Type: String
Default: file
Required: No
Options: file, cookie, database, redis, memcached, array
Determines how session data is stored.
SESSION_DRIVER=file

SESSION_LIFETIME

Type: Integer (minutes)
Default: 120
Required: No
The number of minutes before a user session expires.
SESSION_LIFETIME=120  # 2 hours

QUEUE_CONNECTION

Type: String
Default: sync
Required: No
Options: sync, database, redis, sqs, beanstalkd
Determines how queued jobs are processed.
QUEUE_CONNECTION=sync

Mail Configuration

.env
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

MAIL_MAILER

Type: String
Default: smtp
Required: Yes
Options: smtp, sendmail, mailgun, ses, postmark, log
The mail driver to use for sending emails.
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025

MAIL_FROM_ADDRESS

Type: Email
Required: Yes
The default email address used as the “from” address.
MAIL_FROM_ADDRESS=[email protected]

MAIL_FROM_NAME

Type: String
Required: No
The default name used as the “from” name.
MAIL_FROM_NAME="Sistema de Ventas"

Redis Configuration

.env
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
Redis is optional and not required for basic functionality. It’s useful for caching and queues in production.

REDIS_HOST

Type: String/IP
Default: 127.0.0.1
The Redis server hostname.

REDIS_PASSWORD

Type: String
Default: null
The Redis server password (if required).

REDIS_PORT

Type: Integer
Default: 6379
The Redis server port.

Broadcasting Configuration

.env
BROADCAST_DRIVER=log

BROADCAST_DRIVER

Type: String
Default: log
Options: pusher, redis, log, null
Determines how real-time events are broadcast.
BROADCAST_DRIVER=log

Filesystem Configuration

.env
FILESYSTEM_DRIVER=local

FILESYSTEM_DRIVER

Type: String
Default: local
Options: local, public, s3, ftp
Determines where uploaded files are stored.
FILESYSTEM_DRIVER=local

AWS Configuration (Optional)

.env
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
AWS configuration is only needed if you plan to use S3 for file storage or SES for email.

Pusher Configuration (Optional)

.env
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
Pusher configuration is only needed for real-time broadcasting features.

Additional Settings

MEMCACHED_HOST

Type: String/IP
Default: 127.0.0.1
MEMCACHED_HOST=127.0.0.1

Environment-Specific Examples

Development Environment

.env
APP_NAME="Sistema de Ventas"
APP_ENV=local
APP_KEY=base64:generated-key-here
APP_DEBUG=true
APP_URL=http://localhost:8000

LOG_CHANNEL=stack
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=tutorial_sistema_ventas
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

MAIL_MAILER=log
MAIL_HOST=mailhog
MAIL_PORT=1025

Production Environment

.env
APP_NAME="Sistema de Ventas"
APP_ENV=production
APP_KEY=base64:your-production-key-here
APP_DEBUG=false
APP_URL=https://ventas.example.com

LOG_CHANNEL=daily
LOG_LEVEL=error

DB_CONNECTION=mysql
DB_HOST=your-db-host.com
DB_PORT=3306
DB_DATABASE=tutorial_sistema_ventas
DB_USERNAME=db_user
DB_PASSWORD=secure-password-here

BROADCAST_DRIVER=log
CACHE_DRIVER=redis
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=database
SESSION_DRIVER=redis
SESSION_LIFETIME=120

REDIS_HOST=redis
REDIS_PASSWORD=redis-password
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=[email protected]
MAIL_PASSWORD=your-app-password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=[email protected]
MAIL_FROM_NAME="Sistema de Ventas"

Security Best Practices

Follow these security guidelines to protect your application:
  1. Never commit .env: Add it to .gitignore
  2. Unique keys per environment: Each environment should have its own APP_KEY
  3. Strong passwords: Use strong database and Redis passwords
  4. Disable debug in production: Set APP_DEBUG=false
  5. Use HTTPS: Set APP_URL to use https:// in production
  6. Secure mail credentials: Use app-specific passwords for email services
  7. Environment variables: Store all secrets in .env, never hardcode them

Configuration Caching

In production, cache your configuration for better performance:
php artisan config:cache
Clear the cache when you make changes:
php artisan config:clear
When configuration is cached, the .env file is not loaded. Make sure to clear the cache after updating environment variables.

Troubleshooting

Configuration Not Loading

If changes to .env aren’t taking effect:
  1. Clear the configuration cache:
    php artisan config:clear
    
  2. Restart your development server

Invalid APP_KEY

No application encryption key has been specified.
Solution:
php artisan key:generate

Database Connection Issues

Verify your database credentials:
php artisan db:show

Next Steps

Database Setup

Configure your database connection

Authentication

Set up user authentication

Build docs developers (and LLMs) love