Ejemplo n.º 1
0
<?php

// command line in  path\to\project\app\socket
// press php -q index.php
require __DIR__ . '/../config/define.php';
use Truvu\Loader;
use Truvu\DI;
use Truvu\Lib\Socket;
$loader = new Loader();
$loader->register(CORE . 'lib/');
Socket::listen(3000);
Socket::connect(function ($data) {
    Socket::setData($data);
    Socket::on('chat', function ($data) {
        Socket::emit('chat', $data);
    });
    Socket::on('time', function ($data) {
        Socket::emit('time', $data);
    });
});
Ejemplo n.º 2
0
<?php

require __DIR__ . '/../app/config/define.php';
use Truvu\Loader;
use Truvu\DI;
use Truvu\Db\Mysql as DBMysql;
use Truvu\Mvc\Application;
$database = (require CONFIG . 'database.php');
$loader = new Loader();
$loader->register(__DIR__ . '/../app/mvc/models/');
$di = new DI();
$di->set('mysql', function () use($database) {
    return DBMysql::connect($database['mysql']);
});
$app = new Application($di);
// $app->get('/', function(){
// 	echo "Index Using Callback Function";
// });
$app->handle();