Skip to content

A lightweight PHP framework for building APIs with frontend support. Built with simplicity and performance in mind.

License

Notifications You must be signed in to change notification settings

jdanielcmedina/trindade

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Trindade Framework

Modern, lightweight and flexible PHP framework for fast and secure web development.

πŸ“š Complete Documentation

πŸš€ Quick Installation

composer require trindade/framework

πŸ› οΈ Dependencies

The framework uses third-party libraries to provide robust functionality:

  • Medoo: Query builder and database system

    • Simple and secure interface for database operations
    • Support for multiple database types (MySQL, PostgreSQL, SQLite)
    • Protection against SQL injection
    • Documentation: https://medoo.in
  • PHPMailer: Email sending system

⚑ Basic Example

require_once __DIR__ . '/vendor/autoload.php';

$config = require_once 'config.php';
$app = new Trindade\Core($config);

// Database example using Medoo
$app->on('GET /users', function() use ($app) {
    $users = $app->db->select('users', '*');
    $app->json($users);
});

// Email example using PHPMailer
$app->on('POST /contact', function() use ($app) {
    $app->mail->send(
        '[email protected]',
        'Contact Form',
        'New message from contact form',
        ['html' => true]
    );
});

🎯 Main Features

Powerful Routing

// Basic route
$app->on('GET /users', function() use ($app) {
    $users = $app->db->select('users', '*');
    $app->json($users);
});

// Route groups
$app->group('/api', function() use ($app) {
    $app->on('GET /users', function() {
        // ...
    });
});

// Dynamic parameters
$app->on('GET /users/:id', function($id) use ($app) {
    // ...
});

Database Query Builder

// Simple select
$users = $app->db->select('users', '*');

// Join with conditions
$posts = $app->db->select('posts', [
    '[>]users' => ['user_id' => 'id']
], [
    'posts.id',
    'posts.title',
    'users.name'
]);

// Insert with ID return
$id = $app->db->insert('users', [
    'name' => 'John',
    'email' => '[email protected]'
]);

Cache System

// Set cache
$app->cache->set('key', $value, 3600);

// Get from cache
$value = $app->cache->get('key', $default);

Session Management

$app->session->set('user_id', 123);
$userId = $app->session->get('user_id');

Plugin System

// Plugin configuration
'plugins' => [
    'blog' => [
        'class' => \Trindade\Plugins\Blog\BlogPlugin::class,
        'config' => [
            // plugin settings
        ]
    ]
]

// Using the plugin
$app->blog->createPost([
    'title' => 'My Post',
    'content' => 'Content...'
]);

Utilities

// Slugify
$slug = $app->utils->slug('Post Title');

// Date formatting
$date = $app->utils->formatDate('2024-01-01');

// Secure hash
$hash = $app->hash->make($password);

πŸ› οΈ Main Components

  • Core: Framework core
  • Database: Database system with Query Builder
  • Session: Session management
  • Cache: Cache system
  • Mail: Email system
  • File: File management
  • Utils: Utility functions
  • Logger: Logging system
  • Assets: Asset management
  • Lang: Internationalization
  • Hash: Hash and encryption utilities
  • Cookie: Cookie management

πŸ”Œ Available Plugins

  • Blog: Complete blog system
  • Auth: Authentication and authorization
  • Admin: Administrative panel
  • API: RESTful API generator
  • Forms: Form builder
  • SEO: Search engine optimization

πŸ”’ Security

  • CSRF Protection
  • Input Sanitization
  • Prepared Statements
  • XSS Prevention
  • Rate Limiting
  • Password Hashing

πŸ“¦ Requirements

  • PHP 7.4 or higher
  • MySQL 5.7 or higher
  • PHP Extensions:
    • PDO
    • mbstring
    • json
    • openssl

🀝 Contributing

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/MyFeature)
  3. Commit your changes (`

πŸ“ Author

Jorge Daniel Medina

πŸ“„ License

This framework is open-source software licensed under the MIT license.

About

A lightweight PHP framework for building APIs with frontend support. Built with simplicity and performance in mind.

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published