" \
11 | description="The PHP image to test the tutorial application"
12 |
13 | ENV PHALCON_VERSION="5.6.0"
14 |
15 | # Update
16 | RUN apt update -y && \
17 | apt install -y \
18 | apt-utils \
19 | gettext \
20 | git \
21 | libzip-dev \
22 | nano \
23 | sudo \
24 | wget \
25 | zip
26 |
27 | # PECL Packages
28 | RUN pecl install phalcon-${PHALCON_VERSION} \
29 | xdebug
30 |
31 | # Install PHP extensions
32 | RUN docker-php-ext-install \
33 | gettext \
34 | pdo_mysql \
35 | zip
36 |
37 | # Install PHP extensions
38 | RUN docker-php-ext-enable \
39 | opcache \
40 | phalcon \
41 | xdebug
42 |
43 | # Clear cache
44 | RUN apt-get clean && rm -rf /var/lib/apt/lists/*
45 |
46 | # Add user
47 | RUN groupadd -g 1000 phalcon
48 | RUN useradd -u 1000 -ms /bin/bash -g phalcon phalcon
49 |
50 | # Composer
51 | COPY --from=composer /usr/bin/composer /usr/local/bin/composer
52 |
53 | # Copy existing application directory contents
54 | COPY . /code
55 |
56 | # Bash script with helper aliases
57 | COPY config/.bashrc /root/.bashrc
58 | COPY config/.bashrc /home/phalcon/.bashrc
59 |
60 | # Copy existing application directory permissions
61 | COPY --chown=phalcon:phalcon . /code
62 |
63 | # Change current user to phalcon
64 | USER phalcon
65 |
66 | EXPOSE 80
67 |
68 | CMD ["php", "-S", "0.0.0.0:80", "-t", "public/", ".htrouter.php"]
69 |
--------------------------------------------------------------------------------
/resources/docker/8.3/config/.bashrc:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Easier navigation: .., ..., ...., ....., ~ and -
4 | alias ..="cd .."
5 | alias ...="cd ../.."
6 | alias ....="cd ../../.."
7 | alias .....="cd ../../../.."
8 | alias ~="cd ~" # `cd` is probably faster to type though
9 | alias -- -="cd -"
10 |
11 | # Shortcuts
12 | alias g="git"
13 | alias h="history"
14 |
15 | # Detect which `ls` flavor is in use
16 | if ls --color > /dev/null 2>&1; then # GNU `ls`
17 | colorflag="--color"
18 | else # OS X `ls`
19 | colorflag="-G"
20 | fi
21 |
22 | # List all files colorized in long format
23 | # shellcheck disable=SC2139
24 | alias l="ls -lF ${colorflag}"
25 |
26 | # List all files colorized in long format, including dot files
27 | # shellcheck disable=SC2139
28 | alias la="ls -laF ${colorflag}"
29 |
30 | # List only directories
31 | # shellcheck disable=SC2139
32 | alias lsd="ls -lF ${colorflag} | grep --color=never '^d'"
33 |
34 | # See: https://superuser.com/a/656746/280737
35 | alias ll='LC_ALL="C.UTF-8" ls -alF'
36 |
37 | # Always use color output for `ls`
38 | # shellcheck disable=SC2139
39 | alias ls="command ls ${colorflag}"
40 | export LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:'
41 |
42 | # Always enable colored `grep` output
43 | alias grep='grep --color=auto '
44 |
45 | # Enable aliases to be sudo’ed
46 | alias sudo='sudo '
47 |
48 | # Get week number
49 | alias week='date +%V'
50 |
51 | # Stopwatch
52 | alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date'
53 |
54 | # Canonical hex dump; some systems have this symlinked
55 | command -v hd > /dev/null || alias hd="hexdump -C"
56 |
57 | # vhosts
58 | alias hosts='sudo nano /etc/hosts'
59 |
60 | # copy working directory
61 | alias cwd='pwd | tr -d "\r\n" | xclip -selection clipboard'
62 |
63 | # copy file interactive
64 | alias cp='cp -i'
65 |
66 | # move file interactive
67 | alias mv='mv -i'
68 |
69 | # untar
70 | alias untar='tar xvf'
71 |
72 | # Zephir related
73 | alias untar='tar xvf'
74 |
75 | PATH=$PATH:./vendor/bin
76 |
--------------------------------------------------------------------------------
/resources/docker/8.3/config/extra.ini:
--------------------------------------------------------------------------------
1 | error_reporting = E_ALL
2 | display_errors = "On"
3 | display_startup_errors = "On"
4 | log_errors = "On"
5 | error_log = /code/php_errors.log
6 | memory_limit = 512M
7 | apc.enable_cli = "On"
8 | session.save_path = "/tmp"
9 |
10 | ;xdebug
11 | xdebug.client_host = "localhost"
12 | xdebug.client_port = 9090
13 | xdebug.discover_client_host = 1
14 | xdebug.force_display_errors = 0
15 | xdebug.force_error_reporting = 0
16 | xdebug.max_nesting_level = 256
17 | xdebug.mode = coverage, debug, develop
18 | xdebug.output_dir = "/tmp"
19 | xdebug.remote_cookie_expire_time = 3600
20 | xdebug.remote_mode = "req"
21 | xdebug.show_error_trace = 1
22 | xdebug.show_exception_trace = 1
23 | xdebug.show_local_vars = 1
24 | xdebug.start_with_request = yes
25 | xdebug.var_display_max_children = 128
26 | xdebug.var_display_max_data = 512
27 | xdebug.var_display_max_depth = 3
28 |
--------------------------------------------------------------------------------
/resources/schemas/tutorial.sql:
--------------------------------------------------------------------------------
1 | CREATE DATABASE IF NOT EXISTS `tutorial` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;
2 | USE `tutorial`;
3 |
4 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
5 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
6 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
7 | /*!40101 SET NAMES utf8mb4 */;
8 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
9 | /*!40103 SET TIME_ZONE='+00:00' */;
10 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
11 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
12 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
13 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
14 |
15 | --
16 | -- Table structure for table `users`
17 | --
18 |
19 | /*!40101 SET @saved_cs_client = @@character_set_client */;
20 | /*!40101 SET character_set_client = utf8mb4 */;
21 | CREATE TABLE `users`
22 | (
23 | `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Record ID',
24 | `name` varchar(255) NOT NULL COMMENT 'User Name',
25 | `email` varchar(255) NOT NULL COMMENT 'User Email Address',
26 | PRIMARY KEY (`id`)
27 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
28 |
29 | /*!40101 SET character_set_client = @saved_cs_client */;
30 |
31 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
32 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
33 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
34 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
35 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
36 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
37 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
38 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
39 |
40 | INSERT INTO `users` (`name`, `email`)
41 | VALUES ('Phalcon Team', 'team@phalcon.io');
42 |
--------------------------------------------------------------------------------
/src/controllers/IndexController.php:
--------------------------------------------------------------------------------
1 | view->users = Users::find();
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/controllers/SignupController.php:
--------------------------------------------------------------------------------
1 | request->getPost();
20 |
21 | // Store and check for errors
22 | $user = new Users();
23 | $user->name = $post['name'];
24 | $user->email = $post['email'];
25 | // Store and check for errors
26 | $success = $user->save();
27 |
28 | // passing the result to the view
29 | $this->view->success = $success;
30 |
31 | if ($success) {
32 | $message = "Thanks for registering!";
33 | } else {
34 | $message = "Sorry, the following problems were generated:
"
35 | . implode('
', $user->getMessages());
36 | }
37 |
38 | // passing a message to the view
39 | $this->view->message = $message;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/models/Users.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Phalcon Tutorial
6 |
8 |
9 |
10 |
11 | getContent(); ?>
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/views/index/index.phtml:
--------------------------------------------------------------------------------
1 | Hello!";
4 |
5 | echo $this->tag->a('signup', 'Sign Up Here!', ['class' => 'btn btn-primary']);
6 |
7 | if ($users->count() > 0) {
8 | ?>
9 |
10 |
11 |
12 | # |
13 | Name |
14 | Email |
15 |
16 |
17 |
18 |
19 | Users quantity: count(); ?> |
20 |
21 |
22 |
23 |
24 |
25 | id; ?> |
26 | name; ?> |
27 | email; ?> |
28 |
29 |
30 |
31 |
32 | Sign using this form
2 |
3 | tag->form(['action' => '/signup/register']); ?>
4 |
5 |
6 |
7 | tag->inputText('name'); ?>
8 |
9 |
10 |
11 |
12 | tag->inputText('email'); ?>
13 |
14 |
15 |
16 | tag->inputSubmit('Register', null, ['class' => 'btn btn-primary']); ?>
17 |
18 |
19 | tag->close('form'); ?>
20 |
--------------------------------------------------------------------------------
/src/views/signup/register.phtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | tag->a('/', 'Go back', ['class' => 'btn btn-primary']); ?>
6 |
--------------------------------------------------------------------------------