Overview
Grupo Mecsa CMS uses Supabase as its backend database and authentication provider. The system automatically detects whether it’s running in production or development and loads the appropriate configuration.Configuration Files
The CMS uses two main configuration approaches:1. Main Configuration File
Location:config/supabase.php
This is the centralized configuration file that handles:
- Environment detection (production vs development)
- Loading credentials from environment variables or defaults
- Providing helper functions for API requests
2. Supabase Class
Location:supabase.php (root)
Provides object-oriented interface for:
- Authentication (login, password reset)
- Data operations (CRUD)
- Admin operations (user management)
Environment-Specific Configuration
Production Environment
The system automatically detects production when the hostname contains
grupomecsa.net- Environment variables (recommended)
- Default values in
config/supabase.php
Development Environment
Local configuration is only loaded when not in production environment
local.supabase.php file in the root directory:
local.supabase.php
Setup Instructions
Get Supabase Credentials
- Log in to your Supabase Dashboard
- Select your project
- Go to Settings → API
- Copy the following:
- Project URL
anonpublickeyservice_rolekey (for admin operations)
Configure Production Environment
Set environment variables on your server:Or configure in Apache/PHP-FPM:
.htaccess
Set Database Schema
The CMS uses the Ensure your Supabase database has a
cms schema by default. This is configured in config/supabase.php:cms schema with the required tables.Configuration Details
Key Types
The CMS requires two different API keys for different security levels:
| Key Type | Variable | Usage |
|---|---|---|
| Anon/Public Key | $supabase_key | Standard database operations with Row Level Security (RLS) |
| Service Role Key | $supabase_service_role | Admin operations that bypass RLS (user management, password resets) |
Schema Configuration
The system uses schema-based routing for API requests:Accept-Profile: cmsContent-Profile: cms
Platform-Specific Handling
Windows/XAMPP:- Uses
curl.exeviashell_exec() - Includes SSL bypass flags:
-k --ssl-no-revoke - Required for local XAMPP development
- Uses PHP’s native
curl_init()and related functions - Standard SSL handling for production servers
Helper Functions
Theconfig/supabase.php file provides several helper functions:
Basic Request
Service Role Request (Admin)
Quick GET
Response Format
Troubleshooting
Connection Issues
Authentication Errors
- Verify your API keys are correct
- Check that the keys have not expired
- Ensure RLS policies allow your operations
- For admin operations, verify you’re using the service role key
Schema Not Found
- Verify the
cmsschema exists in your Supabase database - Check that all tables are in the correct schema
- Run the schema creation SQL from
docs/supabase_email_builder.sql
Next Steps
Security Configuration
Learn about security best practices and session management
Deployment
Deploy your CMS to production servers