Skip to content

Commit 18fc00a

Browse files
author
Phalcon
committed
Merge pull request #1 from phalcon/0.5.0
0.5.0
2 parents 58368e0 + 132465e commit 18fc00a

9 files changed

Lines changed: 56 additions & 35 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_Store
2+
public/.DS_Store

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Get Started
1515

1616
To run this application on your machine, you need at least:
1717

18-
* PHP >= 5.3.6
18+
* PHP >= 5.3.11
1919
* Apache Web Server with mod rewrite enabled
20-
* Phalcon PHP Framework extension enabled (0.4.x)
20+
* Phalcon PHP Framework extension enabled (0.5.x)
2121

app/controllers/IndexController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<?php
22

3-
class IndexController extends Phalcon_Controller {
3+
class IndexController extends Phalcon\Mvc\Controller
4+
{
45

5-
function indexAction(){
6+
public function indexAction()
7+
{
68

79
}
810

app/controllers/SignupController.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
<?php
22

3-
class SignupController extends Phalcon_Controller {
3+
class SignupController extends Phalcon\Mvc\Controller
4+
{
45

5-
function indexAction(){
6+
public function indexAction()
7+
{
68

79
}
810

9-
function registerAction(){
11+
public function registerAction()
12+
{
1013

1114
//Request variables from html form
1215
$name = $this->request->getPost('name', 'string');

app/models/Users.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3-
class Users extends Phalcon_Model_Base {
3+
class Users extends Phalcon\Mvc\Model
4+
{
45

56
}

app/views/index/index.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
echo "<h1>Hello!</h1>";
44

5-
echo Phalcon_Tag::linkTo("signup", "Sign Up Here!");
5+
echo Phalcon\Tag::linkTo("signup", "Sign Up Here!");
66

app/views/signup/index.phtml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<h2>Sign using this form</h2>
22

3-
<?php echo Phalcon_Tag::form('signup/register') ?>
3+
<?php echo Phalcon\Tag::form('signup/register') ?>
44

55
<p>
66
<label for="name">Name</label>
7-
<?php echo Phalcon_Tag::textField("name") ?>
7+
<?php echo Phalcon\Tag::textField("name") ?>
88
</p>
99

1010
<p>
1111
<label for="name">E-Mail</label>
12-
<?php echo Phalcon_Tag::textField("email") ?>
12+
<?php echo Phalcon\Tag::textField("email") ?>
1313
</p>
1414

1515
<p>
16-
<?php echo Phalcon_Tag::submitButton("Register") ?>
16+
<?php echo Phalcon\Tag::submitButton("Register") ?>
1717
</p>
1818

1919
</form>

public/.htaccess

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ AddDefaultCharset UTF-8
33
RewriteEngine On
44
RewriteCond %{REQUEST_FILENAME} !-d
55
RewriteCond %{REQUEST_FILENAME} !-f
6-
RewriteRule ^(.*)$ index.php?_url=$1 [QSA,L]
6+
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
77
</IfModule>

public/index.php

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,40 @@
22

33
try {
44

5-
$config = new Phalcon_Config(array(
6-
'database' => array(
7-
'adapter' => 'Mysql',
8-
'host' => 'localhost',
9-
'username' => 'test',
10-
'password' => 'test',
11-
'name' => 'test_db'
12-
),
13-
'phalcon' => array(
14-
'controllersDir' => '../app/controllers/',
15-
'modelsDir' => '../app/models/',
16-
'viewsDir' => '../app/views/'
17-
)
18-
));
5+
//Register an autoloader
6+
$loader = new \Phalcon\Loader();
7+
$loader->registerDirs(
8+
array(
9+
'../app/controllers/',
10+
'../app/models/'
11+
)
12+
)->register();
1913

20-
$front = Phalcon_Controller_Front::getInstance();
21-
$front->setConfig($config);
22-
echo $front->dispatchLoop()->getContent();
14+
//Create a DI
15+
$di = new Phalcon\DI\FactoryDefault();
2316

24-
}
25-
catch(Phalcon_Exception $e){
26-
echo 'PhalconException: '.$e->getMessage(), PHP_EOL;
27-
}
17+
//Set the database service
18+
$di->set('db', function(){
19+
return new \Phalcon\Db\Adapter\Pdo\Mysql(array(
20+
"host" => "localhost",
21+
"username" => "root",
22+
"password" => "secret",
23+
"dbname" => "test_db"
24+
));
25+
});
26+
27+
//Setting up the view component
28+
$di->set('view', function(){
29+
$view = new \Phalcon\Mvc\View();
30+
$view->setViewsDir('../app/views/');
31+
return $view;
32+
});
2833

34+
//Handle the request
35+
$application = new \Phalcon\Mvc\Application();
36+
$application->setDI($di);
37+
echo $application->handle()->getContent();
38+
39+
} catch(\Phalcon\Exception $e) {
40+
echo "PhalconException: ", $e->getMessage();
41+
}

0 commit comments

Comments
 (0)