Skip to content

smetana/tipy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tipy

Tiny PHP MVC + xUnit framework

Build Status

Installation

Prerequisites:

  • PHP 5.5+
  • Apache 2 + mod_php5
  • MySQL
  • Git
  • Composer

Clone tipy-project

git clone https://github.com/smetana/tipy-project myproject
cd myproject
composer.phar install

Add virtual host to apache2

# /etc/apache2/sites-available/tipy-conf

<VirtualHost 127.0.0.1:80>
    ServerName localhost
    DocumentRoot /home/user/projects/tipy-project/public
    <Directory "/home/user/projects/tipy-project">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Convention over Configuration

Tipy follows "Convention over Configuration" software design paradigm so there is only one small config file for database connection.

API and Documentation

http://smetana.me/tipy-api - a reference to tipy classes with annotations.

Models

// app/models/BlogPost.php

class BlogPost extends TipyModel {
    protected $hasMany = ['comments'];
}

// app/models/Comment.php

class Comment extends TipyModel {
    protected $belongsTo = [
        'post' => ['class' => 'BlogPost', 'dependent' => 'delete']
    ];
}

Controllers

// app/controllers/BlogController.php

class BlogController extends TipyController {

    public function post() {
        $post = BlogPost::load($this->in('id'));
        $this->out('post', $post);
    }

}

Views

<!-- app/views/Blog/post.php -->

<!DOCTYPE html>
<html>
<head>
    <title><?= $post->title ></title>
</head>
<body>
    <h1><?= $post->title ?></p>
    <p><?= $post->body ?></p>
</body>
</html>

Tests

class BlogPostTest extends TipyTestCase {

    public function testBlogPost() {
        $post = BlogPost::load(1);
        assertNotNull($post->title);
        assertEqual($post->id, 1);
    }

}

See http://smetana.me/tipy-api for more details.

About

Tiny PHP MVC + xUnit framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages