Skip to content

Commit 307c0eb

Browse files
authored
Merge branch 'master' into patch-1
2 parents 73c9d83 + 628f785 commit 307c0eb

File tree

11 files changed

+80
-58
lines changed

11 files changed

+80
-58
lines changed

.htaccess

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<IfModule mod_rewrite.c>
22
RewriteEngine on
33
RewriteRule ^$ public/ [L]
4-
RewriteRule (.*) public/$1 [L]
5-
</IfModule>
4+
RewriteRule ((?s).*) public/$1 [L]
5+
</IfModule>

.htrouter.php

Lines changed: 29 additions & 0 deletions
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

Lines changed: 6 additions & 2 deletions
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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/.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 ^((?s).*)$ index.php?_url=/$1 [QSA,L]
77
</IfModule>

public/index.php

Lines changed: 34 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,58 +7,49 @@
77
use Phalcon\Mvc\Url as UrlProvider;
88
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
99

10-
10+
define('BASE_PATH', dirname(__DIR__));
11+
define('APP_PATH', BASE_PATH . '/app');
1112

1213
// Register an autoloader
1314
$loader = new Loader();
14-
1515
$loader->registerDirs(
16-
[
17-
"../app/controllers/",
18-
"../app/models/",
19-
]
20-
);
21-
22-
$loader->register();
23-
24-
16+
array(
17+
APP_PATH . '/controllers/',
18+
APP_PATH . '/models/'
19+
)
20+
)->register();
2521

2622
// Create a DI
2723
$di = new FactoryDefault();
2824

29-
// Setup the view component
30-
$di->set(
31-
"view",
32-
function () {
33-
$view = new View();
34-
35-
$view->setViewsDir("../app/views/");
36-
37-
return $view;
38-
}
39-
);
25+
// Setting up the view component
26+
$di['view'] = function() {
27+
$view = new View();
28+
$view->setViewsDir(APP_PATH . '/views/');
29+
return $view;
30+
};
4031

4132
// Setup a base URI so that all generated URIs include the "tutorial" folder
42-
$di->set(
43-
"url",
44-
function () {
45-
$url = new UrlProvider();
46-
47-
$url->setBaseUri("/tutorial/");
48-
49-
return $url;
50-
}
51-
);
52-
53-
54-
55-
$application = new Application($di);
56-
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
5750
try {
58-
// Handle the request
59-
$response = $application->handle();
60-
61-
$response->send();
62-
} catch (\Exception $e) {
63-
echo "Exception: ", $e->getMessage();
51+
$application = new Application($di);
52+
echo $application->handle()->getContent();
53+
} catch (Exception $e) {
54+
echo "Exception: ", $e->getMessage();
6455
}

0 commit comments

Comments
 (0)