Skip to content

Commit

Permalink
Merge pull request #17 from mruz/master
Browse files Browse the repository at this point in the history
Add Ice framework 1.0
  • Loading branch information
kenjis committed May 1, 2015
2 parents cbe43f1 + 4a43606 commit ee7285a
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ These are my benchmarks, not yours. **I encourage you to run on your environment
|zf-2.4 | 72.88| 1.7| 3.00| 6.0|
|typo3-flow-2.3 | 42.61| 1.0| 5.25| 10.5|

Note(1): All the results are run on php with phalcon.so. If you don't load phalcon.so, the rps except for Phalcon probably increase.
Note(1): All the results are run on php with phalcon.so and ice.so. If you don't load phalcon.so or ice.so, the rps except for Phalcon or Ice probably increase.

## How to Benchmark

Expand Down
4 changes: 4 additions & 0 deletions benchmarks/hello_world.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ fw="phalcon-2.0"
url="$base/$fw/public/index.php?_url=/hello/index"
benchmark "$fw" "$url"

fw="ice-1.0"
url="$base/$fw/public/index.php?_url=/hello/index"
benchmark "$fw" "$url"

fw="slim-2.6"
url="$base/$fw/index.php/hello/index"
benchmark "$fw" "$url"
Expand Down
48 changes: 48 additions & 0 deletions ice-1.0/App/Bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace App;

/**
* Register the psr-4 auto loader. You will be able to use:
* App\Controller, App\Model, App\Library, etc.
*/
(new \Ice\Loader())
->addNamespace(__NAMESPACE__, __DIR__)
->register();

// Create a dependency injector container
$di = new \Ice\Di();

// Set some services
$di->request = new \Ice\Http\Request();
$di->response = new \Ice\Http\Response();
$di->tag = new \Ice\Tag();

$di->set('dispatcher', function () {
$dispatcher = new \Ice\Mvc\Dispatcher();
$dispatcher->setNamespace(__NAMESPACE__);

return $dispatcher;
});

$di->set('router', function () {
$router = new \Ice\Mvc\Router();
$router->setRoutes([
// The default routes
['GET', '/{controller:[a-z]+}/{action:[a-z]+[/]?}'],
['GET', '/{controller:[a-z]+[/]?}'],
['GET', ''],
]);

return $router;
});

$di->set('view', function () {
$view = new \Ice\Mvc\View();
$view->setViewsDir(__DIR__ . '/View/');

return $view;
});

// Create and return a MVC application
return new \Ice\Mvc\App($di);
12 changes: 12 additions & 0 deletions ice-1.0/App/Controller/HelloController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App\Controller;

class HelloController extends IndexController
{

public function indexAction()
{
$this->view->setContent('Hello World!');
}
}
14 changes: 14 additions & 0 deletions ice-1.0/App/Controller/IndexController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace App\Controller;

use Ice\Mvc\Controller;

class IndexController extends Controller
{

public function indexAction()
{

}
}
1 change: 1 addition & 0 deletions ice-1.0/App/View/index/index.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
index
1 change: 1 addition & 0 deletions ice-1.0/App/View/layouts/index.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php echo $this->getContent() ?>
9 changes: 9 additions & 0 deletions ice-1.0/public/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#/public/.htaccess
Options FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
</IfModule>
20 changes: 20 additions & 0 deletions ice-1.0/public/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

error_reporting(E_ALL);

try {
// Load the bootstrap which return the MVC application
$app = require_once __DIR__ . '/../App/Bootstrap.php';

// Handle a MVC request and display the HTTP response body
echo $app->handle();
} catch (Exception $e) {
// Dispaly the excepton's message
echo $e->getMessage();
}

printf(
"\n%' 8d:%f",
memory_get_peak_usage(true),
microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']
);

0 comments on commit ee7285a

Please sign in to comment.