-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from ninjapanzer/pks/sync_tutorial_repo_with_docs
Revise tutorial project to match documentation
- Loading branch information
Showing
9 changed files
with
83 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/* | ||
+------------------------------------------------------------------------+ | ||
| Phalcon Developer Tools | | ||
+------------------------------------------------------------------------+ | ||
| Copyright (c) 2011-2017 Phalcon Team (https://www.phalconphp.com) | | ||
+------------------------------------------------------------------------+ | ||
| This source file is subject to the New BSD License that is bundled | | ||
| with this package in the file LICENSE.txt. | | ||
| | | ||
| If you did not receive a copy of the license and are unable to | | ||
| obtain it through the world-wide-web, please send an email | | ||
| to [email protected] so we can send you a copy immediately. | | ||
+------------------------------------------------------------------------+ | ||
| Authors: Andres Gutierrez <[email protected]> | | ||
| Eduar Carvajal <[email protected]> | | ||
| Serghei Iakovlev <[email protected]> | | ||
+------------------------------------------------------------------------+ | ||
*/ | ||
|
||
define('PUBLIC_PATH', __DIR__ . '/public'); | ||
|
||
$uri = urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)); | ||
if ($uri !== '/' && file_exists(PUBLIC_PATH . $uri)) { | ||
return false; | ||
} | ||
$_GET['_url'] = $_SERVER['REQUEST_URI']; | ||
|
||
require_once PUBLIC_PATH . '/index.php'; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,7 @@ class Users extends Model | |
{ | ||
|
||
public $id; | ||
|
||
public $name; | ||
|
||
public $email; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,3 @@ | |
echo "<h1>Hello!</h1>"; | ||
|
||
echo $this->tag->linkTo("signup", "Sign Up Here!"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,55 @@ | ||
<?php | ||
|
||
use Phalcon\Loader; | ||
use Phalcon\Tag; | ||
use Phalcon\Mvc\Url; | ||
use Phalcon\Mvc\View; | ||
use Phalcon\Mvc\Application; | ||
use Phalcon\DI\FactoryDefault; | ||
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter; | ||
|
||
define('BASE_PATH', dirname(__DIR__)); | ||
define('APP_PATH', BASE_PATH . '/app'); | ||
|
||
// Register an autoloader | ||
$loader = new Loader(); | ||
$loader->registerDirs( | ||
array( | ||
APP_PATH . '/controllers/', | ||
APP_PATH . '/models/' | ||
) | ||
)->register(); | ||
|
||
// Create a DI | ||
$di = new FactoryDefault(); | ||
|
||
// Setting up the view component | ||
$di['view'] = function() { | ||
$view = new View(); | ||
$view->setViewsDir(APP_PATH . '/views/'); | ||
return $view; | ||
}; | ||
|
||
// Setup a base URI so that all generated URIs include the "tutorial" folder | ||
$di['url'] = function() { | ||
$url = new Url(); | ||
$url->setBaseUri('/'); | ||
return $url; | ||
}; | ||
|
||
// Set the database service | ||
$di['db'] = function() { | ||
return new DbAdapter(array( | ||
"host" => "127.0.0.1", | ||
"username" => "root", | ||
"password" => "secret", | ||
"dbname" => "tutorial1" | ||
)); | ||
}; | ||
|
||
// Handle the request | ||
try { | ||
|
||
// Register an autoloader | ||
$loader = new Loader(); | ||
$loader->registerDirs( | ||
array( | ||
'../app/controllers/', | ||
'../app/models/' | ||
) | ||
)->register(); | ||
|
||
// Create a DI | ||
$di = new FactoryDefault(); | ||
|
||
// Set the database service | ||
$di['db'] = function() { | ||
return new DbAdapter(array( | ||
"host" => "localhost", | ||
"username" => "root", | ||
"password" => "secret", | ||
"dbname" => "tutorial" | ||
)); | ||
}; | ||
|
||
// Setting up the view component | ||
$di['view'] = function() { | ||
$view = new View(); | ||
$view->setViewsDir('../app/views/'); | ||
return $view; | ||
}; | ||
|
||
// Setup a base URI so that all generated URIs include the "tutorial" folder | ||
$di['url'] = function() { | ||
$url = new Url(); | ||
$url->setBaseUri('/tutorial/'); | ||
return $url; | ||
}; | ||
|
||
// Setup the tag helpers | ||
$di['tag'] = function() { | ||
return new Tag(); | ||
}; | ||
|
||
// Handle the request | ||
$application = new Application($di); | ||
|
||
echo $application->handle()->getContent(); | ||
|
||
} catch (Exception $e) { | ||
echo "Exception: ", $e->getMessage(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters