Installation, Configuration (config/config.local.php & Env), Admin Setup, Authentication & Usage Manual
8.0 or newer (8.0, 8.1, 8.2, 8.3, 8.4)pdo, pdo_mysql, json, mbstringsession_start)5.7+ / 8.0+ or MariaDB 10.3+ (utf8mb4_unicode_ci)/config directory (chmod 755 or 775) so the installer can write config/config.local.php and config/installed.lockbillcraft-pro/ โโโ api/v1/ โ โโโ auth.php # Session API (?action=me, ?action=logout) โ โโโ documents.php # Auth + CSRF REST API (GET/POST/PATCH/DELETE) โโโ config/ โ โโโ .htaccess # Denies direct HTTP access โ โโโ Database.php # PDO Singleton MySQL Connector โ โโโ config.local.php # (Generated) Local DB credentials array โ โโโ installed.lock # (Generated) Locks installer after setup โโโ includes/ โ โโโ .htaccess # Denies direct HTTP access โ โโโ Auth.php # Bcrypt Auth, RBAC & Brute-Force Guard โ โโโ bootstrap.php # Session (BCSESSID), CSRF & API Guard โโโ install/ โ โโโ index.php # 1-Click Installer + Admin Account Wizard โโโ sql/ โ โโโ .htaccess # Denies direct HTTP access โ โโโ billcraft_schema.sql # 7 InnoDB MySQL Tables & Seed Data โโโ views/ โ โโโ .htaccess # Denies direct HTTP access โ โโโ dashboard.php # Protected 5-Module Workspace View โโโ index.php # Main Entry (routes to install/login/app) โโโ login.php # Sign-In Page (Bcrypt + CSRF + Throttling) โโโ DOCUMENTATION.html # This Interactive Browser Manual โโโ README.md # Complete Markdown Manual
public_html/, htdocs/billcraft-pro/, or /var/www/html/).ALL PRIVILEGES via MySQLยฎ Database Wizard. On local environments (XAMPP/WAMP/MAMP/Laragon), the installer creates the database automatically.http://your-domain.com/index.php (which automatically redirects to install/ before setup) or open http://your-domain.com/install/index.php directly.localhost (or 127.0.0.1)billcraft_pro (letters, numbers, and underscores only)root)Alex Mercer)admin@yourdomain.com)/sql/billcraft_schema.sql (creating all 7 InnoDB tables: bc_users, bc_login_attempts, bc_settings, bc_clients, bc_catalog, bc_documents, bc_document_items + seed records).password_hash($adminPass, PASSWORD_DEFAULT) (Bcrypt) and inserts your admin account into bc_users./config/config.local.php (chmod 0640) with your database credentials./config/installed.lock to lock the installer against unauthorized re-runs.login.php and sign in with the administrator email and password you created. (Recommended for production servers: delete the /install directory after setup).config/config.local.php or Environment Variables)If you prefer manual setup without running /install/index.php, follow these 4 steps. Note: You never need to edit /config/Database.php directly.
In phpMyAdmin (or MySQL CLI), create a database named billcraft_pro (collation utf8mb4_unicode_ci) and import /sql/billcraft_schema.sql.
config/config.local.php or Environment Variables)BillCraft\Config\Database::credentials() resolves database settings in this order: (1) Environment variables DB_HOST, DB_NAME, DB_USER, DB_PASS, (2) /config/config.local.php, and (3) built-in fallback defaults. Create /config/config.local.php with the following structure:
<?php
// config/config.local.php
return [
'host' => 'localhost',
'name' => 'billcraft_pro',
'user' => 'your_mysql_username',
'pass' => 'your_mysql_password',
];
Alternatively, set DB_HOST, DB_NAME, DB_USER, and DB_PASS as server environment variables (Apache SetEnv, Nginx fastcgi_param, or Docker environment).
bc_usersFor security, no hardcoded default admin account is shipped in billcraft_schema.sql. Generate a Bcrypt hash with PHP CLI and insert your admin user:
# 1. Generate Bcrypt password hash in terminal:
php -r "echo password_hash('YourStrongPassword123!', PASSWORD_DEFAULT) . PHP_EOL;"
-- 2. Insert administrator row in MySQL / phpMyAdmin:
INSERT INTO `bc_users` (`full_name`, `email`, `password_hash`, `role`, `language`)
VALUES ('Administrator', 'admin@yourdomain.com', '$2y$10$REPLACE_WITH_YOUR_BCRYPT_HASH', 'admin', 'en');
/config/installed.lockCreate the file /config/installed.lock (e.g., containing Installed manually - v2.0.0). Until config/installed.lock is present, index.php and login.php automatically redirect to /install/.
index.php)index.php is the main entry point. It checks bc_is_installed() (config/installed.lock) and redirects to install/ if not installed, checks Auth::user() and redirects unauthenticated visitors to login.php, or loads the protected workspace (views/dashboard.php).
login.php)Authenticates users against bc_users with password_verify() (Bcrypt) and CSRF protection. Failed attempts are logged in bc_login_attempts; after 5 failed attempts within 15 minutes from the same IP, login is throttled with HTTP 429.
Uses hardened cookie sessions (BCSESSID, HttpOnly, SameSite=Lax). State-changing API calls require the X-CSRF-Token header. Roles supported: admin, manager, staff (deleting documents requires admin or manager).
After signing in at login.php, you are directed to the authenticated workspace at index.php. BillCraft Pro synchronizes all documents with MySQL via api/v1/documents.php while maintaining a fast browser cache.
Sign in to index.php, click "Company & SQL API" in the left sidebar, and click "๐ Test & Sync MySQL Database Now". The status box calls GET api/v1/documents.php and displays: โ
MySQL Connected! Synced X records from bc_documents table.
In A4 Document Studio, choose Invoice, Price Quote, or Service Contract, add line items, sign the canvas, and click "๐พ Save to CRM". A transactional POST (with X-CSRF-Token) saves the record in bc_documents and bc_document_items.
In Client CRM & Ledger, click Pending โป / Paid โ to send a PATCH request, click Delete (admin/manager) to send a DELETE request, or export to A4 PDF, CSV (Excel), or JSON Backup.
All endpoints require an authenticated session cookie (BCSESSID). Mutating requests (POST, PATCH, DELETE) also require the per-session X-CSRF-Token header.
| Method | Endpoint | CSRF Header | Action |
|---|---|---|---|
| GET | /api/v1/auth.php?action=me | No | Returns current authenticated user profile (id, full_name, email, role, can_delete) and csrf_token. |
| POST | /api/v1/auth.php?action=logout | X-CSRF-Token | Destroys the active PHP session and redirects to login.php?logged_out=1. |
| GET | /api/v1/documents.php | No | Fetches up to 250 documents with line items and SQL aggregate KPIs (total_pipeline, total_paid, total_pending, total_count). |
| POST | /api/v1/documents.php | X-CSRF-Token | Creates or updates an Invoice, Proposal, or Contract + line items inside a PDO SQL Transaction. |
| PATCH | /api/v1/documents.php?id={id} | X-CSRF-Token | Toggles document payment status between Paid and Pending in MySQL. |
| DELETE | /api/v1/documents.php?id={id} | X-CSRF-Token | Deletes the document (requires admin or manager role) and cascades to bc_document_items. |