Skip to content

GabrielMcMoreira1997/tiny-framework

Repository files navigation

logo-no-background

Tiny Framework

Tiny is a simple framework. Developed with the intention of simplifying the development of small projects.

Usage

Routes

How i create a new route?

Make a file .php in PROJECT >> ROUTES. Inside this file, insert code route. Only GET/POST available.

  //Default route for news
  $this->get('news', function($params){
    echo "All news here";
  });

  //Specific route for news
  $this->get('news/{id}', function($params){
    echo "News: {$param['id']}";
  });

Rendering a view

Make a file .php in PROJECT >> TEMPLATES with your front-end. In PROJECT >> ROUTES make a new file .php. After, define a new route and call the method render of template class.

$this->get('news', function($params){
    $tpl = $this->core->loadModule('template');
    $db = $this->core->loadModule('database');

    $sql = $db->query('SELECT * FROM news');
    $array = $sql->fetchAll();
    echo $tpl->render('news.twig', ['news' => $array]);
});

Database config

In your project folder, edit the config.php and your datas in $db array.

  $config = array(
    'db' => array(
        'host' => 'localhost',
        'user' => 'root',
        'pass' => '',
        'dbname' => 'db_name'
    )
);

Development

Want to contribute? Great!

To fix a bug or enhance an existing module, follow these steps:

  • Fork the repo
  • Create a new branch (git checkout -b improve-feature)
  • Make the appropriate changes in the files
  • Add changes to reflect the changes made
  • Commit your changes (git commit -am 'Improve feature')
  • Push to the branch (git push origin improve-feature)
  • Create a Pull Request

Bug / Feature Request

If you'd like to request a new function, feel free to do so by opening an issue here. Please include sample queries and their corresponding results.

Built with

  • PHP - Only PHP, so far.
  • Twig - Template Engine.
  • iziToast - Notifications/Alerts.

To-do (Improves)

  • Add in packagist for download by composer.
  • Add template engine. (Twig)
  • add Monolog for logs.
  • Group routes

Team

Devs: Gabriel Moreira - https://github.com/Venzke

About

Tiny is a simple framework. Developed with the intention of simplifying the development of small projects.

Resources

Stars

Watchers

Forks

Contributors