Skip to content

Commit 17a2936

Browse files
committed
Added boxfile for nanobox; Added storage folder; Using nanobox db
1 parent 8008230 commit 17a2936

11 files changed

Lines changed: 127 additions & 145 deletions

File tree

.htrouter.php

Lines changed: 0 additions & 29 deletions
This file was deleted.

app/controllers/IndexController.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
class IndexController extends Controller
66
{
77

8-
public function indexAction()
9-
{
10-
11-
}
12-
8+
public function indexAction()
9+
{
10+
}
1311
}

app/controllers/SignupController.php

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,30 @@
55
class SignupController extends Controller
66
{
77

8-
public function indexAction()
9-
{
10-
11-
}
12-
13-
public function registerAction()
14-
{
15-
16-
$user = new Users();
17-
18-
// Store and check for errors
19-
$success = $user->save(
20-
$this->request->getPost(),
21-
array('name', 'email')
22-
);
23-
24-
if ($success) {
25-
echo "Thanks for registering!";
26-
} else {
27-
echo "Sorry, the following problems were generated: ";
28-
foreach ($user->getMessages() as $message) {
29-
echo $message->getMessage(), "<br/>";
30-
}
31-
}
32-
33-
$this->view->disable();
34-
}
35-
8+
public function indexAction()
9+
{
10+
}
11+
12+
public function registerAction()
13+
{
14+
15+
$user = new Users();
16+
17+
// Store and check for errors
18+
$success = $user->save(
19+
$this->request->getPost(),
20+
['name', 'email']
21+
);
22+
23+
if ($success) {
24+
echo "Thanks for registering!";
25+
} else {
26+
echo "Sorry, the following problems were generated: ";
27+
foreach ($user->getMessages() as $message) {
28+
echo $message->getMessage(), "<br/>";
29+
}
30+
}
31+
32+
$this->view->disable();
33+
}
3634
}

app/models/Users.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
class Users extends Model
66
{
7-
8-
public $id;
9-
public $name;
10-
public $email;
11-
7+
public $id;
8+
public $name;
9+
public $email;
1210
}

app/views/signup/index.phtml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
<?php echo $this->tag->form('signup/register') ?>
44

5-
<p>
6-
<label for="name">Name</label>
7-
<?php echo $this->tag->textField("name") ?>
8-
</p>
5+
<p>
6+
<label for="name">Name</label>
7+
<?php echo $this->tag->textField("name") ?>
8+
</p>
99

10-
<p>
11-
<label for="name">E-Mail</label>
12-
<?php echo $this->tag->textField("email") ?>
13-
</p>
10+
<p>
11+
<label for="name">E-Mail</label>
12+
<?php echo $this->tag->textField("email") ?>
13+
</p>
1414

15-
<p>
16-
<?php echo $this->tag->submitButton("Register") ?>
17-
</p>
15+
<p>
16+
<?php echo $this->tag->submitButton("Register") ?>
17+
</p>
1818

19-
</form>
19+
<?php echo $this->tag->endForm() ?>

boxfile.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
run.config:
2+
engine: php
3+
engine.config:
4+
runtime: php-7.2
5+
extensions:
6+
- pdo
7+
- pdo_mysql
8+
- session
9+
- simplexml
10+
- tokenizer
11+
- xmlwriter
12+
zend_extensions:
13+
- opcache
14+
dev_zend_extensions:
15+
add:
16+
- xdebug
17+
rm:
18+
- opcache
19+
extra_packages:
20+
- mysql-client
21+
- php72-phalcon-3.3.2
22+
extra_steps:
23+
- echo 'extension=phalcon.so' >> "/data/etc/php/dev_php.ini"
24+
- echo 'extension=phalcon.so' >> "/data/etc/php/prod_php.ini"
25+
- cp /app/storage/ci/xdebug.ini /data/etc/php.dev.d/xdebug.ini
26+
27+
data.mysql:
28+
image: nanobox/mysql:5.7

public/index.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,44 @@
1313
// Register an autoloader
1414
$loader = new Loader();
1515
$loader->registerDirs(
16-
array(
16+
[
1717
APP_PATH . '/controllers/',
18-
APP_PATH . '/models/'
19-
)
20-
)->register();
18+
APP_PATH . '/models/',
19+
]
20+
)->register()
21+
;
2122

2223
// Create a DI
2324
$di = new FactoryDefault();
2425

2526
// Setting up the view component
26-
$di['view'] = function() {
27+
$di['view'] = function () {
2728
$view = new View();
2829
$view->setViewsDir(APP_PATH . '/views/');
2930
return $view;
3031
};
3132

3233
// Setup a base URI so that all generated URIs include the "tutorial" folder
33-
$di['url'] = function() {
34+
$di['url'] = function () {
3435
$url = new UrlProvider();
3536
$url->setBaseUri('/');
3637
return $url;
3738
};
3839

3940
// 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-
));
41+
$di['db'] = function () {
42+
return new DbAdapter([
43+
"host" => getenv('DATA_MYSQL_HOST'),
44+
"username" => getenv('DATA_MYSQL_USER'),
45+
"password" => getenv('DATA_MYSQL_PASS'),
46+
"dbname" => "gonano",
47+
]);
4748
};
4849

4950
// Handle the request
5051
try {
5152
$application = new Application($di);
5253
echo $application->handle()->getContent();
5354
} catch (Exception $e) {
54-
echo "Exception: ", $e->getMessage();
55+
echo "Exception: ", $e->getMessage();
5556
}

schemas/tutorial.sql

Lines changed: 0 additions & 52 deletions
This file was deleted.

storage/ci/import_db.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
mysql --user=$DATA_MYSQL_USER \
4+
--password=$DATA_MYSQL_PASS \
5+
--host=$DATA_MYSQL_HOST \
6+
gonano < /app/storage/schemas/tutorial.sql

storage/ci/xdebug.ini

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
xdebug.coverage_enable = 1
2+
xdebug.default_enable = 1
3+
xdebug.extended_info = 1
4+
xdebug.force_display_errors = 0
5+
xdebug.force_error_reporting = 0
6+
xdebug.max_nesting_level = 256
7+
xdebug.profiler_enable = 1
8+
xdebug.profiler_enable_trigger = 1
9+
xdebug.profiler_output_dir = "/tmp"
10+
xdebug.remote_autostart = 0
11+
xdebug.remote_connect_back = 1
12+
xdebug.remote_cookie_expire_time = 3600
13+
xdebug.remote_enable = 1
14+
xdebug.remote_handler = "dbgp"
15+
xdebug.remote_host = "localhost"
16+
xdebug.remote_log = ""
17+
xdebug.remote_mode = "req"
18+
xdebug.remote_port = 9090
19+
xdebug.show_error_trace = 1
20+
xdebug.show_exception_trace = 1
21+
xdebug.show_local_vars = 1
22+
xdebug.var_display_max_children = 128
23+
xdebug.var_display_max_data = 512
24+
xdebug.var_display_max_depth = 3

0 commit comments

Comments
 (0)