Skip to main content

Prerequisites

Before installing Sistema de Ventas, ensure your system meets the following requirements:

Server Requirements

  • PHP 7.3+ or 8.2+
  • MySQL 5.7+ or 8.0+
  • Apache or Nginx web server
  • Composer (latest version)

Development Tools

  • Node.js 14+ and NPM
  • Git
  • Text editor or IDE
  • Terminal/Command line access

Installation Steps

1

Clone the Repository

Clone the Sistema de Ventas repository from GitHub:
git clone https://github.com/isai-ismael/tutorial-sistema-ventas.git
cd tutorial-sistema-ventas
This downloads the complete application source code to your local machine.
2

Install PHP Dependencies

Use Composer to install all PHP dependencies defined in composer.json:
composer install
This installs:
  • Laravel Framework 11.0
  • Laravel Sanctum 4.0 (API authentication)
  • Laravel UI 4.0 (authentication scaffolding)
  • Laravel Tinker 2.5 (REPL tool)
  • Guzzle HTTP 7.0 (HTTP client)
If you encounter memory limit errors, try: php -d memory_limit=-1 /path/to/composer install
3

Install Frontend Dependencies

Install JavaScript dependencies using NPM:
npm install
This installs:
  • Bootstrap 4.6
  • jQuery 3.6
  • Laravel Mix 6.0
  • Sass and related build tools
4

Configure Environment

Copy the example environment file and configure it:
cp .env.example .env
Edit .env and update the following essential settings:
.env
APP_NAME="Sistema de Ventas"
APP_ENV=local
APP_DEBUG=true
APP_URL=http://localhost:8000

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=tutorial_sistema_ventas
DB_USERNAME=root
DB_PASSWORD=your_password_here
Make sure to set DB_DATABASE=tutorial_sistema_ventas to match the database name from the SQL file.
5

Generate Application Key

Generate a unique application encryption key:
php artisan key:generate
This creates a secure APP_KEY in your .env file, which Laravel uses to encrypt sessions and other sensitive data.
6

Create Database

Create a MySQL database for the application:
CREATE DATABASE tutorial_sistema_ventas CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
Or import the provided SQL file directly:
mysql -u root -p < BD/tutorial_sistema_ventas.sql
The SQL file (BD/tutorial_sistema_ventas.sql) includes the complete schema with these tables:
  • categoria - Product categories
  • producto - Products with pricing and stock
  • cliente - Customer information
  • proveedor - Supplier information
  • entrada - Inventory entries
  • venta and venta_detalle - Sales transactions
  • usuario and tipo_usuario - User management
  • empresa - Company information
7

Run Migrations (Alternative)

If you prefer to use Laravel migrations instead of importing the SQL file:
php artisan migrate
The provided SQL file includes sample data. Using migrations will create empty tables.
8

Create Storage Link

Create a symbolic link from public/storage to storage/app/public:
php artisan storage:link
This allows public access to uploaded files (product photos, user avatars, company logos).
9

Compile Frontend Assets

Build the frontend assets (CSS and JavaScript):
npm run dev
Use watch mode during development to automatically recompile when files change.
10

Start Development Server

Launch the Laravel development server:
php artisan serve
The application will be available at http://localhost:8000
To specify a different port: php artisan serve --port=8080

Post-Installation

Create Admin User

If using a fresh database, create an admin user account:
php artisan tinker
Then run:
DB::table('tipo_usuario')->insert([
    'tipo' => 'Administrador'
]);

DB::table('usuario')->insert([
    'id_tipo' => 1,
    'nombre' => 'Admin',
    'apellido' => 'User',
    'usuario' => 'admin',
    'clave' => bcrypt('admin123'),
    'correo' => '[email protected]',
    'estado' => '1'
]);

Verify Installation

Check that everything is working:
  1. Access the application: Navigate to http://localhost:8000
  2. Login: Use the admin credentials
  3. Check database: Verify tables were created
  4. Test file uploads: Try uploading a product image

Docker Installation (Alternative)

Laravel Sail provides a Docker-based development environment:
# Install Sail
composer require laravel/sail --dev

# Publish Sail configuration
php artisan sail:install

# Start Docker containers
./vendor/bin/sail up

# Run migrations
./vendor/bin/sail artisan migrate

# Install NPM dependencies
./vendor/bin/sail npm install

# Build assets
./vendor/bin/sail npm run dev
The application will be available at http://localhost

Troubleshooting

If you encounter permission errors, ensure proper permissions on storage and cache directories:
chmod -R 775 storage bootstrap/cache
chown -R www-data:www-data storage bootstrap/cache
  • Verify MySQL is running: systemctl status mysql
  • Check credentials in .env match your MySQL setup
  • Test connection: mysql -u root -p -h 127.0.0.1
  • Ensure database exists: SHOW DATABASES;
  • Update Composer: composer self-update
  • Clear Composer cache: composer clear-cache
  • Check PHP version: php -v (must be 7.3+)
  • Install missing PHP extensions: php-mbstring, php-xml, php-mysql
  • Clear NPM cache: npm cache clean --force
  • Delete node_modules: rm -rf node_modules package-lock.json
  • Reinstall: npm install
  • Update Node.js if using an old version

Production Deployment

Never deploy to production with APP_DEBUG=true or the default APP_KEY.
For production deployment:
  1. Set APP_ENV=production in .env
  2. Set APP_DEBUG=false
  3. Configure a production database
  4. Run php artisan config:cache
  5. Run php artisan route:cache
  6. Run php artisan view:cache
  7. Build assets: npm run prod
  8. Configure your web server (Apache/Nginx)
  9. Set proper file permissions
  10. Enable HTTPS with SSL certificate

Next Steps

Quick Start

Complete the quick start guide

Configuration

Configure environment settings

Features

Explore core features

Build docs developers (and LLMs) love