Skip to content

Pramnos Framework is a custom framework built on top of Symfony, enhanced with frequently used code and components that are common across my projects. It combines the power and flexibility of Symfony with my custom solutions to streamline development and avoid repetitive coding tasks.

License

mrpc/PramnosFramework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Pramnos Framework

Pramnos Framework is a comprehensive PHP MVC framework designed for building robust web applications. It combines proven design patterns with modern development practices, providing a solid foundation for secure, scalable, and maintainable applications.

πŸ“š Documentation

For comprehensive documentation, please refer to:

Requirements

  • PHP 7.4 or higher (8.0+ recommended)
  • ext-mbstring extension
  • ext-pdo extension (for database support)
  • Optional: Redis/Memcached for caching

Installation

composer require mrpc/pramnosframework

✨ Key Features

πŸ—οΈ Architecture

  • MVC Design Pattern - Clean separation of concerns
  • Component-Based - Modular and reusable components
  • Namespace Support - PSR-4 compliant autoloading
  • Factory Pattern - Centralized object creation and management

πŸ” Authentication & Security

  • JWT Token Support - Secure token-based authentication
  • Session Management - Robust session handling with multiple storage backends
  • Permission System - Granular access control and user permissions
  • OAuth2 Support - Built-in OAuth2 server capabilities
  • CSRF Protection - Request validation and security

πŸ’Ύ Database & Caching

  • Database Abstraction - Support for MySQL, PostgreSQL
  • Query Builder - Secure parameterized queries with printf-style formatting
  • Multiple Cache Backends - Redis, Memcached, File-based caching
  • Database Migrations - Version-controlled database schema changes
  • Connection Pooling - Efficient database connection management

🌐 Web Features

  • RESTful Routing - Flexible URL routing with parameter binding
  • API Framework - Built-in REST API support with versioning
  • Multiple Output Formats - JSON, XML, HTML, PDF, RSS
  • Theme System - Pluggable theming with template inheritance
  • Multilingual Support - Complete internationalization framework

πŸ› οΈ Developer Tools

  • Console Commands - Code generators and maintenance tools
  • Logging System - Structured logging with multiple handlers
  • Debug Tools - Built-in debugging and profiling utilities
  • Testing Support - PHPUnit integration and test helpers

πŸ“¦ Additional Components

  • Media Handling - Image processing and file management
  • Email System - SMTP support with template rendering
  • Geolocation - Geographic utilities and distance calculations
  • HTML Utilities - Form builders, datatables, and UI components

Directory Structure

src/Pramnos/
β”œβ”€β”€ Addon/         # Extension modules
β”œβ”€β”€ Application/   # Application core
β”œβ”€β”€ Auth/          # Authentication components
β”œβ”€β”€ Cache/         # Caching utilities
β”œβ”€β”€ Console/       # CLI commands
β”œβ”€β”€ Database/      # Database interaction
β”œβ”€β”€ Document/      # Document handling
β”œβ”€β”€ Email/         # Email services
β”œβ”€β”€ Filesystem/    # File operations
β”œβ”€β”€ Framework/     # Core framework classes
β”œβ”€β”€ General/       # General utilities
β”œβ”€β”€ Geolocation/   # Geolocation services
β”œβ”€β”€ Html/          # HTML utilities
β”œβ”€β”€ Http/          # HTTP request/response
β”œβ”€β”€ Interfaces/    # Framework interfaces
β”œβ”€β”€ Logs/          # Logging functionality
β”œβ”€β”€ Media/         # Media handling
β”œβ”€β”€ Routing/       # URL routing
β”œβ”€β”€ Theme/         # Theming system
β”œβ”€β”€ Translator/    # Translation services
β”œβ”€β”€ User/          # User management
└── helpers.php    # Global helper functions

πŸš€ Quick Start

Basic Application Setup

<?php
// public/index.php
require __DIR__ . '/../vendor/autoload.php';

// Set the path to your root app directory
define('ROOT', dirname(__DIR__));

// Define start point for performance tracking
define('SP', microtime(true));

// Create an application instance
$app = new Pramnos\Application\Application();

// Initialize the application
$app->init();

// Execute the application
$app->exec();

// Render the output
echo $app->render();

Creating Your First Controller

<?php
namespace MyApp\Controllers;

class WelcomeController extends \Pramnos\Application\Controller
{
    public function __construct(?\Pramnos\Application\Application $application = null)
    {
        // Define public actions (no authentication required)
        $this->addaction(['display', 'about']);
        
        // Define authenticated actions (login required)
        $this->addAuthAction(['dashboard', 'profile']);
        
        parent::__construct($application);
    }
    
    public function display()
    {
        $view = $this->getView('Welcome');
        
        $doc = \Pramnos\Framework\Factory::getDocument();
        $doc->title = 'Welcome to Pramnos Framework';
        
        $this->application->addBreadcrumb('Home', sURL);
        
        return $view->display('welcome');
    }
}

Database Operations

// Using the Pramnos database pattern
$sql = $this->application->database->prepareQuery(
    "SELECT * FROM users WHERE email = %s AND status = %d", 
    $email, 
    $status
);
$result = $this->application->database->query($sql);

// Single record
if ($result->numRows > 0) {
    $user = $result->fields; // Direct access to associative array
}

// Multiple records
$users = [];
while ($result->fetch()) {
    $users[] = $result->fields;
}

Console Commands

The framework includes powerful console commands for development:

# Generate a new controller
php bin/pramnos create:controller UserController --full

# Generate a new model
php bin/pramnos create:model User

# Generate API endpoints
php bin/pramnos create:api UserAPI

# Create database migrations
php bin/pramnos create:migration CreateUsersTable

# Run development server
php bin/pramnos serve --port=8080

# Migrate log files to structured format
php bin/pramnos migrate:logs --days=30

πŸ—οΈ Architecture Overview

Framework Components

src/Pramnos/
β”œβ”€β”€ Application/     # Core MVC components (Controllers, Models, Views)
β”œβ”€β”€ Auth/           # Authentication, JWT, Permissions
β”œβ”€β”€ Cache/          # Multi-backend caching system
β”œβ”€β”€ Console/        # CLI commands and tools
β”œβ”€β”€ Database/       # Database abstraction and migrations
β”œβ”€β”€ Document/       # Output rendering (HTML, JSON, PDF, etc.)
β”œβ”€β”€ Email/          # Email handling and templates
β”œβ”€β”€ Framework/      # Base classes and Factory
β”œβ”€β”€ Http/           # Request/Response handling
β”œβ”€β”€ Logs/           # Logging and log management
β”œβ”€β”€ Media/          # File and image processing
β”œβ”€β”€ Routing/        # URL routing and dispatching
β”œβ”€β”€ Theme/          # Theming and template system
β”œβ”€β”€ Translator/     # Internationalization
└── User/           # User management and tokens

Configuration Structure

app/
β”œβ”€β”€ app.php          # Main application configuration
β”œβ”€β”€ config/          # Additional configuration files
β”‚   β”œβ”€β”€ database.php
β”‚   β”œβ”€β”€ cache.php
β”‚   └── settings.php
β”œβ”€β”€ language/        # Translation files
β”œβ”€β”€ migrations/      # Database migrations
└── themes/          # Application themes

src/
β”œβ”€β”€ Controllers/     # Application controllers
β”œβ”€β”€ Models/          # Data models
β”œβ”€β”€ Views/           # Template files (.html.php)
└── Api/            # API controllers and routes

πŸ”§ Configuration

Database Configuration

// app/config/database.php
return [
    'host' => 'localhost',
    'username' => 'dbuser',
    'password' => 'dbpass',
    'database' => 'myapp',
    'prefix' => 'app_',
    'type' => 'mysql', // or 'postgresql'
    'port' => 3306
];

Cache Configuration

// app/config/cache.php
return [
    'method' => 'redis', // redis, memcached, memcache, file
    'hostname' => 'localhost',
    'port' => 6379,
    'database' => 0,
    'prefix' => 'myapp_'
];

Application Configuration

// app/app.php
return [
    'namespace' => 'MyApp',
    'theme' => 'default',
    'api_version' => 'v1',
    'addons' => [
        ['addon' => 'UserDatabase', 'type' => 'auth'],
        ['addon' => 'Session', 'type' => 'system']
    ],
    'scripts' => [
        [
            'script' => 'jquery',
            'src' => 'assets/js/jquery.min.js',
            'deps' => [],
            'version' => '3.6.0',
            'footer' => false
        ]
    ]
];

🌟 Advanced Features

Custom Authentication Addon

<?php
namespace MyApp\Addon\Auth;

class CustomAuth extends \Pramnos\Addon\Addon
{
    public function onAuth($username, $password, $remember, $encrypted, $validate)
    {
        // Custom authentication logic
        return [
            'status' => true,
            'username' => $username,
            'uid' => $userId,
            'email' => $email,
            'auth' => $authHash
        ];
    }
}

API Controller Example

<?php
namespace MyApp\Api\Controllers;

class UsersController extends \Pramnos\Application\Controller
{
    public function display()
    {
        // GET /api/users
        $users = $this->getModel('User')->getList();
        return $this->response(['users' => $users]);
    }
    
    public function postCreateUser()
    {
        // POST /api/users
        $data = $this->getRequestData();
        $user = $this->getModel('User');
        $user->create($data);
        return $this->response(['user' => $user->getData()], 201);
    }
}

Custom Cache Usage

// Using the cache system
$cache = \Pramnos\Cache\Cache::getInstance('user_data', 'user', 'redis');

// Save data
$cache->save($userData, $userId);

// Load data
$userData = $cache->load($userId);

// Clear category
$cache->clear('user');

πŸ“„ Documentation

The framework includes comprehensive documentation for all major subsystems:

Core System Documentation

Feature Documentation

πŸ“„ License

MIT License - see the LICENSE.txt file for details.

πŸ‘¨β€πŸ’» Author

Yannis - Pastis Glaros
Email: mrpc@pramnoshosting.gr
Company: Pramnos Hosting Ltd.

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Setup

  1. Clone the repository
  2. Run composer install
  3. Copy configuration files from examples
  4. Set up your database and cache
  5. Run tests with vendor/bin/phpunit

Guidelines

  • Follow PSR-4 autoloading standards
  • Write tests for new features
  • Update documentation when adding features
  • Use the existing code style and patterns

πŸ†˜ Support

  • Documentation: Check the docs/ directory
  • Issues: Submit issues on the project repository
  • Community: Join our community discussions

About

Pramnos Framework is a custom framework built on top of Symfony, enhanced with frequently used code and components that are common across my projects. It combines the power and flexibility of Symfony with my custom solutions to streamline development and avoid repetitive coding tasks.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages