Skip to main content

Why Extend FacturaScripts?

FacturaScripts is a powerful open-source ERP and accounting software designed with extensibility at its core. Built in PHP, it provides a robust foundation for business management while allowing developers to customize and extend functionality through its plugin architecture.

Key Benefits for Developers

Plugin Architecture

Create modular extensions without modifying core code. Plugins are isolated, version-controlled, and can be distributed independently.

MVC Pattern

Clean separation of concerns with Models, Views (Twig templates), and Controllers makes code maintainable and testable.

Database Abstraction

Support for MySQL and PostgreSQL with automatic schema management and migrations handled by the framework.

Modern PHP

Built with PHP 8.1+, leveraging namespaces, traits, and modern object-oriented programming practices.

What You Can Build

FacturaScripts’ extensibility allows you to create:
  • Custom Controllers: Add new pages and administrative interfaces
  • Models: Extend the data layer with new business entities
  • API Endpoints: Build RESTful APIs for integrations
  • Business Logic: Implement custom calculations, workflows, and automation
  • UI Components: Create reusable widgets and form elements
  • Reports: Generate custom PDF documents and exports
  • Integrations: Connect with external services and third-party APIs

Development Philosophy

FacturaScripts follows these core principles:

1. Plugin-Based Extensions

The core system remains untouched. All customizations happen in plugins located in the /Plugins directory. This ensures:
  • Easy updates without losing custom code
  • Modular development and testing
  • Distribution and reuse across installations

2. Dynamic Loading

The framework uses a “Dinamic” layer that merges core functionality with plugin overrides:
// Always use Dinamic namespace for instantiation
use FacturaScripts\Dinamic\Model\Cliente;

$cliente = new Cliente();
The Dinamic folder is automatically generated during deployment and combines:
  • Core classes from /Core
  • Plugin extensions from /Plugins/{PluginName}

3. Convention Over Configuration

FacturaScripts uses naming conventions to reduce boilerplate:
  • Controllers in /Controller directory
  • Models in /Model directory
  • Views in /View directory
  • Tables named after model classes (e.g., Cliente model → clientes table)

Request Lifecycle Overview

Understanding the request flow is crucial for development:
1

Entry Point

Request hits index.php which loads configuration and initializes the Kernel.
2

Kernel Initialization

Kernel::init() sets up constants, loads language, registers workers, and prepares the environment.
3

Plugin Loading

Plugins::init() executes initialization code from all enabled plugins in order.
4

Route Matching

Kernel::run() matches the URL to a controller using the routing system.
5

Controller Execution

The matched controller is instantiated and its run() method executes.
6

Authentication

Controller checks authentication (public or private access).
7

Business Logic

privateCore() or publicCore() methods handle the request logic.
8

Response

Controller renders the template and sends the HTTP response.

Core Technologies

FacturaScripts is built with:
TechnologyPurpose
PHP 8.1+Backend language
MySQL / PostgreSQLDatabase layer
TwigTemplate engine for views
ComposerDependency management
PSR-4Autoloading standard

Development Requirements

Before starting development, ensure you have:
  • PHP 8.1 or higher
  • MySQL 5.7+ or PostgreSQL 9.6+
  • Composer (for dependencies)
  • Web server (Apache/Nginx)
  • Git (recommended for version control)
  • curl
  • gd
  • intl
  • mbstring
  • pdo_mysql or pdo_pgsql
  • xml
  • zip
  • Code editor (VS Code, PHPStorm recommended)
  • Xdebug (for debugging)
  • PHPUnit (for testing)
  • Browser developer tools

Project Structure

Understanding the directory layout:
FacturaScripts/
├── Core/                    # Core framework code (do not modify)
│   ├── Base/               # Base classes (Controller, DataBase, etc.)
│   ├── Controller/         # Core controllers
│   ├── Model/              # Core models
│   ├── View/               # Core views (Twig templates)
│   ├── Kernel.php          # Application kernel
│   ├── Plugins.php         # Plugin manager
│   └── Tools.php           # Utility functions
├── Dinamic/                # Auto-generated merged code
├── Plugins/                # Your custom plugins go here
│   └── YourPlugin/
│       ├── Controller/
│       ├── Model/
│       ├── View/
│       ├── Init.php        # Plugin initialization
│       └── facturascripts.ini  # Plugin metadata
├── MyFiles/                # Runtime data (cache, uploads)
├── index.php               # Application entry point
└── config.php              # Configuration file

Next Steps

System Architecture

Learn about the MVC pattern, core components, and how the framework operates.

Development Setup

Set up your development environment and create your first plugin.

Creating Plugins

Build your first plugin from scratch with step-by-step guidance.

API Reference

Explore the complete API documentation for core classes.

Community and Support

Join the FacturaScripts developer community:
Start by reading the architecture documentation to understand how the framework components work together, then set up your development environment.

Build docs developers (and LLMs) love