Skip to content

Commit 4047ca0

Browse files
committed
Revise tutorial project to match documentation
1 parent 01a8107 commit 4047ca0

File tree

9 files changed

+83
-58
lines changed

9 files changed

+83
-58
lines changed

.htrouter.php

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/*
3+
+------------------------------------------------------------------------+
4+
| Phalcon Developer Tools |
5+
+------------------------------------------------------------------------+
6+
| Copyright (c) 2011-2017 Phalcon Team (https://www.phalconphp.com) |
7+
+------------------------------------------------------------------------+
8+
| This source file is subject to the New BSD License that is bundled |
9+
| with this package in the file LICENSE.txt. |
10+
| |
11+
| If you did not receive a copy of the license and are unable to |
12+
| obtain it through the world-wide-web, please send an email |
13+
| to [email protected] so we can send you a copy immediately. |
14+
+------------------------------------------------------------------------+
15+
| Authors: Andres Gutierrez <[email protected]> |
16+
| Eduar Carvajal <[email protected]> |
17+
| Serghei Iakovlev <[email protected]> |
18+
+------------------------------------------------------------------------+
19+
*/
20+
21+
define('PUBLIC_PATH', __DIR__ . '/public');
22+
23+
$uri = urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
24+
if ($uri !== '/' && file_exists(PUBLIC_PATH . $uri)) {
25+
return false;
26+
}
27+
$_GET['_url'] = $_SERVER['REQUEST_URI'];
28+
29+
require_once PUBLIC_PATH . '/index.php';

.phalcon/.gitkeep

Whitespace-only changes.

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,20 @@ Check out a [explanation article][1].
1414
To run this application on your machine, you need at least:
1515

1616
* PHP >= 5.4
17-
* [Apache][2] Web Server with [mod_rewrite][3] enabled or [Nginx][4] Web Server
17+
* Server Any of the following
18+
* [Phalcon Devtools][7] using provided **.htrouter** and `phalcon serve` command
19+
* [Apache][2] Web Server with [mod_rewrite][3] enabled
20+
* [Nginx][4] Web Server
1821
* Latest stable [Phalcon Framework release][5] extension enabled
1922

2023
## License
2124

2225
Phalcon Tutorial is open-sourced software licensed under the [New BSD License][6]. © Phalcon Framework Team and contributors
2326

24-
[1]: http://docs.phalconphp.com/en/latest/reference/tutorial.html
27+
[1]: https://docs.phalconphp.com/en/latest/tutorial-base
2528
[2]: http://httpd.apache.org/
2629
[3]: http://httpd.apache.org/docs/current/mod/mod_rewrite.html
2730
[4]: http://nginx.org/
2831
[5]: https://github.com/phalcon/cphalcon/releases
2932
[6]: https://github.com/phalcon/tutorial/blob/master/docs/LICENSE.md
33+
[7]: https://github.com/phalcon/phalcon-devtools

app/models/Users.php

-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ class Users extends Model
66
{
77

88
public $id;
9-
109
public $name;
11-
1210
public $email;
1311

1412
}

app/views/index/index.phtml

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
echo "<h1>Hello!</h1>";
44

55
echo $this->tag->linkTo("signup", "Sign Up Here!");
6-

docs/LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
New BSD License
22
===============
33

4-
Copyright (c) 2013-2015, Phalcon Framework Team and contributors
4+
Copyright (c) 2013-2017, Phalcon Framework Team and contributors
55
All rights reserved.
66

77
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

docs/LICENSE.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
New BSD License
22

3-
Copyright (c) 2013-2015, Phalcon Framework Team and contributors
3+
Copyright (c) 2013-2017, Phalcon Framework Team and contributors
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without

public/index.php

+40-46
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,55 @@
11
<?php
22

33
use Phalcon\Loader;
4-
use Phalcon\Tag;
54
use Phalcon\Mvc\Url;
65
use Phalcon\Mvc\View;
76
use Phalcon\Mvc\Application;
87
use Phalcon\DI\FactoryDefault;
98
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
109

10+
define('BASE_PATH', dirname(__DIR__));
11+
define('APP_PATH', BASE_PATH . '/app');
12+
13+
// Register an autoloader
14+
$loader = new Loader();
15+
$loader->registerDirs(
16+
array(
17+
APP_PATH . '/controllers/',
18+
APP_PATH . '/models/'
19+
)
20+
)->register();
21+
22+
// Create a DI
23+
$di = new FactoryDefault();
24+
25+
// Setting up the view component
26+
$di['view'] = function() {
27+
$view = new View();
28+
$view->setViewsDir(APP_PATH . '/views/');
29+
return $view;
30+
};
31+
32+
// Setup a base URI so that all generated URIs include the "tutorial" folder
33+
$di['url'] = function() {
34+
$url = new Url();
35+
$url->setBaseUri('/');
36+
return $url;
37+
};
38+
39+
// Set the database service
40+
$di['db'] = function() {
41+
return new DbAdapter(array(
42+
"host" => "127.0.0.1",
43+
"username" => "root",
44+
"password" => "secret",
45+
"dbname" => "tutorial1"
46+
));
47+
};
48+
49+
// Handle the request
1150
try {
12-
13-
// Register an autoloader
14-
$loader = new Loader();
15-
$loader->registerDirs(
16-
array(
17-
'../app/controllers/',
18-
'../app/models/'
19-
)
20-
)->register();
21-
22-
// Create a DI
23-
$di = new FactoryDefault();
24-
25-
// Set the database service
26-
$di['db'] = function() {
27-
return new DbAdapter(array(
28-
"host" => "localhost",
29-
"username" => "root",
30-
"password" => "secret",
31-
"dbname" => "tutorial"
32-
));
33-
};
34-
35-
// Setting up the view component
36-
$di['view'] = function() {
37-
$view = new View();
38-
$view->setViewsDir('../app/views/');
39-
return $view;
40-
};
41-
42-
// Setup a base URI so that all generated URIs include the "tutorial" folder
43-
$di['url'] = function() {
44-
$url = new Url();
45-
$url->setBaseUri('/tutorial/');
46-
return $url;
47-
};
48-
49-
// Setup the tag helpers
50-
$di['tag'] = function() {
51-
return new Tag();
52-
};
53-
54-
// Handle the request
5551
$application = new Application($di);
56-
5752
echo $application->handle()->getContent();
58-
5953
} catch (Exception $e) {
6054
echo "Exception: ", $e->getMessage();
6155
}

schemas/tutorial.sql

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- MySQL dump 10.13 Distrib 5.5.36, for osx10.9 (i386)
22
--
3-
-- Host: localhost Database: tutorial
3+
-- Host: localhost Database: tutorial1
44
-- ------------------------------------------------------
55
-- Server version 5.5.36
66

@@ -23,10 +23,11 @@ DROP TABLE IF EXISTS `users`;
2323
/*!40101 SET @saved_cs_client = @@character_set_client */;
2424
/*!40101 SET character_set_client = utf8 */;
2525
CREATE TABLE `users` (
26-
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
27-
`name` varchar(70) NOT NULL,
28-
`email` varchar(70) NOT NULL,
29-
PRIMARY KEY (`id`)
26+
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
27+
`name` varchar(70) NOT NULL,
28+
`email` varchar(70) NOT NULL,
29+
30+
PRIMARY KEY (`id`)
3031
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3132
/*!40101 SET character_set_client = @saved_cs_client */;
3233

0 commit comments

Comments
 (0)