Skip to content

tipsyphp/tipsy

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

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

Repository files navigation

Tipsy PHP Framework v2.0 - Modernized

A lightning-fast PHP micro-framework, modernized for PHP 8.3+

Originally created in 2014-2015, Tipsy has been completely modernized while maintaining its core philosophy: "Small and Fast, but Highly Flexible".

πŸš€ Performance Results

14.77x Performance Improvement over legacy PHP 5.6 version:

  • Legacy (PHP 5.6): 167.46 req/sec
  • NextGen (PHP 8.3): 2,474.34 req/sec

⚑ Quick Start

1. Run the Demo

# Start the modernized framework demo
./demo.sh

# Or check status first
./status.sh

Demo will be available at: http://localhost:8080

2. Available Demo URLs

3. Compare Legacy vs Modern

# Run full performance comparison
./real_comparison.sh

🎯 What's New in v2.0

βœ… Fully Modernized Core

  • PHP 8.3+ Required - Modern type system, match expressions, attributes
  • Strict Types - declare(strict_types=1) in all files
  • Performance Optimized - Critical path optimizations, zero legacy code
  • Type Safety - Complete return types, union types, nullable types

βœ… Legacy Code Eliminated

  • ❌ No more call_user_func_array()
  • ❌ No more PHP 5.x compatibility hacks
  • ❌ No more error suppression @
  • ❌ No more outdated function polyfills

βœ… Modern PHP Features

  • Match Expressions - Replace legacy switch statements
  • String Functions - str_starts_with(), str_contains()
  • Spread Operators - ...$args for function calls
  • Constructor Property Promotion - Where applicable
  • Union Types - string|int, callable|string

πŸ—οΈ Architecture

Core Components (21 modernized files)

  • App.php - Service container with type safety
  • Router.php - Performance-optimized routing
  • Route.php - Individual route matching (critical path optimized)
  • DependencyInjector.php - Modern reflection-based injection
  • Request.php - HTTP request handling with match expressions
  • View.php - Template engine with layout support
  • Resource.php - Active Record ORM with multi-database support
  • Looper.php - Collection processing with jQuery-like interface

πŸ“– Quick Examples

Simple Routing

<?php
require 'vendor/autoload.php';

use Tipsy\Tipsy;

$app = new Tipsy();

$app->get('/', function($Request, $View) {
    $View->display('home', ['message' => 'Hello Tipsy v2.0!']);
});

$app->get('/api/users/:id', function($Params, $Response) {
    $user = ['id' => $Params->id, 'name' => 'John Doe'];
    $Response->json($user);
});

$app->run();

Database Resources

// Define a User resource
$app->service('User', [
    '_table' => 'users',
    '_id' => 'id'
]);

// Active Record operations
$user = User::o(1);              // Load by ID
$user->name = 'Updated Name';
$user->save();                   // Save changes

// Query with Looper collections
$admins = User::q('SELECT * FROM users WHERE role = ?', ['admin']);
$admins->each(function() {
    echo $this->name . "\n";
});

Collection Processing

$users = new Looper([
    (object)['name' => 'John', 'role' => 'admin'],
    (object)['name' => 'Jane', 'role' => 'user'],
]);

$admins = $users->filter(['role' => 'admin']);
echo $admins->json(); // JSON output

🐳 Docker Development

NextGen (PHP 8.3)

cd nextgen/baseline
docker-compose up -d
# Available at http://localhost:8080

Legacy Comparison (PHP 5.6)

cd legacy/baseline  
docker-compose up -d
# Available at http://localhost:8081

πŸ“ Project Structure

tipsy/
β”œβ”€β”€ README.md                    # This file
β”œβ”€β”€ demo.sh                      # Quick demo script (./demo.sh)
β”œβ”€β”€ status.sh                    # Check system status (./status.sh)
β”œβ”€β”€ real_comparison.sh          # Performance comparison
β”œβ”€β”€ nextgen/                    # Modernized PHP 8.3+ version
β”‚   β”œβ”€β”€ src/                    # Framework source code (21 modernized files)
β”‚   β”œβ”€β”€ baseline/               # Docker demo environment
β”‚   └── composer.json           # Modern dependencies
└── legacy/                     # Original PHP 5.6 version
    β”œβ”€β”€ src/                    # Legacy source code
    └── baseline/               # Legacy Docker environment

🎯 Philosophy

Tipsy maintains its original philosophy while embracing modern PHP:

  1. Small - Minimal dependencies, lightweight core
  2. Fast - Performance-first design, optimized critical paths
  3. Flexible - Convention over configuration, but configurable
  4. Modern - PHP 8.3+ features, strict types, zero legacy code

πŸ”§ Requirements

  • PHP 8.3+ (Required)
  • Docker (For demo environment)
  • Composer (For autoloading)

πŸ“Š Benchmarks

Run ./real_comparison.sh to see the dramatic performance improvements:

Legacy (PHP 5.6):  167.46 req/sec,  47.91ms latency
NextGen (PHP 8.3): 2474.34 req/sec,  3.24ms latency
Improvement: 14.77x faster

🀝 Contributing

This is a modernization project showcasing how legacy PHP frameworks can be brought into the modern era while maintaining their core strengths.

πŸ“œ License

MIT License - Same as original Tipsy framework


Tipsy v2.0 - Proving that legacy frameworks can be modernized for dramatic performance gains while maintaining their essential character.

About

An MVW PHP micro framework

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages