From 7fecb3635a6eb0968442e1769559fb8d7af8877f Mon Sep 17 00:00:00 2001 From: Phalcon Date: Tue, 4 Sep 2012 16:33:09 -0500 Subject: [PATCH 1/2] Updating tutorial to 0.5.0 --- .gitignore | 2 + app/controllers/IndexController.php | 6 ++- app/controllers/SignupController.php | 9 +++-- app/models/Users.php | 3 +- app/views/index/index.phtml | 2 +- app/views/signup/index.phtml | 8 ++-- public/.htaccess | 2 +- public/index.php | 55 +++++++++++++++++----------- 8 files changed, 54 insertions(+), 33 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5c7ec6d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.DS_Store +public/.DS_Store diff --git a/app/controllers/IndexController.php b/app/controllers/IndexController.php index 871bc93..59e6e70 100644 --- a/app/controllers/IndexController.php +++ b/app/controllers/IndexController.php @@ -1,8 +1,10 @@ request->getPost('name', 'string'); diff --git a/app/models/Users.php b/app/models/Users.php index d08e7e2..ce4f163 100644 --- a/app/models/Users.php +++ b/app/models/Users.php @@ -1,5 +1,6 @@ Hello!"; -echo Phalcon_Tag::linkTo("signup", "Sign Up Here!"); +echo Phalcon\Tag::linkTo("signup", "Sign Up Here!"); diff --git a/app/views/signup/index.phtml b/app/views/signup/index.phtml index 00c12b3..1e04f6a 100644 --- a/app/views/signup/index.phtml +++ b/app/views/signup/index.phtml @@ -1,19 +1,19 @@

Sign using this form

- +

- +

- +

- +

diff --git a/public/.htaccess b/public/.htaccess index eef80cf..7a9d6fe 100755 --- a/public/.htaccess +++ b/public/.htaccess @@ -3,5 +3,5 @@ AddDefaultCharset UTF-8 RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^(.*)$ index.php?_url=$1 [QSA,L] + RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L] diff --git a/public/index.php b/public/index.php index 1511581..2f26682 100755 --- a/public/index.php +++ b/public/index.php @@ -2,27 +2,40 @@ try { - $config = new Phalcon_Config(array( - 'database' => array( - 'adapter' => 'Mysql', - 'host' => 'localhost', - 'username' => 'test', - 'password' => 'test', - 'name' => 'test_db' - ), - 'phalcon' => array( - 'controllersDir' => '../app/controllers/', - 'modelsDir' => '../app/models/', - 'viewsDir' => '../app/views/' - ) - )); + //Register an autoloader + $loader = new \Phalcon\Loader(); + $loader->registerDirs( + array( + '../app/controllers/', + '../app/models/' + ) + )->register(); - $front = Phalcon_Controller_Front::getInstance(); - $front->setConfig($config); - echo $front->dispatchLoop()->getContent(); + //Create a DI + $di = new Phalcon\DI\FactoryDefault(); -} -catch(Phalcon_Exception $e){ - echo 'PhalconException: '.$e->getMessage(), PHP_EOL; -} + //Set the database service + $di->set('db', function(){ + return new \Phalcon\Db\Adapter\Pdo\Mysql(array( + "host" => "localhost", + "username" => "root", + "password" => "secret", + "dbname" => "test_db" + )); + }); + + //Setting up the view component + $di->set('view', function(){ + $view = new \Phalcon\Mvc\View(); + $view->setViewsDir('../app/views/'); + return $view; + }); + //Handle the request + $application = new \Phalcon\Mvc\Application(); + $application->setDI($di); + echo $application->handle()->getContent(); + +} catch(\Phalcon\Exception $e) { + echo "PhalconException: ", $e->getMessage(); +} From 132465e8fc2d07681d287de073cb65bdce90c2a1 Mon Sep 17 00:00:00 2001 From: Phalcon Date: Tue, 4 Sep 2012 16:34:21 -0500 Subject: [PATCH 2/2] Updating README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f1577a1..654f468 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Get Started To run this application on your machine, you need at least: -* PHP >= 5.3.6 +* PHP >= 5.3.11 * Apache Web Server with mod rewrite enabled -* Phalcon PHP Framework extension enabled (0.4.x) +* Phalcon PHP Framework extension enabled (0.5.x)