Giter Club home page Giter Club logo

bored's Introduction

Bored is a PHP micro-framework. It provides a simple framework but you can bring things together in order to refine your own ad-hoc framework; just don't call the bored_run() function. The main documentation is the source code.

In a nutshell:

<?php
include('bored.php');

route('GET', '/hello/!name', function($name) {
	return "Hello ${name}";
});

bored_run();
?>

Concepts

Things bored will never have:

  • An ORM
  • A templating system
  • Dependency injection
  • Built-in database migration
  • Unit testing
  • More than 2000 SLOC.

Keep reading to learn about things bored do have.

Routing

It works like this:

route('GET', '/hello/?name', function($name = "Friend") {
	return "Hello ${name}";
});

Argument prefixes are: !mandatory and ?optional.

Database

Database facilities are based on the mysqli PHP extension. It mainly consists of a single function dbquery() which allows few but very convenient ways to interact with the database. In order to enabled the database you have to define four constants:

define('DBHOST', '');
define('DBUSER', '');
define('DBPASS', '');
define('DBNAME', '');

If one is missing, no DB connection gets opened and any call to dbquery() will fails. Once all of the above has been defined a connection to the DB is made available and it's possible to use dbquery(). Keep reading.

Fetch a single row:

$sql = "select id,username from users where id = 30";
$user = dbquery($sql);
print_r($user);

This will results in the following:

Array
(
    [id] => 30
    [username] => userfoo
    ...
)

Fetch multiple rows:

$sql = "select id,username from users";
$users = dbquery($sql, -1); /* -1 means no limit */
print_r($users);

This produces an output like this:

Array
(
    [0] => Array
        (
            [id] => 248
            [username] => userbar
            ...
        )

    [1] => Array
        (
            [id] => 425
            [username] => userbaz
            ...
        )
    ...
)

Views

...

Session

...

Run-time cache

...

Utils

Mails

...

Output formatting

...

bored's People

Contributors

bitsmanent avatar

Stargazers

Roman avatar André Philip avatar Jorge Gomez avatar Dario Cangialosi avatar Adrian Emil Grigore avatar  avatar

Watchers

André Philip avatar  avatar James Cloos avatar

Forkers

jgarte

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.