Skip to content

Commit ee7285a

Browse files
committed
Merge pull request #17 from mruz/master
Add Ice framework 1.0
2 parents cbe43f1 + 4a43606 commit ee7285a

File tree

9 files changed

+110
-1
lines changed

9 files changed

+110
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ These are my benchmarks, not yours. **I encourage you to run on your environment
7777
|zf-2.4 | 72.88| 1.7| 3.00| 6.0|
7878
|typo3-flow-2.3 | 42.61| 1.0| 5.25| 10.5|
7979

80-
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.
80+
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.
8181

8282
## How to Benchmark
8383

benchmarks/hello_world.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ fw="phalcon-2.0"
3333
url="$base/$fw/public/index.php?_url=/hello/index"
3434
benchmark "$fw" "$url"
3535

36+
fw="ice-1.0"
37+
url="$base/$fw/public/index.php?_url=/hello/index"
38+
benchmark "$fw" "$url"
39+
3640
fw="slim-2.6"
3741
url="$base/$fw/index.php/hello/index"
3842
benchmark "$fw" "$url"

ice-1.0/App/Bootstrap.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace App;
4+
5+
/**
6+
* Register the psr-4 auto loader. You will be able to use:
7+
* App\Controller, App\Model, App\Library, etc.
8+
*/
9+
(new \Ice\Loader())
10+
->addNamespace(__NAMESPACE__, __DIR__)
11+
->register();
12+
13+
// Create a dependency injector container
14+
$di = new \Ice\Di();
15+
16+
// Set some services
17+
$di->request = new \Ice\Http\Request();
18+
$di->response = new \Ice\Http\Response();
19+
$di->tag = new \Ice\Tag();
20+
21+
$di->set('dispatcher', function () {
22+
$dispatcher = new \Ice\Mvc\Dispatcher();
23+
$dispatcher->setNamespace(__NAMESPACE__);
24+
25+
return $dispatcher;
26+
});
27+
28+
$di->set('router', function () {
29+
$router = new \Ice\Mvc\Router();
30+
$router->setRoutes([
31+
// The default routes
32+
['GET', '/{controller:[a-z]+}/{action:[a-z]+[/]?}'],
33+
['GET', '/{controller:[a-z]+[/]?}'],
34+
['GET', ''],
35+
]);
36+
37+
return $router;
38+
});
39+
40+
$di->set('view', function () {
41+
$view = new \Ice\Mvc\View();
42+
$view->setViewsDir(__DIR__ . '/View/');
43+
44+
return $view;
45+
});
46+
47+
// Create and return a MVC application
48+
return new \Ice\Mvc\App($di);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace App\Controller;
4+
5+
class HelloController extends IndexController
6+
{
7+
8+
public function indexAction()
9+
{
10+
$this->view->setContent('Hello World!');
11+
}
12+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace App\Controller;
4+
5+
use Ice\Mvc\Controller;
6+
7+
class IndexController extends Controller
8+
{
9+
10+
public function indexAction()
11+
{
12+
13+
}
14+
}

ice-1.0/App/View/index/index.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
index

ice-1.0/App/View/layouts/index.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php echo $this->getContent() ?>

ice-1.0/public/.htaccess

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#/public/.htaccess
2+
Options FollowSymLinks
3+
<IfModule mod_rewrite.c>
4+
RewriteEngine On
5+
6+
RewriteCond %{REQUEST_FILENAME} !-d
7+
RewriteCond %{REQUEST_FILENAME} !-f
8+
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
9+
</IfModule>

ice-1.0/public/index.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
error_reporting(E_ALL);
4+
5+
try {
6+
// Load the bootstrap which return the MVC application
7+
$app = require_once __DIR__ . '/../App/Bootstrap.php';
8+
9+
// Handle a MVC request and display the HTTP response body
10+
echo $app->handle();
11+
} catch (Exception $e) {
12+
// Dispaly the excepton's message
13+
echo $e->getMessage();
14+
}
15+
16+
printf(
17+
"\n%' 8d:%f",
18+
memory_get_peak_usage(true),
19+
microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']
20+
);

0 commit comments

Comments
 (0)