├── .gitignore ├── README.md ├── blog ├── .gitignore ├── Dockerfile ├── LICENSE.md ├── README.md ├── Vagrantfile ├── composer.json ├── composer.lock ├── composer.phar ├── config │ ├── application.config.php │ ├── autoload │ │ ├── .gitignore │ │ ├── README.md │ │ ├── development.local.php.dist │ │ ├── global.php │ │ ├── local.php.dist │ │ └── zend-developer-tools.local-development.php │ ├── development.config.php.dist │ └── modules.config.php ├── data │ ├── Migrations │ │ ├── Version20160901114333.php │ │ └── Version20160901114938.php │ ├── cache │ │ └── .gitignore │ └── schema.mysql.sql ├── docker-compose.yml ├── module │ └── Application │ │ ├── config │ │ └── module.config.php │ │ ├── src │ │ ├── Controller │ │ │ ├── Factory │ │ │ │ ├── IndexControllerFactory.php │ │ │ │ └── PostControllerFactory.php │ │ │ ├── IndexController.php │ │ │ └── PostController.php │ │ ├── Entity │ │ │ ├── Comment.php │ │ │ ├── Post.php │ │ │ └── Tag.php │ │ ├── Form │ │ │ ├── CommentForm.php │ │ │ └── PostForm.php │ │ ├── Module.php │ │ ├── Repository │ │ │ └── PostRepository.php │ │ ├── Service │ │ │ ├── Factory │ │ │ │ └── PostManagerFactory.php │ │ │ └── PostManager.php │ │ └── View │ │ │ └── Helper │ │ │ ├── Breadcrumbs.php │ │ │ └── Menu.php │ │ ├── test │ │ └── Controller │ │ │ └── IndexControllerTest.php │ │ └── view │ │ ├── application │ │ ├── index │ │ │ ├── about.phtml │ │ │ └── index.phtml │ │ ├── partial │ │ │ └── paginator.phtml │ │ └── post │ │ │ ├── add.phtml │ │ │ ├── admin.phtml │ │ │ ├── edit.phtml │ │ │ └── view.phtml │ │ ├── error │ │ ├── 404.phtml │ │ └── index.phtml │ │ └── layout │ │ └── layout.phtml ├── phpunit.xml.dist └── public │ ├── .htaccess │ ├── css │ ├── bootstrap-theme.css │ ├── bootstrap-theme.css.map │ ├── bootstrap-theme.min.css │ ├── bootstrap-theme.min.css.map │ ├── bootstrap.css │ ├── bootstrap.css.map │ ├── bootstrap.min.css │ ├── bootstrap.min.css.map │ └── style.css │ ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 │ ├── img │ ├── favicon.ico │ └── zf-logo.png │ ├── index.php │ └── js │ ├── bootstrap.js │ ├── bootstrap.min.js │ └── jquery-2.2.4.min.js ├── formdemo ├── .gitignore ├── Dockerfile ├── LICENSE.md ├── README.md ├── Vagrantfile ├── composer.json ├── composer.lock ├── composer.phar ├── config │ ├── application.config.php │ ├── autoload │ │ ├── .gitignore │ │ ├── README.md │ │ ├── development.local.php.dist │ │ ├── global.php │ │ ├── local.php.dist │ │ └── zend-developer-tools.local-development.php │ ├── development.config.php.dist │ └── modules.config.php ├── data │ ├── cache │ │ └── .gitignore │ └── font │ │ └── thorne_shaded.ttf ├── docker-compose.yml ├── module │ └── Application │ │ ├── config │ │ └── module.config.php │ │ ├── src │ │ ├── Controller │ │ │ ├── Factory │ │ │ │ ├── ImageControllerFactory.php │ │ │ │ ├── IndexControllerFactory.php │ │ │ │ └── RegistrationControllerFactory.php │ │ │ ├── ImageController.php │ │ │ ├── IndexController.php │ │ │ └── RegistrationController.php │ │ ├── Filter │ │ │ └── PhoneFilter.php │ │ ├── Form │ │ │ ├── ContactForm.php │ │ │ ├── ImageForm.php │ │ │ ├── PaymentForm.php │ │ │ └── RegistrationForm.php │ │ ├── Module.php │ │ ├── Service │ │ │ ├── ImageManager.php │ │ │ └── MailSender.php │ │ ├── Validator │ │ │ └── PhoneValidator.php │ │ └── View │ │ │ └── Helper │ │ │ ├── Breadcrumbs.php │ │ │ └── Menu.php │ │ ├── test │ │ └── Controller │ │ │ └── IndexControllerTest.php │ │ └── view │ │ ├── application │ │ ├── image │ │ │ ├── index.phtml │ │ │ └── upload.phtml │ │ ├── index │ │ │ ├── about.phtml │ │ │ ├── contact-us.phtml │ │ │ ├── index.phtml │ │ │ ├── payment.phtml │ │ │ ├── send-error.phtml │ │ │ └── thank-you.phtml │ │ └── registration │ │ │ ├── review.phtml │ │ │ ├── step1.phtml │ │ │ ├── step2.phtml │ │ │ └── step3.phtml │ │ ├── error │ │ ├── 404.phtml │ │ └── index.phtml │ │ └── layout │ │ └── layout.phtml ├── phpunit.xml.dist └── public │ ├── .htaccess │ ├── css │ ├── bootstrap-theme.css │ ├── bootstrap-theme.css.map │ ├── bootstrap-theme.min.css │ ├── bootstrap-theme.min.css.map │ ├── bootstrap.css │ ├── bootstrap.css.map │ ├── bootstrap.min.css │ ├── bootstrap.min.css.map │ └── style.css │ ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 │ ├── img │ ├── favicon.ico │ └── zf-logo.png │ ├── index.php │ └── js │ ├── bootstrap.js │ ├── bootstrap.min.js │ └── jquery-2.2.4.min.js ├── helloworld ├── .gitignore ├── Dockerfile ├── LICENSE.md ├── README.md ├── Vagrantfile ├── composer.json ├── composer.lock ├── composer.phar ├── config │ ├── application.config.php │ ├── autoload │ │ ├── .gitignore │ │ ├── README.md │ │ ├── development.local.php.dist │ │ ├── global.php │ │ ├── local.php.dist │ │ └── zend-developer-tools.local-development.php │ ├── development.config.php.dist │ └── modules.config.php ├── data │ ├── cache │ │ └── .gitignore │ └── download │ │ └── sample.txt ├── docker-compose.yml ├── module │ └── Application │ │ ├── config │ │ └── module.config.php │ │ ├── src │ │ ├── Controller │ │ │ ├── DownloadController.php │ │ │ └── IndexController.php │ │ ├── Module.php │ │ ├── Route │ │ │ └── StaticRoute.php │ │ └── View │ │ │ └── Helper │ │ │ ├── Breadcrumbs.php │ │ │ └── Menu.php │ │ ├── test │ │ └── Controller │ │ │ └── IndexControllerTest.php │ │ └── view │ │ ├── application │ │ ├── download │ │ │ └── index.phtml │ │ └── index │ │ │ ├── about.phtml │ │ │ ├── doc │ │ │ ├── contents.phtml │ │ │ ├── install.phtml │ │ │ └── introduction.phtml │ │ │ ├── index.phtml │ │ │ ├── partial-demo.phtml │ │ │ ├── static │ │ │ ├── chapter1 │ │ │ │ └── intro.phtml │ │ │ ├── datepicker.phtml │ │ │ ├── help.phtml │ │ │ └── typeahead.phtml │ │ │ └── table-row.phtml │ │ ├── error │ │ ├── 404.phtml │ │ └── index.phtml │ │ └── layout │ │ ├── layout.phtml │ │ └── layout2.phtml ├── phpunit.xml.dist └── public │ ├── .htaccess │ ├── css │ ├── bootstrap-theme.css │ ├── bootstrap-theme.css.map │ ├── bootstrap-theme.min.css │ ├── bootstrap-theme.min.css.map │ ├── bootstrap.css │ ├── bootstrap.css.map │ ├── bootstrap.min.css │ ├── bootstrap.min.css.map │ ├── jquery-ui.min.css │ └── style.css │ ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 │ ├── img │ ├── favicon.ico │ └── zf-logo.png │ ├── index.php │ └── js │ ├── bootstrap.js │ ├── bootstrap.min.js │ ├── jquery-2.2.4.min.js │ ├── jquery-ui.min.js │ └── typeahead.min.js ├── i18ndemo ├── .gitignore ├── Dockerfile ├── LICENSE.md ├── README.md ├── Vagrantfile ├── composer.json ├── composer.lock ├── composer.phar ├── config │ ├── application.config.php │ ├── autoload │ │ ├── .gitignore │ │ ├── README.md │ │ ├── development.local.php.dist │ │ ├── global.php │ │ ├── local.php.dist │ │ └── zend-developer-tools.local-development.php │ ├── development.config.php.dist │ └── modules.config.php ├── data │ ├── cache │ │ └── .gitignore │ ├── font │ │ └── thorne_shaded.ttf │ └── language │ │ ├── es_ES.php │ │ └── ru_RU.php ├── docker-compose.yml ├── module │ └── Application │ │ ├── config │ │ └── module.config.php │ │ ├── src │ │ ├── Controller │ │ │ ├── Factory │ │ │ │ └── IndexControllerFactory.php │ │ │ └── IndexController.php │ │ ├── Form │ │ │ └── ContactForm.php │ │ ├── Module.php │ │ ├── Service │ │ │ └── MailSender.php │ │ ├── Validator │ │ │ └── PhoneValidator.php │ │ └── View │ │ │ └── Helper │ │ │ ├── Breadcrumbs.php │ │ │ └── Menu.php │ │ ├── test │ │ └── Controller │ │ │ └── IndexControllerTest.php │ │ └── view │ │ ├── application │ │ └── index │ │ │ ├── about.phtml │ │ │ ├── contact-us.phtml │ │ │ ├── index.phtml │ │ │ ├── send-error.phtml │ │ │ └── thank-you.phtml │ │ ├── error │ │ ├── 404.phtml │ │ └── index.phtml │ │ └── layout │ │ └── layout.phtml ├── phpunit.xml.dist └── public │ ├── .htaccess │ ├── css │ ├── bootstrap-theme.css │ ├── bootstrap-theme.css.map │ ├── bootstrap-theme.min.css │ ├── bootstrap-theme.min.css.map │ ├── bootstrap.css │ ├── bootstrap.css.map │ ├── bootstrap.min.css │ ├── bootstrap.min.css.map │ └── style.css │ ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 │ ├── img │ ├── favicon.ico │ └── zf-logo.png │ ├── index.php │ └── js │ ├── bootstrap.js │ ├── bootstrap.min.js │ └── jquery-2.2.4.min.js ├── purephp ├── README.md ├── index.php ├── login.php └── logout.php ├── renovate.json ├── roledemo ├── .gitignore ├── Dockerfile ├── LICENSE.md ├── README.md ├── Vagrantfile ├── composer.json ├── composer.lock ├── composer.phar ├── config │ ├── application.config.php │ ├── autoload │ │ ├── .gitignore │ │ ├── README.md │ │ ├── development.local.php.dist │ │ ├── global.php │ │ ├── local.php.dist │ │ └── zend-developer-tools.local-development.php │ ├── development.config.php.dist │ └── modules.config.php ├── data │ ├── Migrations │ │ ├── Version20160924162137.php │ │ └── Version20161209132215.php │ └── font │ │ └── thorne_shaded.ttf ├── docker-compose.yml ├── module │ ├── Application │ │ ├── config │ │ │ └── module.config.php │ │ ├── src │ │ │ ├── Controller │ │ │ │ ├── Factory │ │ │ │ │ └── IndexControllerFactory.php │ │ │ │ └── IndexController.php │ │ │ ├── Module.php │ │ │ ├── Service │ │ │ │ ├── Factory │ │ │ │ │ ├── NavManagerFactory.php │ │ │ │ │ └── RbacAssertionManagerFactory.php │ │ │ │ ├── NavManager.php │ │ │ │ └── RbacAssertionManager.php │ │ │ └── View │ │ │ │ └── Helper │ │ │ │ ├── Breadcrumbs.php │ │ │ │ ├── Factory │ │ │ │ └── MenuFactory.php │ │ │ │ └── Menu.php │ │ ├── test │ │ │ └── Controller │ │ │ │ └── IndexControllerTest.php │ │ └── view │ │ │ ├── application │ │ │ └── index │ │ │ │ ├── about.phtml │ │ │ │ ├── index.phtml │ │ │ │ └── settings.phtml │ │ │ ├── error │ │ │ ├── 404.phtml │ │ │ └── index.phtml │ │ │ └── layout │ │ │ └── layout.phtml │ └── User │ │ ├── config │ │ └── module.config.php │ │ ├── src │ │ ├── Controller │ │ │ ├── AuthController.php │ │ │ ├── Factory │ │ │ │ ├── AuthControllerFactory.php │ │ │ │ ├── PermissionControllerFactory.php │ │ │ │ ├── RoleControllerFactory.php │ │ │ │ └── UserControllerFactory.php │ │ │ ├── PermissionController.php │ │ │ ├── Plugin │ │ │ │ ├── AccessPlugin.php │ │ │ │ ├── CurrentUserPlugin.php │ │ │ │ └── Factory │ │ │ │ │ ├── AccessPluginFactory.php │ │ │ │ │ └── CurrentUserPluginFactory.php │ │ │ ├── RoleController.php │ │ │ └── UserController.php │ │ ├── Entity │ │ │ ├── Permission.php │ │ │ ├── Role.php │ │ │ └── User.php │ │ ├── Form │ │ │ ├── LoginForm.php │ │ │ ├── PasswordChangeForm.php │ │ │ ├── PasswordResetForm.php │ │ │ ├── PermissionForm.php │ │ │ ├── RoleForm.php │ │ │ ├── RolePermissionsForm.php │ │ │ └── UserForm.php │ │ ├── Module.php │ │ ├── Repository │ │ │ ├── RoleRepository.php │ │ │ └── UserRepository.php │ │ ├── Service │ │ │ ├── AuthAdapter.php │ │ │ ├── AuthManager.php │ │ │ ├── Factory │ │ │ │ ├── AuthAdapterFactory.php │ │ │ │ ├── AuthManagerFactory.php │ │ │ │ ├── AuthenticationServiceFactory.php │ │ │ │ ├── PermissionManagerFactory.php │ │ │ │ ├── RbacManagerFactory.php │ │ │ │ ├── RoleManagerFactory.php │ │ │ │ └── UserManagerFactory.php │ │ │ ├── PermissionManager.php │ │ │ ├── RbacManager.php │ │ │ ├── RoleManager.php │ │ │ └── UserManager.php │ │ ├── Validator │ │ │ ├── PermissionExistsValidator.php │ │ │ ├── RoleExistsValidator.php │ │ │ └── UserExistsValidator.php │ │ └── View │ │ │ └── Helper │ │ │ ├── Access.php │ │ │ ├── CurrentUser.php │ │ │ └── Factory │ │ │ ├── AccessFactory.php │ │ │ └── CurrentUserFactory.php │ │ ├── test │ │ └── Controller │ │ │ └── UserControllerTest.php │ │ └── view │ │ └── user │ │ ├── auth │ │ ├── login.phtml │ │ └── not-authorized.phtml │ │ ├── email │ │ └── reset-password-email.phtml │ │ ├── partial │ │ └── paginator.phtml │ │ ├── permission │ │ ├── add.phtml │ │ ├── edit.phtml │ │ ├── index.phtml │ │ └── view.phtml │ │ ├── role │ │ ├── add.phtml │ │ ├── edit-permissions.phtml │ │ ├── edit.phtml │ │ ├── index.phtml │ │ └── view.phtml │ │ └── user │ │ ├── add.phtml │ │ ├── change-password.phtml │ │ ├── edit.phtml │ │ ├── index.phtml │ │ ├── message.phtml │ │ ├── reset-password.phtml │ │ ├── set-password.phtml │ │ └── view.phtml ├── phpunit.xml.dist └── public │ ├── .htaccess │ ├── css │ ├── bootstrap-theme.css │ ├── bootstrap-theme.css.map │ ├── bootstrap-theme.min.css │ ├── bootstrap-theme.min.css.map │ ├── bootstrap.css │ ├── bootstrap.css.map │ ├── bootstrap.min.css │ ├── bootstrap.min.css.map │ └── style.css │ ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 │ ├── img │ ├── favicon.ico │ └── zf-logo.png │ ├── index.php │ └── js │ ├── bootstrap.js │ ├── bootstrap.min.js │ └── jquery-2.2.4.min.js └── userdemo ├── .gitignore ├── Dockerfile ├── LICENSE.md ├── README.md ├── Vagrantfile ├── composer.json ├── composer.lock ├── composer.phar ├── config ├── application.config.php ├── autoload │ ├── .gitignore │ ├── README.md │ ├── development.local.php.dist │ ├── global.php │ ├── local.php.dist │ └── zend-developer-tools.local-development.php ├── development.config.php.dist └── modules.config.php ├── data ├── Migrations │ └── Version20160924162137.php ├── cache │ └── .gitignore └── font │ └── thorne_shaded.ttf ├── docker-compose.yml ├── module ├── Application │ ├── config │ │ └── module.config.php │ ├── src │ │ ├── Controller │ │ │ ├── Factory │ │ │ │ └── IndexControllerFactory.php │ │ │ └── IndexController.php │ │ ├── Module.php │ │ ├── Service │ │ │ ├── Factory │ │ │ │ └── NavManagerFactory.php │ │ │ └── NavManager.php │ │ └── View │ │ │ └── Helper │ │ │ ├── Breadcrumbs.php │ │ │ ├── Factory │ │ │ └── MenuFactory.php │ │ │ └── Menu.php │ ├── test │ │ └── Controller │ │ │ └── IndexControllerTest.php │ └── view │ │ ├── application │ │ └── index │ │ │ ├── about.phtml │ │ │ ├── index.phtml │ │ │ └── settings.phtml │ │ ├── error │ │ ├── 404.phtml │ │ └── index.phtml │ │ └── layout │ │ └── layout.phtml └── User │ ├── config │ └── module.config.php │ ├── src │ ├── Controller │ │ ├── AuthController.php │ │ ├── Factory │ │ │ ├── AuthControllerFactory.php │ │ │ └── UserControllerFactory.php │ │ ├── Plugin │ │ │ ├── CurrentUserPlugin.php │ │ │ └── Factory │ │ │ │ └── CurrentUserPluginFactory.php │ │ └── UserController.php │ ├── Entity │ │ └── User.php │ ├── Form │ │ ├── LoginForm.php │ │ ├── PasswordChangeForm.php │ │ ├── PasswordResetForm.php │ │ └── UserForm.php │ ├── Module.php │ ├── Repository │ │ └── UserRepository.php │ ├── Service │ │ ├── AuthAdapter.php │ │ ├── AuthManager.php │ │ ├── Factory │ │ │ ├── AuthAdapterFactory.php │ │ │ ├── AuthManagerFactory.php │ │ │ ├── AuthenticationServiceFactory.php │ │ │ └── UserManagerFactory.php │ │ └── UserManager.php │ ├── Validator │ │ └── UserExistsValidator.php │ └── View │ │ └── Helper │ │ ├── CurrentUser.php │ │ └── Factory │ │ └── CurrentUserFactory.php │ ├── test │ └── Controller │ │ └── UserControllerTest.php │ └── view │ └── user │ ├── auth │ └── login.phtml │ ├── email │ └── reset-password-email.phtml │ ├── partial │ └── paginator.phtml │ └── user │ ├── add.phtml │ ├── change-password.phtml │ ├── edit.phtml │ ├── index.phtml │ ├── message.phtml │ ├── reset-password.phtml │ ├── set-password.phtml │ └── view.phtml ├── phpunit.xml.dist └── public ├── .htaccess ├── css ├── bootstrap-theme.css ├── bootstrap-theme.css.map ├── bootstrap-theme.min.css ├── bootstrap-theme.min.css.map ├── bootstrap.css ├── bootstrap.css.map ├── bootstrap.min.css ├── bootstrap.min.css.map └── style.css ├── fonts ├── glyphicons-halflings-regular.eot ├── glyphicons-halflings-regular.svg ├── glyphicons-halflings-regular.ttf ├── glyphicons-halflings-regular.woff └── glyphicons-halflings-regular.woff2 ├── img ├── favicon.ico └── zf-logo.png ├── index.php └── js ├── bootstrap.js ├── bootstrap.min.js └── jquery-2.2.4.min.js /.gitignore: -------------------------------------------------------------------------------- 1 | ./idea 2 | 3 | /blog/nbproject/private/ 4 | /userdemo/nbproject/private/ 5 | /formdemo/public/img/captcha 6 | -------------------------------------------------------------------------------- /blog/.gitignore: -------------------------------------------------------------------------------- 1 | nbproject 2 | ._* 3 | .vagrant 4 | .~lock.* 5 | .buildpath 6 | .DS_Store 7 | .idea 8 | .project 9 | .settings 10 | vendor/ 11 | config/development.config.php 12 | phpunit.xml 13 | -------------------------------------------------------------------------------- /blog/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.0-apache 2 | 3 | RUN apt-get update \ 4 | && apt-get install -y git zlib1g-dev \ 5 | && docker-php-ext-install zip \ 6 | && a2enmod rewrite \ 7 | && sed -i 's!/var/www/html!/var/www/public!g' /etc/apache2/apache2.conf \ 8 | && mv /var/www/html /var/www/public \ 9 | && curl -sS https://getcomposer.org/installer \ 10 | | php -- --install-dir=/usr/local/bin --filename=composer 11 | 12 | WORKDIR /var/www 13 | -------------------------------------------------------------------------------- /blog/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005-2015, Zend Technologies USA, Inc. 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | - Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | - Neither the name of Zend Technologies USA, Inc. nor the names of its 16 | contributors may be used to endorse or promote products derived from this 17 | software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 23 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /blog/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zendframework/skeleton-application", 3 | "description": "Skeleton Application for Zend Framework zend-mvc applications", 4 | "type": "project", 5 | "license": "BSD-3-Clause", 6 | "keywords": [ 7 | "framework", 8 | "mvc", 9 | "zf2" 10 | ], 11 | "homepage": "http://framework.zend.com/", 12 | "minimum-stability": "dev", 13 | "prefer-stable": true, 14 | "require": { 15 | "php": "^5.6 || ^7.0", 16 | "zendframework/zend-component-installer": "^1.0 || ^0.3 || ^1.0.0-dev@dev", 17 | "zendframework/zend-mvc": "^3.1", 18 | "zfcampus/zf-development-mode": "^3.0", 19 | "zendframework/zend-mvc-form": "^1.0", 20 | "zendframework/zend-mvc-plugins": "^1.0.1", 21 | "zendframework/zend-session": "^2.7.1", 22 | "doctrine/doctrine-orm-module": "^2.0", 23 | "doctrine/migrations": "^1.8" 24 | }, 25 | "autoload": { 26 | "psr-4": { 27 | "Application\\": "module/Application/src/" 28 | } 29 | }, 30 | "autoload-dev": { 31 | "psr-4": { 32 | "ApplicationTest\\": "module/Application/test/" 33 | } 34 | }, 35 | "extra": [], 36 | "scripts": { 37 | "development-disable": "zf-development-mode disable", 38 | "development-enable": "zf-development-mode enable", 39 | "development-status": "zf-development-mode status", 40 | "serve": "php -S 0.0.0.0:8080 -t public/ public/index.php" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /blog/composer.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/blog/composer.phar -------------------------------------------------------------------------------- /blog/config/autoload/.gitignore: -------------------------------------------------------------------------------- 1 | local.php 2 | *.local.php 3 | -------------------------------------------------------------------------------- /blog/config/autoload/README.md: -------------------------------------------------------------------------------- 1 | About this directory: 2 | ===================== 3 | 4 | By default, this application is configured to load all configs in 5 | `./config/autoload/{,*.}{global,local}.php`. Doing this provides a 6 | location for a developer to drop in configuration override files provided by 7 | modules, as well as cleanly provide individual, application-wide config files 8 | for things like database connections, etc. 9 | -------------------------------------------------------------------------------- /blog/config/autoload/development.local.php.dist: -------------------------------------------------------------------------------- 1 | 9 | * $ composer development-enable 10 | * 11 | * 12 | * from the project root to copy this file to development.local.php and enable 13 | * the settings it contains. 14 | * 15 | * You may also create files matching the glob pattern `{,*.}{global,local}-development.php`. 16 | */ 17 | 18 | return [ 19 | 'view_manager' => [ 20 | 'display_exceptions' => true, 21 | ], 22 | ]; 23 | -------------------------------------------------------------------------------- /blog/config/autoload/global.php: -------------------------------------------------------------------------------- 1 | [ 16 | // migrations configuration 17 | 'migrations_configuration' => [ 18 | 'orm_default' => [ 19 | 'directory' => 'data/Migrations', 20 | 'name' => 'Doctrine Database Migrations', 21 | 'namespace' => 'Migrations', 22 | 'table' => 'migrations', 23 | ], 24 | ], 25 | ], 26 | ]; 27 | -------------------------------------------------------------------------------- /blog/config/autoload/local.php.dist: -------------------------------------------------------------------------------- 1 | [ 18 | 'connection' => [ 19 | 'orm_default' => [ 20 | 'driverClass' => PDOMySqlDriver::class, 21 | 'params' => [ 22 | 'host' => '127.0.0.1', 23 | 'user' => 'blog', 24 | 'password' => '', 25 | 'dbname' => 'blog', 26 | ] 27 | ], 28 | ], 29 | ], 30 | ]; 31 | -------------------------------------------------------------------------------- /blog/config/development.config.php.dist: -------------------------------------------------------------------------------- 1 | [ 11 | ], 12 | // Configuration overrides during development mode 13 | 'module_listener_options' => [ 14 | 'config_glob_paths' => [realpath(__DIR__) . '/autoload/{,*.}{global,local}-development.php'], 15 | 'config_cache_enabled' => false, 16 | 'module_map_cache_enabled' => false, 17 | ], 18 | ]; 19 | -------------------------------------------------------------------------------- /blog/config/modules.config.php: -------------------------------------------------------------------------------- 1 | get('doctrine.entitymanager.orm_default'); 18 | $postManager = $container->get(PostManager::class); 19 | 20 | // Instantiate the controller and inject dependencies 21 | return new IndexController($entityManager, $postManager); 22 | } 23 | } 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /blog/module/Application/src/Controller/Factory/PostControllerFactory.php: -------------------------------------------------------------------------------- 1 | get('doctrine.entitymanager.orm_default'); 18 | $postManager = $container->get(PostManager::class); 19 | 20 | // Instantiate the controller and inject dependencies 21 | return new PostController($entityManager, $postManager); 22 | } 23 | } 24 | 25 | 26 | -------------------------------------------------------------------------------- /blog/module/Application/src/Entity/Tag.php: -------------------------------------------------------------------------------- 1 | posts = new ArrayCollection(); 37 | } 38 | 39 | /** 40 | * Returns ID of this tag. 41 | * @return integer 42 | */ 43 | public function getId() 44 | { 45 | return $this->id; 46 | } 47 | 48 | /** 49 | * Sets ID of this tag. 50 | * @param int $id 51 | */ 52 | public function setId($id) 53 | { 54 | $this->id = $id; 55 | } 56 | 57 | /** 58 | * Returns name. 59 | * @return string 60 | */ 61 | public function getName() 62 | { 63 | return $this->name; 64 | } 65 | 66 | /** 67 | * Sets name. 68 | * @param string $name 69 | */ 70 | public function setName($name) 71 | { 72 | $this->name = $name; 73 | } 74 | 75 | /** 76 | * Returns posts which have this tag. 77 | * @return type 78 | */ 79 | public function getPosts() 80 | { 81 | return $this->posts; 82 | } 83 | 84 | /** 85 | * Adds a post which has this tag. 86 | * @param type $post 87 | */ 88 | public function addPost($post) 89 | { 90 | $this->posts[] = $post; 91 | } 92 | } 93 | 94 | -------------------------------------------------------------------------------- /blog/module/Application/src/Module.php: -------------------------------------------------------------------------------- 1 | get('doctrine.entitymanager.orm_default'); 17 | 18 | // Instantiate the service and inject dependencies 19 | return new PostManager($entityManager); 20 | } 21 | } 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /blog/module/Application/view/application/index/about.phtml: -------------------------------------------------------------------------------- 1 | headTitle('About'); 3 | 4 | $this->mainMenu()->setActiveItemId('about'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home'), 8 | 'About'=>$this->url('about'), 9 | ]); 10 | 11 | ?> 12 | 13 |

About

14 | 15 |

16 | Application name: escapeHtml($appName) ?> 17 |

18 | 19 |

20 | Application description: escapeHtml($appDescription) ?> 21 |

22 | 23 | 24 | -------------------------------------------------------------------------------- /blog/module/Application/view/application/partial/paginator.phtml: -------------------------------------------------------------------------------- 1 | pageCount): ?> 2 | 3 | 46 | -------------------------------------------------------------------------------- /blog/module/Application/view/application/post/admin.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Manage Posts'); 3 | 4 | $this->mainMenu()->setActiveItemId('admin'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Admin'=>$this->url('home') 8 | ]); 9 | ?> 10 | 11 |

Manage Posts

12 | 13 |

14 | 16 | New Post 17 | 18 |

19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 39 | 40 | 41 | 51 | 52 | 53 | 54 | 55 |
IDPost TitleDate CreatedStatusActions
escapeHtml($post->getId()); ?> 35 | 36 | escapeHtml($post->getTitle()); ?> 37 | 38 | escapeHtml($post->getDateCreated()); ?>escapeHtml($postManager->getPostStatusAsString($post)); ?> 42 | 44 | Edit 45 | 46 | 48 | Delete 49 | 50 |
-------------------------------------------------------------------------------- /blog/phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ./module/Application/test 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /blog/public/.htaccess: -------------------------------------------------------------------------------- 1 | RewriteEngine On 2 | # The following rule tells Apache that if the requested filename 3 | # exists, simply serve it. 4 | RewriteCond %{REQUEST_FILENAME} -s [OR] 5 | RewriteCond %{REQUEST_FILENAME} -l [OR] 6 | RewriteCond %{REQUEST_FILENAME} -d 7 | RewriteRule ^.*$ - [L] 8 | # The following rewrites all other queries to index.php. The 9 | # condition ensures that if you are using Apache aliases to do 10 | # mass virtual hosting or installed the project in a subdirectory, 11 | # the base path will be prepended to allow proper resolution of 12 | # the index.php file; it will work in non-aliased environments 13 | # as well, providing a safe, one-size fits all solution. 14 | RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ 15 | RewriteRule ^(.*) - [E=BASE:%1] 16 | RewriteRule ^(.*)$ %{ENV:BASE}/index.php [L] 17 | -------------------------------------------------------------------------------- /blog/public/css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-bottom: 40px; 3 | } 4 | 5 | .zf-green { 6 | color: #68b604; 7 | } 8 | 9 | .btn-success { 10 | background-color: #57a900; 11 | background-image: -moz-linear-gradient(top, #70d900, #57a900); 12 | background-image: -ms-linear-gradient(top, #70d900, #57a900); 13 | background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#70d900), to(#57a900)); 14 | background-image: -webkit-linear-gradient(top, #70d900, #57a900); 15 | background-image: -o-linear-gradient(top, #70d900, #57a900); 16 | background-image: linear-gradient(top, #70d900, #57a900); 17 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#70d900', endColorstr='#57a900', GradientType=0); 18 | } 19 | 20 | .btn-success:hover, 21 | .btn-success:active, 22 | .btn-success.active, 23 | .btn-success.disabled, 24 | .btn-success[disabled] { 25 | background-color: #57a900; 26 | } 27 | 28 | .btn-success:active, .btn-success.active { 29 | background-color: #57a900; 30 | } 31 | 32 | div.container a.navbar-brand > img { 33 | display: inline; 34 | margin-right: 4px; 35 | } 36 | 37 | div.app-caption { 38 | padding: 25px 0px; 39 | font-size:3.0em; 40 | font-weight: bold; 41 | color:#6aacaf 42 | } 43 | 44 | form ul { 45 | list-style-type: none; 46 | padding: 0px; 47 | margin: 0px 5px; 48 | } 49 | 50 | form ul li { 51 | color: red; 52 | } -------------------------------------------------------------------------------- /blog/public/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/blog/public/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /blog/public/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/blog/public/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /blog/public/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/blog/public/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /blog/public/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/blog/public/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /blog/public/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/blog/public/img/favicon.ico -------------------------------------------------------------------------------- /blog/public/img/zf-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/blog/public/img/zf-logo.png -------------------------------------------------------------------------------- /blog/public/index.php: -------------------------------------------------------------------------------- 1 | run(); 41 | -------------------------------------------------------------------------------- /formdemo/.gitignore: -------------------------------------------------------------------------------- 1 | nbproject 2 | ._* 3 | .vagrant 4 | .~lock.* 5 | .buildpath 6 | .DS_Store 7 | .idea 8 | .project 9 | .settings 10 | vendor/ 11 | config/development.config.php 12 | phpunit.xml 13 | data/upload 14 | public/img/captcha/* 15 | -------------------------------------------------------------------------------- /formdemo/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.0-apache 2 | 3 | RUN apt-get update \ 4 | && apt-get install -y git zlib1g-dev \ 5 | && docker-php-ext-install zip \ 6 | && a2enmod rewrite \ 7 | && sed -i 's!/var/www/html!/var/www/public!g' /etc/apache2/apache2.conf \ 8 | && mv /var/www/html /var/www/public \ 9 | && curl -sS https://getcomposer.org/installer \ 10 | | php -- --install-dir=/usr/local/bin --filename=composer 11 | 12 | WORKDIR /var/www 13 | -------------------------------------------------------------------------------- /formdemo/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005-2015, Zend Technologies USA, Inc. 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | - Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | - Neither the name of Zend Technologies USA, Inc. nor the names of its 16 | contributors may be used to endorse or promote products derived from this 17 | software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 23 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /formdemo/README.md: -------------------------------------------------------------------------------- 1 | Form Demo Sample 2 | ================================================== 3 | 4 | This sample is based on the *Hello World* sample. It shows how to: 5 | 6 | * Create a form model 7 | * Use the form model in a controller 8 | * Render the form with special form view helpers 9 | * Use form security elements (CAPTCHA, CSRF) 10 | * Upload files with forms 11 | 12 | ## Installation 13 | 14 | You need to have Apache 2.4 HTTP server, PHP v.5.6 or later plus `gd` and `mbstring` PHP extensions. 15 | 16 | Download the sample to some directory (it can be your home dir or `/var/www/html`) and run Composer as follows: 17 | 18 | ``` 19 | php composer.phar install 20 | ``` 21 | 22 | The command above will install the dependencies (Zend Framework). 23 | 24 | Adjust permissions for `public/img/captcha` directory: 25 | 26 | ``` 27 | sudo chown -R www-data:www-data public/img/captcha 28 | sudo chown -R 775 public/img/captcha 29 | ``` 30 | 31 | Then create an Apache virtual host. It should look like below: 32 | 33 | ``` 34 | 35 | DocumentRoot /path/to/formdemo/public 36 | 37 | 38 | DirectoryIndex index.php 39 | AllowOverride All 40 | Require all granted 41 | 42 | 43 | 44 | ``` 45 | 46 | Now you should be able to see the Form Demo website by visiting the link "http://localhost/". 47 | 48 | ## License 49 | 50 | This code is provided under the [BSD-like license](https://en.wikipedia.org/wiki/BSD_licenses). 51 | 52 | ## Contributing 53 | 54 | If you found a mistake or a bug, please report it using the [Issues](https://github.com/olegkrivtsov/using-zf3-book-samples/issues) page. Your feedback is highly appreciated. 55 | -------------------------------------------------------------------------------- /formdemo/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zendframework/skeleton-application", 3 | "description": "Skeleton Application for Zend Framework zend-mvc applications", 4 | "type": "project", 5 | "license": "BSD-3-Clause", 6 | "keywords": [ 7 | "framework", 8 | "mvc", 9 | "zf2" 10 | ], 11 | "homepage": "http://framework.zend.com/", 12 | "minimum-stability": "dev", 13 | "prefer-stable": true, 14 | "require": { 15 | "php": "^5.6 || ^7.0", 16 | "ext-gd": "*", 17 | "ext-mbstring": "*", 18 | "zendframework/zend-component-installer": "^1.0 || ^0.3 || ^1.0.0-dev@dev", 19 | "zendframework/zend-mvc": "^3.0.1", 20 | "zfcampus/zf-development-mode": "^3.0", 21 | "zendframework/zend-mvc-form": "^1.0", 22 | "zendframework/zend-mvc-plugins": "^1.0.1", 23 | "zendframework/zend-session": "^2.7.1", 24 | "zendframework/zend-captcha": "^2.6", 25 | "zendframework/zend-mail": "^2.7" 26 | }, 27 | "autoload": { 28 | "psr-4": { 29 | "Application\\": "module/Application/src/" 30 | } 31 | }, 32 | "autoload-dev": { 33 | "psr-4": { 34 | "ApplicationTest\\": "module/Application/test/" 35 | } 36 | }, 37 | "extra": [], 38 | "scripts": { 39 | "development-disable": "zf-development-mode disable", 40 | "development-enable": "zf-development-mode enable", 41 | "development-status": "zf-development-mode status", 42 | "serve": "php -S 0.0.0.0:8080 -t public/ public/index.php" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /formdemo/composer.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/formdemo/composer.phar -------------------------------------------------------------------------------- /formdemo/config/autoload/.gitignore: -------------------------------------------------------------------------------- 1 | local.php 2 | *.local.php 3 | -------------------------------------------------------------------------------- /formdemo/config/autoload/README.md: -------------------------------------------------------------------------------- 1 | About this directory: 2 | ===================== 3 | 4 | By default, this application is configured to load all configs in 5 | `./config/autoload/{,*.}{global,local}.php`. Doing this provides a 6 | location for a developer to drop in configuration override files provided by 7 | modules, as well as cleanly provide individual, application-wide config files 8 | for things like database connections, etc. 9 | -------------------------------------------------------------------------------- /formdemo/config/autoload/development.local.php.dist: -------------------------------------------------------------------------------- 1 | 9 | * $ composer development-enable 10 | * 11 | * 12 | * from the project root to copy this file to development.local.php and enable 13 | * the settings it contains. 14 | * 15 | * You may also create files matching the glob pattern `{,*.}{global,local}-development.php`. 16 | */ 17 | 18 | return [ 19 | 'view_manager' => [ 20 | 'display_exceptions' => true, 21 | ], 22 | ]; 23 | -------------------------------------------------------------------------------- /formdemo/config/autoload/global.php: -------------------------------------------------------------------------------- 1 | [ 20 | 'cookie_lifetime' => 60*60*1, // Session cookie will expire in 1 hour. 21 | 'gc_maxlifetime' => 60*60*1, // Store session data on server maximum for 1 hour. 22 | ], 23 | // Session manager configuration. 24 | 'session_manager' => [ 25 | // Session validators (used for security). 26 | 'validators' => [ 27 | RemoteAddr::class, 28 | HttpUserAgent::class, 29 | ] 30 | ], 31 | // Session storage configuration. 32 | 'session_storage' => [ 33 | 'type' => SessionArrayStorage::class 34 | ], 35 | ]; 36 | 37 | -------------------------------------------------------------------------------- /formdemo/config/autoload/local.php.dist: -------------------------------------------------------------------------------- 1 | [ 11 | ], 12 | // Configuration overrides during development mode 13 | 'module_listener_options' => [ 14 | 'config_glob_paths' => [realpath(__DIR__) . '/autoload/{,*.}{global,local}-development.php'], 15 | 'config_cache_enabled' => false, 16 | 'module_map_cache_enabled' => false, 17 | ], 18 | ]; 19 | -------------------------------------------------------------------------------- /formdemo/config/modules.config.php: -------------------------------------------------------------------------------- 1 | get(ImageManager::class); 18 | 19 | // Instantiate the controller and inject dependencies 20 | return new ImageController($imageManager); 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /formdemo/module/Application/src/Controller/Factory/IndexControllerFactory.php: -------------------------------------------------------------------------------- 1 | get(MailSender::class); 18 | 19 | // Instantiate the controller and inject dependencies 20 | return new IndexController($mailSender); 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /formdemo/module/Application/src/Controller/Factory/RegistrationControllerFactory.php: -------------------------------------------------------------------------------- 1 | get('UserRegistration'); 17 | 18 | // Instantiate the controller and inject dependencies 19 | return new RegistrationController($sessionContainer); 20 | } 21 | } 22 | 23 | 24 | -------------------------------------------------------------------------------- /formdemo/module/Application/src/Module.php: -------------------------------------------------------------------------------- 1 | setBody($text); 23 | $mail->setFrom($sender); 24 | $mail->addTo($recipient); 25 | $mail->setSubject($subject); 26 | 27 | // Send E-mail message 28 | $transport = new Sendmail('-f'.$sender); 29 | $transport->send($mail); 30 | $result = true; 31 | } catch(\Exception $e) { 32 | $result = false; 33 | } 34 | 35 | return $result; 36 | } 37 | }; 38 | 39 | 40 | -------------------------------------------------------------------------------- /formdemo/module/Application/view/application/image/index.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Image Gallery'); 3 | 4 | $this->mainMenu()->setActiveItemId('home'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home'), 8 | 'Image Gallery' => $this->url('images') 9 | ]); 10 | ?> 11 | 12 |

Image Gallery

13 | 14 |

15 | This page displays the list of uploaded images. 16 |

17 | 18 |

19 | Upload More 21 |

22 | 23 |
24 | 25 | 26 | 27 |

28 | There are no files to display. 29 |

30 | 31 | 32 | 33 |
34 |
35 | 36 | 37 | 38 |
39 | 40 | 42 | 43 |
44 |

45 |

46 | Show in Natural Size 49 |

50 |
51 |
52 | 53 | 54 |
55 |
56 | 57 |
58 | 59 | 60 | -------------------------------------------------------------------------------- /formdemo/module/Application/view/application/image/upload.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Upload a New Image'); 3 | 4 | $this->mainMenu()->setActiveItemId('home'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home'), 8 | 'Image Gallery' => $this->url('images') 9 | ]); 10 | 11 | $form = $this->form; 12 | $form->get('submit')->setAttributes(['class'=>'btn btn-primary']); 13 | $form->prepare(); 14 | ?> 15 | 16 |

Upload a New Image

17 | 18 |

19 | Please fill out the following form and press the Upload button. 20 |

21 | 22 |
23 |
24 | form()->openTag($form); ?> 25 | 26 |
27 | formLabel($form->get('file')); ?> 28 | formElement($form->get('file')); ?> 29 | formElementErrors($form->get('file')); ?> 30 |
(PNG and JPG formats are allowed)
31 |
32 | 33 | formElement($form->get('submit')); ?> 34 | 35 | form()->closeTag(); ?> 36 |
37 |
-------------------------------------------------------------------------------- /formdemo/module/Application/view/application/index/about.phtml: -------------------------------------------------------------------------------- 1 | headTitle('About'); 3 | 4 | $this->mainMenu()->setActiveItemId('about'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home'), 8 | 'About'=>$this->url('about'), 9 | ]); 10 | ?> 11 | 12 |

About

13 | 14 |

15 | Application name: escapeHtml($appName) ?> 16 |

17 | 18 |

19 | Application description: escapeHtml($appDescription) ?> 20 |

21 | -------------------------------------------------------------------------------- /formdemo/module/Application/view/application/index/index.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Welcome'); 3 | 4 | $this->mainMenu()->setActiveItemId('home'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home') 8 | ]); 9 | ?> 10 | 11 |

Welcome

12 | 13 |

14 | This is the Form Demo application. 15 |

16 | 17 | 39 | 40 | -------------------------------------------------------------------------------- /formdemo/module/Application/view/application/index/send-error.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Contact Us'); 4 | 5 | $this->mainMenu()->setActiveItemId('contactUs'); 6 | 7 | $this->pageBreadcrumbs()->setItems(array( 8 | 'Home'=>$this->url('home'), 9 | 'Contact Us'=>$this->url('contactus') 10 | )); 11 | 12 | ?> 13 | 14 |

Error Sending Email!

15 | 16 |

17 |

18 | Sorry, but we had an unexpected problem when trying to deliver your message. 19 | Please try again later. 20 |
21 |

-------------------------------------------------------------------------------- /formdemo/module/Application/view/application/index/thank-you.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Contact Us'); 4 | 5 | $this->mainMenu()->setActiveItemId('contactUs'); 6 | 7 | $this->pageBreadcrumbs()->setItems(array( 8 | 'Home'=>$this->url('home'), 9 | 'Contact Us'=>$this->url('contactus') 10 | )); 11 | 12 | ?> 13 | 14 |

Thank You!

15 | 16 |

17 |

18 | We will respond to the E-mail address you have provided. 19 |
20 |

21 | -------------------------------------------------------------------------------- /formdemo/module/Application/view/application/registration/review.phtml: -------------------------------------------------------------------------------- 1 | headTitle('User Registration - Review'); 3 | 4 | $this->mainMenu()->setActiveItemId('home'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home'), 8 | 'User Registration' => $this->url('registration') 9 | ]); 10 | ?> 11 | 12 |

User Registration - Review

13 | 14 |

Thank you! Now please review the data you entered in previous three steps.

15 | 16 |
17 | 
18 | 
-------------------------------------------------------------------------------- /formdemo/module/Application/view/application/registration/step3.phtml: -------------------------------------------------------------------------------- 1 | headTitle('User Registration - Step 3'); 3 | 4 | $this->mainMenu()->setActiveItemId('home'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home'), 8 | 'User Registration' => $this->url('registration') 9 | ]); 10 | 11 | $form->get('billing_plan')->setAttributes([ 12 | 'class'=>'form-control', 13 | ]); 14 | 15 | $form->get('payment_method')->setAttributes([ 16 | 'class'=>'form-control', 17 | ]); 18 | 19 | $form->get('submit')->setAttributes(array('class'=>'btn btn-primary')); 20 | 21 | $form->prepare(); 22 | ?> 23 | 24 |

User Registration - Step 3 - Billing Information

25 | 26 |
27 |
28 | form()->openTag($form); ?> 29 | 30 |
31 | formLabel($form->get('billing_plan')); ?> 32 | formElement($form->get('billing_plan')); ?> 33 | formElementErrors($form->get('billing_plan')); ?> 34 |
35 | 36 |
37 | formLabel($form->get('payment_method')); ?> 38 | formElement($form->get('payment_method')); ?> 39 | formElementErrors($form->get('payment_method')); ?> 40 |
41 | 42 |
43 | formElement($form->get('submit')); ?> 44 |
45 | 46 | formElement($form->get('csrf')); ?> 47 | 48 | form()->closeTag(); ?> 49 |
50 |
51 | 52 | -------------------------------------------------------------------------------- /formdemo/phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ./module/Application/test 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /formdemo/public/.htaccess: -------------------------------------------------------------------------------- 1 | RewriteEngine On 2 | # The following rule tells Apache that if the requested filename 3 | # exists, simply serve it. 4 | RewriteCond %{REQUEST_FILENAME} -s [OR] 5 | RewriteCond %{REQUEST_FILENAME} -l [OR] 6 | RewriteCond %{REQUEST_FILENAME} -d 7 | RewriteRule ^.*$ - [L] 8 | # The following rewrites all other queries to index.php. The 9 | # condition ensures that if you are using Apache aliases to do 10 | # mass virtual hosting or installed the project in a subdirectory, 11 | # the base path will be prepended to allow proper resolution of 12 | # the index.php file; it will work in non-aliased environments 13 | # as well, providing a safe, one-size fits all solution. 14 | RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ 15 | RewriteRule ^(.*) - [E=BASE:%1] 16 | RewriteRule ^(.*)$ %{ENV:BASE}/index.php [L] 17 | -------------------------------------------------------------------------------- /formdemo/public/css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-bottom: 40px; 3 | } 4 | 5 | .zf-green { 6 | color: #68b604; 7 | } 8 | 9 | .btn-success { 10 | background-color: #57a900; 11 | background-image: -moz-linear-gradient(top, #70d900, #57a900); 12 | background-image: -ms-linear-gradient(top, #70d900, #57a900); 13 | background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#70d900), to(#57a900)); 14 | background-image: -webkit-linear-gradient(top, #70d900, #57a900); 15 | background-image: -o-linear-gradient(top, #70d900, #57a900); 16 | background-image: linear-gradient(top, #70d900, #57a900); 17 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#70d900', endColorstr='#57a900', GradientType=0); 18 | } 19 | 20 | .btn-success:hover, 21 | .btn-success:active, 22 | .btn-success.active, 23 | .btn-success.disabled, 24 | .btn-success[disabled] { 25 | background-color: #57a900; 26 | } 27 | 28 | .btn-success:active, .btn-success.active { 29 | background-color: #57a900; 30 | } 31 | 32 | div.container a.navbar-brand > img { 33 | display: inline; 34 | margin-right: 4px; 35 | } 36 | 37 | div.app-caption { 38 | padding: 25px 0px; 39 | font-size:3.0em; 40 | font-weight: bold; 41 | color:#6aacaf 42 | } 43 | 44 | form ul { 45 | list-style-type: none; 46 | padding: 0px; 47 | margin: 0px 5px; 48 | } 49 | 50 | form ul li { 51 | color: red; 52 | } -------------------------------------------------------------------------------- /formdemo/public/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/formdemo/public/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /formdemo/public/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/formdemo/public/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /formdemo/public/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/formdemo/public/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /formdemo/public/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/formdemo/public/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /formdemo/public/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/formdemo/public/img/favicon.ico -------------------------------------------------------------------------------- /formdemo/public/img/zf-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/formdemo/public/img/zf-logo.png -------------------------------------------------------------------------------- /formdemo/public/index.php: -------------------------------------------------------------------------------- 1 | run(); 41 | -------------------------------------------------------------------------------- /helloworld/.gitignore: -------------------------------------------------------------------------------- 1 | nbproject 2 | ._* 3 | .vagrant 4 | .~lock.* 5 | .buildpath 6 | .DS_Store 7 | .idea 8 | .project 9 | .settings 10 | vendor/ 11 | config/development.config.php 12 | phpunit.xml 13 | -------------------------------------------------------------------------------- /helloworld/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.0-apache 2 | 3 | RUN apt-get update \ 4 | && apt-get install -y git zlib1g-dev \ 5 | && docker-php-ext-install zip \ 6 | && a2enmod rewrite \ 7 | && sed -i 's!/var/www/html!/var/www/public!g' /etc/apache2/apache2.conf \ 8 | && mv /var/www/html /var/www/public \ 9 | && curl -sS https://getcomposer.org/installer \ 10 | | php -- --install-dir=/usr/local/bin --filename=composer 11 | 12 | WORKDIR /var/www 13 | -------------------------------------------------------------------------------- /helloworld/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005-2015, Zend Technologies USA, Inc. 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | - Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | - Neither the name of Zend Technologies USA, Inc. nor the names of its 16 | contributors may be used to endorse or promote products derived from this 17 | software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 23 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /helloworld/README.md: -------------------------------------------------------------------------------- 1 | Hello World Sample 2 | ================================================== 3 | 4 | This sample is based on *Zend Skeleton Application*. It shows how to: 5 | 6 | * Register controllers 7 | * Create controller actions 8 | * Use layouts and switch between them 9 | * Generate URLs with the `Url` controller plugin and the `Url` view helper 10 | * Create a custom route type 11 | * Create own view helpers 12 | 13 | ## Installation 14 | 15 | You need to have Apache 2.4 HTTP server, PHP v.5.6 or later plus `gd` and `intl` PHP extensions. 16 | 17 | Download the sample to some directory (it can be your home dir or `/var/www/html`) and run Composer as follows: 18 | 19 | ``` 20 | php composer.phar install 21 | ``` 22 | 23 | The command above will install the dependencies (Zend Framework). 24 | 25 | Then create an Apache virtual host. It should look like below: 26 | 27 | ``` 28 | 29 | DocumentRoot /path/to/helloworld/public 30 | 31 | 32 | DirectoryIndex index.php 33 | AllowOverride All 34 | Require all granted 35 | 36 | 37 | 38 | ``` 39 | 40 | Now you should be able to see the Hello World website by visiting the link "http://localhost/". 41 | 42 | ## License 43 | 44 | This code is provided under the [BSD-like license](https://en.wikipedia.org/wiki/BSD_licenses). 45 | 46 | ## Contributing 47 | 48 | If you found a mistake or a bug, please report it using the [Issues](https://github.com/olegkrivtsov/using-zf3-book-samples/issues) page. Your feedback is highly appreciated. 49 | -------------------------------------------------------------------------------- /helloworld/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zendframework/skeleton-application", 3 | "description": "Skeleton Application for Zend Framework zend-mvc applications", 4 | "type": "project", 5 | "license": "BSD-3-Clause", 6 | "keywords": [ 7 | "framework", 8 | "mvc", 9 | "zf2" 10 | ], 11 | "homepage": "http://framework.zend.com/", 12 | "minimum-stability": "dev", 13 | "prefer-stable": true, 14 | "require": { 15 | "php": "^5.6 || ^7.0", 16 | "ext-gd": "*", 17 | "ext-intl": "*", 18 | "zendframework/zend-component-installer": "^1.0 || ^0.3 || ^1.0.0-dev@dev", 19 | "zendframework/zend-mvc": "^3.0.1", 20 | "zfcampus/zf-development-mode": "^3.0", 21 | "zendframework/zend-mvc-form": "^1.0", 22 | "zendframework/zend-mvc-plugins": "^1.0.1", 23 | "zendframework/zend-session": "^2.7.1", 24 | "zendframework/zend-barcode": "^2.6" 25 | }, 26 | "autoload": { 27 | "psr-4": { 28 | "Application\\": "module/Application/src/" 29 | } 30 | }, 31 | "autoload-dev": { 32 | "psr-4": { 33 | "ApplicationTest\\": "module/Application/test/" 34 | } 35 | }, 36 | "extra": [], 37 | "scripts": { 38 | "development-disable": "zf-development-mode disable", 39 | "development-enable": "zf-development-mode enable", 40 | "development-status": "zf-development-mode status", 41 | "serve": "php -S 0.0.0.0:8080 -t public/ public/index.php" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /helloworld/composer.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/helloworld/composer.phar -------------------------------------------------------------------------------- /helloworld/config/autoload/.gitignore: -------------------------------------------------------------------------------- 1 | local.php 2 | *.local.php 3 | -------------------------------------------------------------------------------- /helloworld/config/autoload/README.md: -------------------------------------------------------------------------------- 1 | About this directory: 2 | ===================== 3 | 4 | By default, this application is configured to load all configs in 5 | `./config/autoload/{,*.}{global,local}.php`. Doing this provides a 6 | location for a developer to drop in configuration override files provided by 7 | modules, as well as cleanly provide individual, application-wide config files 8 | for things like database connections, etc. 9 | -------------------------------------------------------------------------------- /helloworld/config/autoload/development.local.php.dist: -------------------------------------------------------------------------------- 1 | 9 | * $ composer development-enable 10 | * 11 | * 12 | * from the project root to copy this file to development.local.php and enable 13 | * the settings it contains. 14 | * 15 | * You may also create files matching the glob pattern `{,*.}{global,local}-development.php`. 16 | */ 17 | 18 | return [ 19 | 'view_manager' => [ 20 | 'display_exceptions' => true, 21 | ], 22 | ]; 23 | -------------------------------------------------------------------------------- /helloworld/config/autoload/global.php: -------------------------------------------------------------------------------- 1 | [ 11 | ], 12 | // Configuration overrides during development mode 13 | 'module_listener_options' => [ 14 | 'config_glob_paths' => [realpath(__DIR__) . '/autoload/{,*.}{global,local}-development.php'], 15 | 'config_cache_enabled' => false, 16 | 'module_map_cache_enabled' => false, 17 | ], 18 | ]; 19 | -------------------------------------------------------------------------------- /helloworld/config/modules.config.php: -------------------------------------------------------------------------------- 1 | headTitle('Downloads'); 3 | 4 | $this->mainMenu()->setActiveItemId('downloads'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home'), 8 | 'Downloads'=>$this->url('download', ['action'=>'index']) 9 | ]); 10 | ?> 11 | 12 |

Downloads

13 | 14 | -------------------------------------------------------------------------------- /helloworld/module/Application/view/application/index/about.phtml: -------------------------------------------------------------------------------- 1 | headTitle('About'); 3 | 4 | $this->mainMenu()->setActiveItemId('about'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home'), 8 | 'About'=>$this->url('about'), 9 | ]); 10 | 11 | $this->layout()->setTemplate('layout/layout2'); 12 | 13 | ?> 14 | 15 |

About

16 | 17 |

18 | Application name: escapeHtml($appName) ?> 19 |

20 | 21 |

22 | Application description: escapeHtml($appDescription) ?> 23 |

24 | -------------------------------------------------------------------------------- /helloworld/module/Application/view/application/index/doc/contents.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Documentation'); 3 | 4 | $this->mainMenu()->setActiveItemId('support'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home'), 8 | 'Documentation'=>$this->url('doc', ['page'=>'contents']), 9 | ]); 10 | ?> 11 | 12 |

Table of Contents

13 | 14 | -------------------------------------------------------------------------------- /helloworld/module/Application/view/application/index/doc/install.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Installation'); 3 | $this->mainMenu()->setActiveItemId('support'); 4 | $this->pageBreadcrumbs()->setItems([ 5 | 'Home'=>$this->url('home'), 6 | 'Documentation'=>$this->url('doc', ['page'=>'contents']), 7 | 'Installation'=>$this->url('doc', ['page'=>'chapter1/installation']), 8 | ]); 9 | ?> 10 | 11 |

Installation

12 | 13 |

Put your installation instruction here.

-------------------------------------------------------------------------------- /helloworld/module/Application/view/application/index/doc/introduction.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Introduction'); 3 | $this->mainMenu()->setActiveItemId('support'); 4 | $this->pageBreadcrumbs()->setItems([ 5 | 'Home'=>$this->url('home'), 6 | 'Documentation'=>$this->url('doc', ['page'=>'contents']), 7 | 'Introduction'=>$this->url('doc', ['page'=>'introduction']), 8 | ]); 9 | ?> 10 | 11 |

Introduction

12 | 13 |

Some introductory materials.

-------------------------------------------------------------------------------- /helloworld/module/Application/view/application/index/index.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Welcome'); 3 | 4 | $this->mainMenu()->setActiveItemId('home'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home') 8 | ]); 9 | ?> 10 | 11 |

Welcome

12 | 13 |

14 | This is the Hello World application powered by Zend Framework 3. 15 |

16 | 17 |

18 | You can optically recognize this app using the barcode image below: 19 |

20 | 21 | 23 | 24 | -------------------------------------------------------------------------------- /helloworld/module/Application/view/application/index/partial-demo.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Partial View Demo'); 3 | 4 | $this->mainMenu()->setActiveItemId('home'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home') 8 | ]); 9 | 10 | ?> 11 | 12 |

Partial View Demo

13 | 14 |

15 | Below, the table of products is presented. It is rendered with the help of 16 | partial views. 17 |

18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | products as $product) { 28 | echo $this->partial('application/index/table-row', ['product'=>$product]); 29 | } 30 | ?> 31 |
IDProductPrice
-------------------------------------------------------------------------------- /helloworld/module/Application/view/application/index/static/chapter1/intro.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Help'); 3 | 4 | $this->mainMenu()->setActiveItemId('support'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home'), 8 | 'Help'=>$this->url('static', ['page'=>'/help']), 9 | 'Introduction'=>$this->url('static', ['page'=>'/chapter1/intro']), 10 | ]); 11 | ?> 12 | 13 |

Introduction

14 | 15 |

16 | Write help introduction here. 17 |

-------------------------------------------------------------------------------- /helloworld/module/Application/view/application/index/static/datepicker.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Datepicker'); 3 | 4 | $this->mainMenu()->setActiveItemId('home'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home') 8 | ]); 9 | 10 | $this->headScript()->appendFile('/js/jquery-ui.min.js', 'text/javascript'); 11 | $this->headLink()->appendStylesheet('/css/jquery-ui.min.css'); 12 | ?> 13 | 14 |

Datepicker

15 | 16 |

17 | Click the edit box below to show the datepicker. 18 |

19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /helloworld/module/Application/view/application/index/static/help.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Help'); 3 | 4 | $this->mainMenu()->setActiveItemId('support'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home'), 8 | 'Help'=>$this->url('static', ['page'=>'/help']), 9 | ]); 10 | ?> 11 | 12 |

Help

13 | 14 |

15 | See the help introduction here. 16 |

17 | 18 | -------------------------------------------------------------------------------- /helloworld/module/Application/view/application/index/static/typeahead.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Typeahead'); 3 | 4 | $this->mainMenu()->setActiveItemId('home'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home') 8 | ]); 9 | 10 | $this->headScript()->appendFile('/js/typeahead.min.js', 'text/javascript'); 11 | ?> 12 | 13 |

Typeahead

14 | 15 |

16 | Type a continent name (e.g. Africa) in the text field below: 17 |

18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /helloworld/module/Application/view/application/index/table-row.phtml: -------------------------------------------------------------------------------- 1 | 2 | escapeHtml($this->product['id']) ?> 3 | escapeHtml($this->product['name']) ?> 4 | escapeHtml($this->product['price']) ?> 5 | -------------------------------------------------------------------------------- /helloworld/module/Application/view/layout/layout2.phtml: -------------------------------------------------------------------------------- 1 | placeholder('content')->captureStart(); ?> 2 | 3 |
4 |
5 | content; ?> 6 |
7 |
8 |
9 |
10 |

Ads

11 |
12 |
13 | Zend Framework 3 Book 14 |

Learn how to create modern web applications with PHP 15 | and Zend Framework 3

16 | 17 | Learn More 18 | 19 |
20 |
21 |
22 |
23 | 24 | placeholder('content')->captureEnd(); 26 | echo $this->partial('layout/layout', 27 | ['content'=>$this->placeholder('content')]); 28 | ?> 29 | 30 | -------------------------------------------------------------------------------- /helloworld/phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ./module/Application/test 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /helloworld/public/.htaccess: -------------------------------------------------------------------------------- 1 | RewriteEngine On 2 | # The following rule tells Apache that if the requested filename 3 | # exists, simply serve it. 4 | RewriteCond %{REQUEST_FILENAME} -s [OR] 5 | RewriteCond %{REQUEST_FILENAME} -l [OR] 6 | RewriteCond %{REQUEST_FILENAME} -d 7 | RewriteRule ^.*$ - [L] 8 | # The following rewrites all other queries to index.php. The 9 | # condition ensures that if you are using Apache aliases to do 10 | # mass virtual hosting or installed the project in a subdirectory, 11 | # the base path will be prepended to allow proper resolution of 12 | # the index.php file; it will work in non-aliased environments 13 | # as well, providing a safe, one-size fits all solution. 14 | RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ 15 | RewriteRule ^(.*) - [E=BASE:%1] 16 | RewriteRule ^(.*)$ %{ENV:BASE}/index.php [L] 17 | -------------------------------------------------------------------------------- /helloworld/public/css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-bottom: 40px; 3 | } 4 | 5 | .zf-green { 6 | color: #68b604; 7 | } 8 | 9 | .btn-success { 10 | background-color: #57a900; 11 | background-image: -moz-linear-gradient(top, #70d900, #57a900); 12 | background-image: -ms-linear-gradient(top, #70d900, #57a900); 13 | background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#70d900), to(#57a900)); 14 | background-image: -webkit-linear-gradient(top, #70d900, #57a900); 15 | background-image: -o-linear-gradient(top, #70d900, #57a900); 16 | background-image: linear-gradient(top, #70d900, #57a900); 17 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#70d900', endColorstr='#57a900', GradientType=0); 18 | } 19 | 20 | .btn-success:hover, 21 | .btn-success:active, 22 | .btn-success.active, 23 | .btn-success.disabled, 24 | .btn-success[disabled] { 25 | background-color: #57a900; 26 | } 27 | 28 | .btn-success:active, .btn-success.active { 29 | background-color: #57a900; 30 | } 31 | 32 | div.container a.navbar-brand > img { 33 | display: inline; 34 | margin-right: 4px; 35 | } 36 | 37 | div.app-caption { 38 | padding: 25px 0px; 39 | font-size:3.0em; 40 | font-weight: bold; 41 | color:#6aacaf 42 | } 43 | 44 | .typeahead, 45 | .tt-query, 46 | .tt-hint { 47 | width: 396px; 48 | height: 30px; 49 | padding: 0px 12px; 50 | font-size: 1.1em; 51 | border: 2px solid #ccc; 52 | border-radius: 4px; 53 | outline: none; 54 | } 55 | 56 | .tt-dropdown-menu { 57 | width: 422px; 58 | margin-top: 12px; 59 | padding: 8px 0; 60 | background-color: #fff; 61 | border: 1px solid #ccc; 62 | border: 1px solid rgba(0, 0, 0, 0.2); 63 | border-radius: 4px; 64 | } 65 | 66 | .tt-suggestion { 67 | padding: 3px 20px; 68 | font-size: 1.1em; 69 | line-height: 24px; 70 | } 71 | 72 | .tt-suggestion.tt-is-under-cursor { 73 | color: #fff; 74 | background-color: #0097cf; 75 | 76 | } 77 | 78 | .tt-suggestion p { 79 | margin: 0; 80 | } -------------------------------------------------------------------------------- /helloworld/public/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/helloworld/public/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /helloworld/public/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/helloworld/public/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /helloworld/public/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/helloworld/public/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /helloworld/public/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/helloworld/public/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /helloworld/public/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/helloworld/public/img/favicon.ico -------------------------------------------------------------------------------- /helloworld/public/img/zf-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/helloworld/public/img/zf-logo.png -------------------------------------------------------------------------------- /helloworld/public/index.php: -------------------------------------------------------------------------------- 1 | run(); 41 | -------------------------------------------------------------------------------- /i18ndemo/.gitignore: -------------------------------------------------------------------------------- 1 | nbproject 2 | ._* 3 | .vagrant 4 | .~lock.* 5 | .buildpath 6 | .DS_Store 7 | .idea 8 | .project 9 | .settings 10 | vendor/ 11 | config/development.config.php 12 | phpunit.xml 13 | data/upload 14 | public/img/captcha/* 15 | -------------------------------------------------------------------------------- /i18ndemo/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.0-apache 2 | 3 | RUN apt-get update \ 4 | && apt-get install -y git zlib1g-dev \ 5 | && docker-php-ext-install zip \ 6 | && a2enmod rewrite \ 7 | && sed -i 's!/var/www/html!/var/www/public!g' /etc/apache2/apache2.conf \ 8 | && mv /var/www/html /var/www/public \ 9 | && curl -sS https://getcomposer.org/installer \ 10 | | php -- --install-dir=/usr/local/bin --filename=composer 11 | 12 | WORKDIR /var/www 13 | -------------------------------------------------------------------------------- /i18ndemo/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005-2015, Zend Technologies USA, Inc. 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | - Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | - Neither the name of Zend Technologies USA, Inc. nor the names of its 16 | contributors may be used to endorse or promote products derived from this 17 | software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 23 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /i18ndemo/README.md: -------------------------------------------------------------------------------- 1 | i18n Demo Sample 2 | ================================================== 3 | 4 | This sample is based on the *Form Demo* sample. It shows how to: 5 | 6 | * Localize your view templates 7 | * Localize view helpers 8 | * Localize forms 9 | * Localize validator messages 10 | * Select a language in the user interface 11 | 12 | ## Installation 13 | 14 | You need to have Apache 2.4 HTTP server, PHP v.5.6 or later plus `intl`, `gd` and `mbstring` PHP extensions. 15 | 16 | Download the sample to some directory (it can be your home dir or `/var/www/html`) and run Composer as follows: 17 | 18 | ``` 19 | php composer.phar install 20 | ``` 21 | 22 | The command above will install the dependencies (Zend Framework). 23 | 24 | Adjust permissions for `public/img/captcha` directory (use `www-data` user/group on Ubuntu, `httpd` on CentOS): 25 | 26 | ``` 27 | sudo chown -R www-data:www-data public/img/captcha 28 | sudo chown -R 775 public/img/captcha 29 | ``` 30 | 31 | Switch to development mode by typing: 32 | 33 | ``` 34 | php composer.phar development-enable 35 | ``` 36 | 37 | Then create an Apache virtual host. It should look like below: 38 | 39 | ``` 40 | 41 | DocumentRoot /path/to/i18ndemo/public 42 | 43 | 44 | DirectoryIndex index.php 45 | AllowOverride All 46 | Require all granted 47 | 48 | 49 | 50 | ``` 51 | 52 | Now you should be able to see the i18n Demo website by visiting the link "http://localhost/". 53 | 54 | ## License 55 | 56 | This code is provided under the [BSD-like license](https://en.wikipedia.org/wiki/BSD_licenses). 57 | 58 | ## Contributing 59 | 60 | If you found a mistake or a bug, please report it using the [Issues](https://github.com/olegkrivtsov/using-zf3-book-samples/issues) page. Your feedback is highly appreciated. 61 | -------------------------------------------------------------------------------- /i18ndemo/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zf3-book-samples/i18ndemo", 3 | "description": "Internationalization & localization demo for the Using Zend Framework 3 book", 4 | "type": "project", 5 | "license": "BSD-3-Clause", 6 | "keywords": [ 7 | "zf3", 8 | "i18n" 9 | ], 10 | "homepage": "https://github.com/olegkrivtsov/using-zf3-book-samples", 11 | "minimum-stability": "dev", 12 | "prefer-stable": true, 13 | "require": { 14 | "php": "^5.6 || ^7.0", 15 | "ext-gd": "*", 16 | "ext-mbstring": "*", 17 | "ext-intl": "*", 18 | "zendframework/zend-component-installer": "^1.1", 19 | "zendframework/zend-mvc": "^3.1", 20 | "zfcampus/zf-development-mode": "^3.2", 21 | "zendframework/zend-mvc-form": "^1.0", 22 | "zendframework/zend-mvc-plugins": "^1.0.1", 23 | "zendframework/zend-session": "^2.8", 24 | "zendframework/zend-captcha": "^2.6", 25 | "zendframework/zend-mail": "^2.7", 26 | "zendframework/zend-mvc-i18n": "^1.1" 27 | }, 28 | "autoload": { 29 | "psr-4": { 30 | "Application\\": "module/Application/src/" 31 | } 32 | }, 33 | "autoload-dev": { 34 | "psr-4": { 35 | "ApplicationTest\\": "module/Application/test/" 36 | } 37 | }, 38 | "extra": [], 39 | "scripts": { 40 | "development-disable": "zf-development-mode disable", 41 | "development-enable": "zf-development-mode enable", 42 | "development-status": "zf-development-mode status", 43 | "serve": "php -S 0.0.0.0:8080 -t public/ public/index.php" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /i18ndemo/composer.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/i18ndemo/composer.phar -------------------------------------------------------------------------------- /i18ndemo/config/autoload/.gitignore: -------------------------------------------------------------------------------- 1 | local.php 2 | *.local.php 3 | -------------------------------------------------------------------------------- /i18ndemo/config/autoload/README.md: -------------------------------------------------------------------------------- 1 | About this directory: 2 | ===================== 3 | 4 | By default, this application is configured to load all configs in 5 | `./config/autoload/{,*.}{global,local}.php`. Doing this provides a 6 | location for a developer to drop in configuration override files provided by 7 | modules, as well as cleanly provide individual, application-wide config files 8 | for things like database connections, etc. 9 | -------------------------------------------------------------------------------- /i18ndemo/config/autoload/development.local.php.dist: -------------------------------------------------------------------------------- 1 | 9 | * $ composer development-enable 10 | * 11 | * 12 | * from the project root to copy this file to development.local.php and enable 13 | * the settings it contains. 14 | * 15 | * You may also create files matching the glob pattern `{,*.}{global,local}-development.php`. 16 | */ 17 | 18 | return [ 19 | 'view_manager' => [ 20 | 'display_exceptions' => true, 21 | ], 22 | ]; 23 | -------------------------------------------------------------------------------- /i18ndemo/config/autoload/global.php: -------------------------------------------------------------------------------- 1 | [ 20 | 'cookie_lifetime' => 60*60*1, // Session cookie will expire in 1 hour. 21 | 'gc_maxlifetime' => 60*60*1, // Store session data on server maximum for 1 hour. 22 | ], 23 | // Session manager configuration. 24 | 'session_manager' => [ 25 | // Session validators (used for security). 26 | 'validators' => [ 27 | RemoteAddr::class, 28 | HttpUserAgent::class, 29 | ] 30 | ], 31 | // Session storage configuration. 32 | 'session_storage' => [ 33 | 'type' => SessionArrayStorage::class 34 | ], 35 | ]; 36 | 37 | -------------------------------------------------------------------------------- /i18ndemo/config/autoload/local.php.dist: -------------------------------------------------------------------------------- 1 | [ 11 | ], 12 | // Configuration overrides during development mode 13 | 'module_listener_options' => [ 14 | 'config_glob_paths' => [realpath(__DIR__) . '/autoload/{,*.}{global,local}-development.php'], 15 | 'config_cache_enabled' => false, 16 | 'module_map_cache_enabled' => false, 17 | ], 18 | ]; 19 | -------------------------------------------------------------------------------- /i18ndemo/config/modules.config.php: -------------------------------------------------------------------------------- 1 | get(MailSender::class); 18 | $i18nSessionContainer = $container->get('I18nSessionContainer'); 19 | 20 | // Instantiate the controller and inject dependencies 21 | return new IndexController($mailSender, $i18nSessionContainer); 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /i18ndemo/module/Application/src/Service/MailSender.php: -------------------------------------------------------------------------------- 1 | setBody($text); 23 | $mail->setFrom($sender); 24 | $mail->addTo($recipient); 25 | $mail->setSubject($subject); 26 | 27 | // Send E-mail message 28 | $transport = new Sendmail('-f'.$sender); 29 | $transport->send($mail); 30 | $result = true; 31 | } catch(\Exception $e) { 32 | $result = false; 33 | } 34 | 35 | return $result; 36 | } 37 | }; 38 | 39 | 40 | -------------------------------------------------------------------------------- /i18ndemo/module/Application/view/application/index/about.phtml: -------------------------------------------------------------------------------- 1 | headTitle('About'); 3 | 4 | $this->mainMenu()->setActiveItemId('about'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home'), 8 | 'About'=>$this->url('about'), 9 | ]); 10 | ?> 11 | 12 |

translate('About') ?>

13 | 14 |

15 | translate('Application name:')?> escapeHtml($this->translate($appName)) ?> 16 |

17 | 18 |

19 | translate('Application description:') ?> escapeHtml($this->translate($appDescription)) ?> 20 |

21 | -------------------------------------------------------------------------------- /i18ndemo/module/Application/view/application/index/index.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Welcome'); 3 | 4 | $this->mainMenu()->setActiveItemId('home'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home') 8 | ]); 9 | ?> 10 | 11 |

translate('Welcome') ?>

12 | 13 |

14 | translate('This is the Internationalization & Localization Demo application.') ?> 15 |

16 | 17 |

18 | translate('Current language is') ?> escapeHtml($this->languageId) ?>. 19 | translate('Select a language using the Language item in the top navigation menu.') ?> 20 |

21 | 22 | 28 | 29 | -------------------------------------------------------------------------------- /i18ndemo/module/Application/view/application/index/send-error.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Contact Us'); 4 | 5 | $this->mainMenu()->setActiveItemId('contactUs'); 6 | 7 | $this->pageBreadcrumbs()->setItems(array( 8 | 'Home'=>$this->url('home'), 9 | 'Contact Us'=>$this->url('contactus') 10 | )); 11 | 12 | ?> 13 | 14 |

translate('Error Sending Email!') ?>

15 | 16 |

17 |

18 | translate('Sorry, but we had an unexpected problem when trying to deliver your message. Please try again later.') ?> 19 |
20 |

-------------------------------------------------------------------------------- /i18ndemo/module/Application/view/application/index/thank-you.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Contact Us'); 4 | 5 | $this->mainMenu()->setActiveItemId('contactUs'); 6 | 7 | $this->pageBreadcrumbs()->setItems(array( 8 | 'Home'=>$this->url('home'), 9 | 'Contact Us'=>$this->url('contactus') 10 | )); 11 | 12 | ?> 13 | 14 |

translate('Thank You!') ?>

15 | 16 |

17 |

18 | translate('We will respond to the E-mail address you have provided.') ?> 19 |
20 |

21 | -------------------------------------------------------------------------------- /i18ndemo/phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ./module/Application/test 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /i18ndemo/public/.htaccess: -------------------------------------------------------------------------------- 1 | RewriteEngine On 2 | # The following rule tells Apache that if the requested filename 3 | # exists, simply serve it. 4 | RewriteCond %{REQUEST_FILENAME} -s [OR] 5 | RewriteCond %{REQUEST_FILENAME} -l [OR] 6 | RewriteCond %{REQUEST_FILENAME} -d 7 | RewriteRule ^.*$ - [L] 8 | # The following rewrites all other queries to index.php. The 9 | # condition ensures that if you are using Apache aliases to do 10 | # mass virtual hosting or installed the project in a subdirectory, 11 | # the base path will be prepended to allow proper resolution of 12 | # the index.php file; it will work in non-aliased environments 13 | # as well, providing a safe, one-size fits all solution. 14 | RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ 15 | RewriteRule ^(.*) - [E=BASE:%1] 16 | RewriteRule ^(.*)$ %{ENV:BASE}/index.php [L] 17 | -------------------------------------------------------------------------------- /i18ndemo/public/css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-bottom: 40px; 3 | } 4 | 5 | .zf-green { 6 | color: #68b604; 7 | } 8 | 9 | .btn-success { 10 | background-color: #57a900; 11 | background-image: -moz-linear-gradient(top, #70d900, #57a900); 12 | background-image: -ms-linear-gradient(top, #70d900, #57a900); 13 | background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#70d900), to(#57a900)); 14 | background-image: -webkit-linear-gradient(top, #70d900, #57a900); 15 | background-image: -o-linear-gradient(top, #70d900, #57a900); 16 | background-image: linear-gradient(top, #70d900, #57a900); 17 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#70d900', endColorstr='#57a900', GradientType=0); 18 | } 19 | 20 | .btn-success:hover, 21 | .btn-success:active, 22 | .btn-success.active, 23 | .btn-success.disabled, 24 | .btn-success[disabled] { 25 | background-color: #57a900; 26 | } 27 | 28 | .btn-success:active, .btn-success.active { 29 | background-color: #57a900; 30 | } 31 | 32 | div.container a.navbar-brand > img { 33 | display: inline; 34 | margin-right: 4px; 35 | } 36 | 37 | div.app-caption { 38 | padding: 25px 0px; 39 | font-size:3.0em; 40 | font-weight: bold; 41 | color:#6aacaf 42 | } 43 | 44 | form ul { 45 | list-style-type: none; 46 | padding: 0px; 47 | margin: 0px 5px; 48 | } 49 | 50 | form ul li { 51 | color: red; 52 | } -------------------------------------------------------------------------------- /i18ndemo/public/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/i18ndemo/public/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /i18ndemo/public/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/i18ndemo/public/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /i18ndemo/public/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/i18ndemo/public/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /i18ndemo/public/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/i18ndemo/public/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /i18ndemo/public/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/i18ndemo/public/img/favicon.ico -------------------------------------------------------------------------------- /i18ndemo/public/img/zf-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/i18ndemo/public/img/zf-logo.png -------------------------------------------------------------------------------- /i18ndemo/public/index.php: -------------------------------------------------------------------------------- 1 | run(); 41 | -------------------------------------------------------------------------------- /purephp/README.md: -------------------------------------------------------------------------------- 1 | Pure PHP Sample 2 | ================================================== 3 | 4 | This sample demonstrates how to write a simple website *without* a framework. It shows how to: 5 | 6 | * Create the Home page 7 | * Create the Login page 8 | * Create the Logout page 9 | 10 | ## Installation 11 | 12 | You need to have Apache 2.4 HTTP server and PHP v.5.6 or later. 13 | 14 | Download the sample to your Apache document root directory (for example, `/var/www/html`). 15 | 16 | Now you should be able to see the sample website by visiting the link "http://localhost/index.php". 17 | 18 | ## License 19 | 20 | This code is provided under the [BSD-like license](https://en.wikipedia.org/wiki/BSD_licenses). 21 | 22 | ## Contributing 23 | 24 | If you found a mistake or a bug, please report it using the [Issues](https://github.com/olegkrivtsov/using-zf3-book-samples/issues) page. 25 | Your feedback is highly appreciated. 26 | -------------------------------------------------------------------------------- /purephp/index.php: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | 14 | 15 | Home page 16 | 17 | 18 |

Home

19 | 20 | Sign in 21 | 22 | Welcome, Sign out 23 | 24 | 25 |

26 | This is a simple website to demonstrate the advantages of a PHP framework 27 | and disadvantages of "pure" PHP. 28 |

29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /purephp/login.php: -------------------------------------------------------------------------------- 1 | 35 | 36 | 37 | 38 | 39 | Login page 40 | 41 | 42 |

Sign in

43 | 44 |
45 | Invalid credentials. 46 |
47 | 48 |
49 | 50 | 51 |
52 | 53 | 54 |
55 | 56 |
57 | 58 | -------------------------------------------------------------------------------- /purephp/logout.php: -------------------------------------------------------------------------------- 1 | 9 | * $ composer development-enable 10 | * 11 | * 12 | * from the project root to copy this file to development.local.php and enable 13 | * the settings it contains. 14 | * 15 | * You may also create files matching the glob pattern `{,*.}{global,local}-development.php`. 16 | */ 17 | 18 | return [ 19 | 'view_manager' => [ 20 | 'display_exceptions' => true, 21 | ], 22 | ]; 23 | -------------------------------------------------------------------------------- /roledemo/config/autoload/local.php.dist: -------------------------------------------------------------------------------- 1 | [ 19 | 'name' => 'localhost.localdomain', 20 | 'host' => '127.0.0.1', 21 | 'port' => 25, 22 | 'connection_class' => 'plain', 23 | 'connection_config' => [ 24 | 'username' => '', 25 | 'password' => '', 26 | ], 27 | ], 28 | // Database connection configuration. 29 | 'doctrine' => [ 30 | 'connection' => [ 31 | 'orm_default' => [ 32 | 'driverClass' => PDOMySqlDriver::class, 33 | 'params' => [ 34 | 'host' => '127.0.0.1', 35 | 'user' => 'roledemo', 36 | 'password' => '', 37 | 'dbname' => 'roledemo', 38 | ] 39 | ], 40 | ], 41 | ], 42 | ]; 43 | -------------------------------------------------------------------------------- /roledemo/config/development.config.php.dist: -------------------------------------------------------------------------------- 1 | [ 11 | ], 12 | // Configuration overrides during development mode 13 | 'module_listener_options' => [ 14 | 'config_glob_paths' => [realpath(__DIR__) . '/autoload/{,*.}{global,local}-development.php'], 15 | 'config_cache_enabled' => false, 16 | 'module_map_cache_enabled' => false, 17 | ], 18 | ]; 19 | -------------------------------------------------------------------------------- /roledemo/config/modules.config.php: -------------------------------------------------------------------------------- 1 | createTable('user'); 31 | $table->addColumn('id', 'integer', ['autoincrement'=>true]); 32 | $table->addColumn('email', 'string', ['notnull'=>true, 'length'=>128]); 33 | $table->addColumn('full_name', 'string', ['notnull'=>true, 'length'=>512]); 34 | $table->addColumn('password', 'string', ['notnull'=>true, 'length'=>256]); 35 | $table->addColumn('status', 'integer', ['notnull'=>true]); 36 | $table->addColumn('date_created', 'datetime', ['notnull'=>true]); 37 | $table->addColumn('pwd_reset_token', 'string', ['notnull'=>false, 'length'=>256]); 38 | $table->addColumn('pwd_reset_token_creation_date', 'datetime', ['notnull'=>false]); 39 | $table->setPrimaryKey(['id']); 40 | $table->addUniqueIndex(['email'], 'email_idx'); 41 | $table->addOption('engine' , 'InnoDB'); 42 | } 43 | 44 | /** 45 | * Reverts the schema changes. 46 | * @param Schema $schema 47 | */ 48 | public function down(Schema $schema) 49 | { 50 | $schema->dropTable('user'); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /roledemo/data/font/thorne_shaded.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/roledemo/data/font/thorne_shaded.ttf -------------------------------------------------------------------------------- /roledemo/docker-compose.yml: -------------------------------------------------------------------------------- 1 | zf: 2 | build: . 3 | dockerfile: Dockerfile 4 | ports: 5 | - "8080:80" 6 | volumes: 7 | - .:/var/www 8 | -------------------------------------------------------------------------------- /roledemo/module/Application/src/Controller/Factory/IndexControllerFactory.php: -------------------------------------------------------------------------------- 1 | get('doctrine.entitymanager.orm_default'); 17 | 18 | // Instantiate the controller and inject dependencies 19 | return new IndexController($entityManager); 20 | } 21 | } -------------------------------------------------------------------------------- /roledemo/module/Application/src/Module.php: -------------------------------------------------------------------------------- 1 | getApplication(); 28 | $serviceManager = $application->getServiceManager(); 29 | 30 | // The following line instantiates the SessionManager and automatically 31 | // makes the SessionManager the 'default' one to avoid passing the 32 | // session manager as a dependency to other models. 33 | $sessionManager = $serviceManager->get(SessionManager::class); 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /roledemo/module/Application/src/Service/Factory/NavManagerFactory.php: -------------------------------------------------------------------------------- 1 | get(\Zend\Authentication\AuthenticationService::class); 20 | 21 | $viewHelperManager = $container->get('ViewHelperManager'); 22 | $urlHelper = $viewHelperManager->get('url'); 23 | $rbacManager = $container->get(RbacManager::class); 24 | 25 | return new NavManager($authService, $urlHelper, $rbacManager); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /roledemo/module/Application/src/Service/Factory/RbacAssertionManagerFactory.php: -------------------------------------------------------------------------------- 1 | get('doctrine.entitymanager.orm_default'); 19 | $authService = $container->get(\Zend\Authentication\AuthenticationService::class); 20 | 21 | return new RbacAssertionManager($entityManager, $authService); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /roledemo/module/Application/src/Service/RbacAssertionManager.php: -------------------------------------------------------------------------------- 1 | entityManager = $entityManager; 30 | $this->authService = $authService; 31 | } 32 | 33 | /** 34 | * This method is used for dynamic assertions. 35 | */ 36 | public function assert(Rbac $rbac, $permission, $params) 37 | { 38 | $currentUser = $this->entityManager->getRepository(User::class) 39 | ->findOneByEmail($this->authService->getIdentity()); 40 | 41 | if ($permission=='profile.own.view' && $params['user']->getId()==$currentUser->getId()) 42 | return true; 43 | 44 | return false; 45 | } 46 | } 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /roledemo/module/Application/src/View/Helper/Factory/MenuFactory.php: -------------------------------------------------------------------------------- 1 | get(NavManager::class); 18 | 19 | // Get menu items. 20 | $items = $navManager->getMenuItems(); 21 | 22 | // Instantiate the helper. 23 | return new Menu($items); 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /roledemo/module/Application/view/application/index/about.phtml: -------------------------------------------------------------------------------- 1 | headTitle('About'); 3 | 4 | $this->mainMenu()->setActiveItemId('about'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home'), 8 | 'About'=>$this->url('about'), 9 | ]); 10 | ?> 11 | 12 |

About

13 | 14 |

15 | Application name: escapeHtml($appName) ?> 16 |

17 | 18 |

19 | Application description: escapeHtml($appDescription) ?> 20 |

21 | -------------------------------------------------------------------------------- /roledemo/module/Application/view/application/index/index.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Welcome'); 3 | 4 | $this->mainMenu()->setActiveItemId('home'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home') 8 | ]); 9 | ?> 10 | 11 |

Welcome

12 | 13 |

14 | This is the Role Demo application powered by Zend Framework 3. It is based on User Demo sample. 15 | It demonstrates how to implement role-based access control. 16 |

17 | 18 |

19 | Click the Sign in button at the top right. To sign in, use the 20 | following credentials: 21 |

    22 |
  • Username: admin@example.com
  • 23 |
  • Password: Secur1ty
  • 24 |
25 |

26 | 27 |

28 | When signed in, use the Admin menu at the top to manage users, roles and permissions. 29 |

30 | 31 | 32 | -------------------------------------------------------------------------------- /roledemo/module/Application/view/application/index/settings.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Settings'); 3 | 4 | $this->mainMenu()->setActiveItemId('settings'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home'), 8 | 'Settings'=>$this->url('application', ['action'=>'settings']), 9 | ]); 10 | ?> 11 | 12 |

Settings

13 | 14 |
15 |
16 | 17 | 18 | 19 | 21 | 22 | 23 | 25 | 26 | 27 | 29 | 30 | 31 | 33 |
ID:escapeHtml($user->getId()) ?> 20 |
E-mail:escapeHtml($user->getEmail()) ?> 24 |
Full Name:escapeHtml($user->getFullName()) ?> 28 |
Date Created:escapeHtml($user->getDateCreated()) ?> 32 |
34 |
35 |
-------------------------------------------------------------------------------- /roledemo/module/User/src/Controller/Factory/AuthControllerFactory.php: -------------------------------------------------------------------------------- 1 | get('doctrine.entitymanager.orm_default'); 19 | $authManager = $container->get(AuthManager::class); 20 | $userManager = $container->get(UserManager::class); 21 | 22 | return new AuthController($entityManager, $authManager, $userManager); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /roledemo/module/User/src/Controller/Factory/PermissionControllerFactory.php: -------------------------------------------------------------------------------- 1 | get('doctrine.entitymanager.orm_default'); 18 | $permissionManager = $container->get(PermissionManager::class); 19 | 20 | // Instantiate the controller and inject dependencies 21 | return new PermissionController($entityManager, $permissionManager); 22 | } 23 | } 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /roledemo/module/User/src/Controller/Factory/RoleControllerFactory.php: -------------------------------------------------------------------------------- 1 | get('doctrine.entitymanager.orm_default'); 18 | $roleManager = $container->get(RoleManager::class); 19 | 20 | // Instantiate the controller and inject dependencies 21 | return new RoleController($entityManager, $roleManager); 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /roledemo/module/User/src/Controller/Factory/UserControllerFactory.php: -------------------------------------------------------------------------------- 1 | get('doctrine.entitymanager.orm_default'); 18 | $userManager = $container->get(UserManager::class); 19 | 20 | // Instantiate the controller and inject dependencies 21 | return new UserController($entityManager, $userManager); 22 | } 23 | } -------------------------------------------------------------------------------- /roledemo/module/User/src/Controller/Plugin/AccessPlugin.php: -------------------------------------------------------------------------------- 1 | rbacManager = $rbacManager; 16 | } 17 | 18 | /** 19 | * Checks whether the currently logged in user has the given permission. 20 | * @param string $permission Permission name. 21 | * @param array $params Optional params (used only if an assertion is associated with permission). 22 | */ 23 | public function __invoke($permission, $params = []) 24 | { 25 | return $this->rbacManager->isGranted(null, $permission, $params); 26 | } 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /roledemo/module/User/src/Controller/Plugin/Factory/AccessPluginFactory.php: -------------------------------------------------------------------------------- 1 | get(RbacManager::class); 18 | 19 | return new AccessPlugin($rbacManager); 20 | } 21 | } 22 | 23 | 24 | -------------------------------------------------------------------------------- /roledemo/module/User/src/Controller/Plugin/Factory/CurrentUserPluginFactory.php: -------------------------------------------------------------------------------- 1 | get('doctrine.entitymanager.orm_default'); 12 | $authService = $container->get(\Zend\Authentication\AuthenticationService::class); 13 | 14 | return new CurrentUserPlugin($entityManager, $authService); 15 | } 16 | } 17 | 18 | 19 | -------------------------------------------------------------------------------- /roledemo/module/User/src/Repository/RoleRepository.php: -------------------------------------------------------------------------------- 1 | getEntityManager(); 19 | 20 | $queryBuilder = $entityManager->createQueryBuilder(); 21 | 22 | $queryBuilder->select('u') 23 | ->from(User::class, 'u') 24 | ->orderBy('u.dateCreated', 'DESC'); 25 | 26 | return $queryBuilder->getQuery(); 27 | } 28 | } -------------------------------------------------------------------------------- /roledemo/module/User/src/Service/Factory/AuthAdapterFactory.php: -------------------------------------------------------------------------------- 1 | get('doctrine.entitymanager.orm_default'); 21 | 22 | // Create the AuthAdapter and inject dependency to its constructor. 23 | return new AuthAdapter($entityManager); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /roledemo/module/User/src/Service/Factory/AuthManagerFactory.php: -------------------------------------------------------------------------------- 1 | get(\Zend\Authentication\AuthenticationService::class); 25 | $sessionManager = $container->get(SessionManager::class); 26 | $rbacManager = $container->get(RbacManager::class); 27 | 28 | // Get contents of 'access_filter' config key (the AuthManager service 29 | // will use this data to determine whether to allow currently logged in user 30 | // to execute the controller action or not. 31 | $config = $container->get('Config'); 32 | if (isset($config['access_filter'])) 33 | $config = $config['access_filter']; 34 | else 35 | $config = []; 36 | 37 | // Instantiate the AuthManager service and inject dependencies to its constructor. 38 | return new AuthManager($authenticationService, $sessionManager, $config, $rbacManager); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /roledemo/module/User/src/Service/Factory/AuthenticationServiceFactory.php: -------------------------------------------------------------------------------- 1 | get(SessionManager::class); 23 | $authStorage = new SessionStorage('RoleDemo_Auth', 'session', $sessionManager); 24 | $authAdapter = $container->get(AuthAdapter::class); 25 | 26 | // Create the service and inject dependencies into its constructor. 27 | return new AuthenticationService($authStorage, $authAdapter); 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /roledemo/module/User/src/Service/Factory/PermissionManagerFactory.php: -------------------------------------------------------------------------------- 1 | get('doctrine.entitymanager.orm_default'); 20 | $rbacManager = $container->get(RbacManager::class); 21 | 22 | return new PermissionManager($entityManager, $rbacManager); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /roledemo/module/User/src/Service/Factory/RbacManagerFactory.php: -------------------------------------------------------------------------------- 1 | get('doctrine.entitymanager.orm_default'); 20 | $authService = $container->get(\Zend\Authentication\AuthenticationService::class); 21 | $cache = $container->get('FilesystemCache'); 22 | 23 | $assertionManagers = []; 24 | $config = $container->get('Config'); 25 | if (isset($config['rbac_manager']['assertions'])) { 26 | foreach ($config['rbac_manager']['assertions'] as $serviceName) { 27 | $assertionManagers[$serviceName] = $container->get($serviceName); 28 | } 29 | } 30 | 31 | return new RbacManager($entityManager, $authService, $cache, $assertionManagers); 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /roledemo/module/User/src/Service/Factory/RoleManagerFactory.php: -------------------------------------------------------------------------------- 1 | get('doctrine.entitymanager.orm_default'); 20 | $rbacManager = $container->get(RbacManager::class); 21 | 22 | return new RoleManager($entityManager, $rbacManager); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /roledemo/module/User/src/Service/Factory/UserManagerFactory.php: -------------------------------------------------------------------------------- 1 | get('doctrine.entitymanager.orm_default'); 21 | $roleManager = $container->get(RoleManager::class); 22 | $permissionManager = $container->get(PermissionManager::class); 23 | $viewRenderer = $container->get('ViewRenderer'); 24 | $config = $container->get('Config'); 25 | 26 | return new UserManager($entityManager, $roleManager, $permissionManager, $viewRenderer, $config); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /roledemo/module/User/src/View/Helper/Access.php: -------------------------------------------------------------------------------- 1 | rbacManager = $rbacManager; 16 | } 17 | 18 | public function __invoke($permission, $params = []) 19 | { 20 | return $this->rbacManager->isGranted(null, $permission, $params); 21 | } 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /roledemo/module/User/src/View/Helper/Factory/AccessFactory.php: -------------------------------------------------------------------------------- 1 | get(RbacManager::class); 18 | 19 | return new Access($rbacManager); 20 | } 21 | } 22 | 23 | 24 | -------------------------------------------------------------------------------- /roledemo/module/User/src/View/Helper/Factory/CurrentUserFactory.php: -------------------------------------------------------------------------------- 1 | get('doctrine.entitymanager.orm_default'); 12 | $authService = $container->get(\Zend\Authentication\AuthenticationService::class); 13 | 14 | return new CurrentUser($entityManager, $authService); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /roledemo/module/User/view/user/auth/login.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Sign in'); 3 | 4 | $this->mainMenu()->setActiveItemId('login'); 5 | 6 | $form->get('email')->setAttributes([ 7 | 'class'=>'form-control', 8 | 'placeholder'=>'Email address', 9 | 'required' => true, 10 | 'autofocus' => true 11 | ]) 12 | ->setLabelAttributes([ 13 | 'class' => 'sr-only' 14 | ]); 15 | 16 | $form->get('password')->setAttributes([ 17 | 'class'=>'form-control', 18 | 'placeholder'=>'Password', 19 | 'required' => true, 20 | ]) 21 | ->setLabelAttributes([ 22 | 'class' => 'sr-only' 23 | ]); 24 | ?> 25 | 26 |
27 |
28 | 49 |
50 |
-------------------------------------------------------------------------------- /roledemo/module/User/view/user/auth/not-authorized.phtml: -------------------------------------------------------------------------------- 1 | headTitle("Not Authorized"); 3 | ?> 4 | 5 |

Not Authorized

6 | 7 |
Sorry, you have no permission to see this page.
8 | -------------------------------------------------------------------------------- /roledemo/module/User/view/user/partial/paginator.phtml: -------------------------------------------------------------------------------- 1 | pageCount): ?> 2 | 3 | 46 | -------------------------------------------------------------------------------- /roledemo/module/User/view/user/permission/add.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Add Permission'); 3 | 4 | $this->mainMenu()->setActiveItemId('permissions'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home'), 8 | 'Manage Permissions'=>$this->url('permissions'), 9 | 'Add Permission'=>$this->url('permissions', ['action'=>'add']) 10 | ]); 11 | 12 | $form->get('name')->setAttributes([ 13 | 'class'=>'form-control', 14 | 'placeholder'=>'Enter name' 15 | ]); 16 | 17 | $form->get('description')->setAttributes([ 18 | 'class'=>'form-control', 19 | 'placeholder'=>'Enter description' 20 | ]); 21 | 22 | $form->get('submit')->setAttributes(['class'=>'btn btn-primary']); 23 | 24 | $form->prepare(); 25 | ?> 26 | 27 |

Add Permission

28 | 29 |

30 | Please fill out the following form and click the Create button. 31 |

32 | 33 |
34 |
35 | form()->openTag($form); ?> 36 | 37 |
38 | formLabel($form->get('name')); ?> 39 | formElement($form->get('name')); ?> 40 | formElementErrors($form->get('name')); ?> 41 |
42 | 43 |
44 | formLabel($form->get('description')); ?> 45 | formElement($form->get('description')); ?> 46 | formElementErrors($form->get('description')); ?> 47 |
48 | 49 | formElement($form->get('csrf')); ?> 50 | 51 | formElement($form->get('submit')); ?> 52 | 53 | form()->closeTag(); ?> 54 |
55 |
56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /roledemo/module/User/view/user/permission/edit.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Edit Permission'); 3 | 4 | $this->mainMenu()->setActiveItemId('permissions'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home'), 8 | 'Manage Permissions'=>$this->url('permissions'), 9 | 'Edit Permission'=>$this->url('permissions', ['action'=>'edit', 'id'=>$permission->getId()]) 10 | ]); 11 | 12 | $form->get('name')->setAttributes([ 13 | 'class'=>'form-control', 14 | 'placeholder'=>'Enter name' 15 | ]); 16 | 17 | $form->get('description')->setAttributes([ 18 | 'class'=>'form-control', 19 | 'placeholder'=>'Enter description' 20 | ]); 21 | 22 | $form->get('submit') 23 | ->setAttributes(['class'=>'btn btn-primary']) 24 | ->setValue('Save'); 25 | 26 | $form->prepare(); 27 | ?> 28 | 29 |

Edit Permission

30 | 31 |
32 |
33 | form()->openTag($form); ?> 34 | 35 |
36 | formLabel($form->get('name')); ?> 37 | formElement($form->get('name')); ?> 38 | formElementErrors($form->get('name')); ?> 39 |
40 | 41 |
42 | formLabel($form->get('description')); ?> 43 | formElement($form->get('description')); ?> 44 | formElementErrors($form->get('description')); ?> 45 |
46 | 47 | formElement($form->get('csrf')); ?> 48 | 49 | formElement($form->get('submit')); ?> 50 | 51 | form()->closeTag(); ?> 52 |
53 |
54 | 55 | -------------------------------------------------------------------------------- /roledemo/module/User/view/user/permission/view.phtml: -------------------------------------------------------------------------------- 1 | headTitle('View Permission'); 3 | 4 | $this->mainMenu()->setActiveItemId('permissions'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home'), 8 | 'Manage Permissions'=>$this->url('permissions'), 9 | 'View Permission'=>$this->url('permissions', ['action'=>'view', 'id'=>$permission->getId()]) 10 | ]); 11 | ?> 12 | 13 | 14 |

View Permission

15 | 16 |
17 |
18 | 19 | 20 | 21 | 23 | 24 | 25 | 27 | 28 | 29 | 31 | 32 | 33 | 35 |
ID:escapeHtml($permission->getId()) ?> 22 |
Name:escapeHtml($permission->getName()) ?> 26 |
Description:escapeHtml($permission->getDescription()) ?> 30 |
Date Created:escapeHtml($permission->getDateCreated()) ?> 34 |
36 |
37 |
-------------------------------------------------------------------------------- /roledemo/module/User/view/user/user/message.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Thank You'); 3 | ?> 4 | 5 |
6 |
7 |

Reset Password

8 | 9 | 10 |

11 | Password reset instructions have been sent to your email address. 12 |

13 | 14 |

15 | There is no user with such an email or the user is inactive. 16 |

17 | 18 |

19 | Your new password has been set successfully. 20 |

21 |

22 | Return to login page. 23 |

24 | 25 | 26 | Invalid reset key or it may have expired. Please return 27 | here and try reset your password again. 28 |

29 | 30 |
31 |
-------------------------------------------------------------------------------- /roledemo/module/User/view/user/user/reset-password.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Reset Password'); 3 | 4 | $form->get('email')->setAttributes([ 5 | 'class'=>'form-control', 6 | 'placeholder'=>'Email address' 7 | ]); 8 | 9 | $form->get('submit')->setAttributes([ 10 | 'class'=>'btn btn-large btn-primary' 11 | ]); 12 | 13 | $form->prepare(); 14 | ?> 15 | 16 |
17 |
18 | form()->openTag($form); ?> 19 | 20 |

Reset Password

21 | 22 |

Enter your e-mail address below to reset your password

23 | 24 | formElement($form->get('email')); ?> 25 | formElementErrors($form->get('email')); ?> 26 | 27 | formElement($form->get('captcha')); ?> 28 |

Enter the letters above as you see them.

29 | 30 | formElement($form->get('submit')); ?> 31 | 32 | formElement($form->get('csrf')); ?> 33 | 34 | form()->closeTag(); ?> 35 |
36 |
37 | -------------------------------------------------------------------------------- /roledemo/module/User/view/user/user/set-password.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Set New Password'); 3 | 4 | $form->get('new_password')->setAttributes(array( 5 | 'class'=>'form-control', 6 | 'placeholder'=>'Type New Password' 7 | )); 8 | $form->get('confirm_new_password')->setAttributes(array( 9 | 'class'=>'form-control', 10 | 'placeholder'=>'Confirm New Password' 11 | )); 12 | $form->get('submit')->setAttributes(array( 13 | 'class'=>'btn btn-primary' 14 | )); 15 | $form->prepare(); 16 | ?> 17 | 18 |
19 |
20 | form()->openTag($form); ?> 21 | 22 |

Set New Password

23 | 24 |

Enter your new password in the form below

25 | 26 |
27 | formLabel($form->get('new_password')); ?> 28 | formElement($form->get('new_password')); ?> 29 | formElementErrors($form->get('new_password')); ?> 30 |
31 | 32 |
33 | formLabel($form->get('confirm_new_password')); ?> 34 | formElement($form->get('confirm_new_password')); ?> 35 | formElementErrors($form->get('confirm_new_password')); ?> 36 |
37 | 38 | formElement($form->get('submit')); ?> 39 | 40 | formElement($form->get('csrf')); ?> 41 | 42 | form()->closeTag(); ?> 43 |
44 |
45 | -------------------------------------------------------------------------------- /roledemo/phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ./module/Application/test 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /roledemo/public/.htaccess: -------------------------------------------------------------------------------- 1 | RewriteEngine On 2 | # The following rule tells Apache that if the requested filename 3 | # exists, simply serve it. 4 | RewriteCond %{REQUEST_FILENAME} -s [OR] 5 | RewriteCond %{REQUEST_FILENAME} -l [OR] 6 | RewriteCond %{REQUEST_FILENAME} -d 7 | RewriteRule ^.*$ - [L] 8 | # The following rewrites all other queries to index.php. The 9 | # condition ensures that if you are using Apache aliases to do 10 | # mass virtual hosting or installed the project in a subdirectory, 11 | # the base path will be prepended to allow proper resolution of 12 | # the index.php file; it will work in non-aliased environments 13 | # as well, providing a safe, one-size fits all solution. 14 | RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ 15 | RewriteRule ^(.*) - [E=BASE:%1] 16 | RewriteRule ^(.*)$ %{ENV:BASE}/index.php [L] 17 | -------------------------------------------------------------------------------- /roledemo/public/css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-bottom: 40px; 3 | } 4 | 5 | .zf-green { 6 | color: #68b604; 7 | } 8 | 9 | .btn-success { 10 | background-color: #57a900; 11 | background-image: -moz-linear-gradient(top, #70d900, #57a900); 12 | background-image: -ms-linear-gradient(top, #70d900, #57a900); 13 | background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#70d900), to(#57a900)); 14 | background-image: -webkit-linear-gradient(top, #70d900, #57a900); 15 | background-image: -o-linear-gradient(top, #70d900, #57a900); 16 | background-image: linear-gradient(top, #70d900, #57a900); 17 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#70d900', endColorstr='#57a900', GradientType=0); 18 | } 19 | 20 | .btn-success:hover, 21 | .btn-success:active, 22 | .btn-success.active, 23 | .btn-success.disabled, 24 | .btn-success[disabled] { 25 | background-color: #57a900; 26 | } 27 | 28 | .btn-success:active, .btn-success.active { 29 | background-color: #57a900; 30 | } 31 | 32 | div.container a.navbar-brand > img { 33 | display: inline; 34 | margin-right: 4px; 35 | } 36 | 37 | div.app-caption { 38 | padding: 25px 0px; 39 | font-size:3.0em; 40 | font-weight: bold; 41 | color:#6aacaf 42 | } 43 | 44 | form ul { 45 | list-style-type: none; 46 | padding: 0px; 47 | margin: 0px 5px; 48 | } 49 | 50 | form ul li { 51 | color: red; 52 | } 53 | 54 | .alert ul { 55 | list-style-type: none; 56 | padding: 0px; 57 | margin: 0px 5px; 58 | } 59 | -------------------------------------------------------------------------------- /roledemo/public/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/roledemo/public/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /roledemo/public/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/roledemo/public/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /roledemo/public/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/roledemo/public/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /roledemo/public/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/roledemo/public/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /roledemo/public/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/roledemo/public/img/favicon.ico -------------------------------------------------------------------------------- /roledemo/public/img/zf-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/roledemo/public/img/zf-logo.png -------------------------------------------------------------------------------- /roledemo/public/index.php: -------------------------------------------------------------------------------- 1 | run(); 41 | -------------------------------------------------------------------------------- /userdemo/.gitignore: -------------------------------------------------------------------------------- 1 | nbproject 2 | ._* 3 | .vagrant 4 | .~lock.* 5 | .buildpath 6 | .DS_Store 7 | .idea 8 | .project 9 | .settings 10 | vendor/ 11 | config/development.config.php 12 | phpunit.xml 13 | public/img/captcha 14 | -------------------------------------------------------------------------------- /userdemo/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.0-apache 2 | 3 | RUN apt-get update \ 4 | && apt-get install -y git zlib1g-dev \ 5 | && docker-php-ext-install zip \ 6 | && a2enmod rewrite \ 7 | && sed -i 's!/var/www/html!/var/www/public!g' /etc/apache2/apache2.conf \ 8 | && mv /var/www/html /var/www/public \ 9 | && curl -sS https://getcomposer.org/installer \ 10 | | php -- --install-dir=/usr/local/bin --filename=composer 11 | 12 | WORKDIR /var/www 13 | -------------------------------------------------------------------------------- /userdemo/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005-2015, Zend Technologies USA, Inc. 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | - Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | - Neither the name of Zend Technologies USA, Inc. nor the names of its 16 | contributors may be used to endorse or promote products derived from this 17 | software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 23 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /userdemo/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zendframework/skeleton-application", 3 | "description": "Skeleton Application for Zend Framework zend-mvc applications", 4 | "type": "project", 5 | "license": "BSD-3-Clause", 6 | "keywords": [ 7 | "framework", 8 | "mvc", 9 | "zf2" 10 | ], 11 | "homepage": "http://framework.zend.com/", 12 | "minimum-stability": "dev", 13 | "prefer-stable": true, 14 | "require": { 15 | "php": "^5.6 || ^7.0", 16 | "ext-gd": "*", 17 | "ext-intl": "*", 18 | "zendframework/zend-component-installer": "^1.0 || ^0.3 || ^1.0.0-dev@dev", 19 | "zendframework/zend-mvc": "^3.1", 20 | "zfcampus/zf-development-mode": "^3.0", 21 | "zendframework/zend-mvc-form": "^1.0", 22 | "zendframework/zend-mvc-plugins": "^1.0.1", 23 | "zendframework/zend-session": "^2.7.1", 24 | "zendframework/zend-authentication": "^2.5", 25 | "doctrine/doctrine-orm-module": "^1.1.5", 26 | "doctrine/migrations": "^1.5", 27 | "zendframework/zend-math": "^3.0", 28 | "zendframework/zend-crypt": "^3.1", 29 | "zendframework/zend-captcha": "^2.6", 30 | "zendframework/zend-mail": "^2.10", 31 | "zendframework/zend-mime": "^2.7" 32 | }, 33 | "autoload": { 34 | "psr-4": { 35 | "Application\\": "module/Application/src/", 36 | "User\\": "module/User/src/" 37 | } 38 | }, 39 | "autoload-dev": { 40 | "psr-4": { 41 | "ApplicationTest\\": "module/Application/test/", 42 | "UserTest\\": "module/User/test/" 43 | } 44 | }, 45 | "extra": [], 46 | "scripts": { 47 | "development-disable": "zf-development-mode disable", 48 | "development-enable": "zf-development-mode enable", 49 | "development-status": "zf-development-mode status", 50 | "serve": "php -S 0.0.0.0:8080 -t public/ public/index.php" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /userdemo/composer.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/userdemo/composer.phar -------------------------------------------------------------------------------- /userdemo/config/autoload/.gitignore: -------------------------------------------------------------------------------- 1 | local.php 2 | *.local.php 3 | -------------------------------------------------------------------------------- /userdemo/config/autoload/README.md: -------------------------------------------------------------------------------- 1 | About this directory: 2 | ===================== 3 | 4 | By default, this application is configured to load all configs in 5 | `./config/autoload/{,*.}{global,local}.php`. Doing this provides a 6 | location for a developer to drop in configuration override files provided by 7 | modules, as well as cleanly provide individual, application-wide config files 8 | for things like database connections, etc. 9 | -------------------------------------------------------------------------------- /userdemo/config/autoload/development.local.php.dist: -------------------------------------------------------------------------------- 1 | 9 | * $ composer development-enable 10 | * 11 | * 12 | * from the project root to copy this file to development.local.php and enable 13 | * the settings it contains. 14 | * 15 | * You may also create files matching the glob pattern `{,*.}{global,local}-development.php`. 16 | */ 17 | 18 | return [ 19 | 'view_manager' => [ 20 | 'display_exceptions' => true, 21 | ], 22 | ]; 23 | -------------------------------------------------------------------------------- /userdemo/config/autoload/global.php: -------------------------------------------------------------------------------- 1 | [ 21 | 'cookie_lifetime' => 60*60*1, // Session cookie will expire in 1 hour. 22 | 'gc_maxlifetime' => 60*60*24*30, // How long to store session data on server (for 1 month). 23 | ], 24 | // Session manager configuration. 25 | 'session_manager' => [ 26 | // Session validators (used for security). 27 | 'validators' => [ 28 | RemoteAddr::class, 29 | HttpUserAgent::class, 30 | ] 31 | ], 32 | // Session storage configuration. 33 | 'session_storage' => [ 34 | 'type' => SessionArrayStorage::class 35 | ], 36 | 'doctrine' => [ 37 | // migrations configuration 38 | 'migrations_configuration' => [ 39 | 'orm_default' => [ 40 | 'directory' => 'data/Migrations', 41 | 'name' => 'Doctrine Database Migrations', 42 | 'namespace' => 'Migrations', 43 | 'table' => 'migrations', 44 | ], 45 | ], 46 | ], 47 | ]; 48 | -------------------------------------------------------------------------------- /userdemo/config/autoload/local.php.dist: -------------------------------------------------------------------------------- 1 | [ 19 | 'name' => 'localhost.localdomain', 20 | 'host' => '127.0.0.1', 21 | 'port' => 25, 22 | 'connection_class' => 'plain', 23 | 'connection_config' => [ 24 | 'username' => '', 25 | 'password' => '', 26 | ], 27 | ], 28 | // Database connection configuration. 29 | 'doctrine' => [ 30 | 'connection' => [ 31 | 'orm_default' => [ 32 | 'driverClass' => PDOMySqlDriver::class, 33 | 'params' => [ 34 | 'host' => '127.0.0.1', 35 | 'user' => 'userdemo', 36 | 'password' => '', 37 | 'dbname' => 'userdemo', 38 | ] 39 | ], 40 | ], 41 | ], 42 | ]; 43 | -------------------------------------------------------------------------------- /userdemo/config/development.config.php.dist: -------------------------------------------------------------------------------- 1 | [ 11 | ], 12 | // Configuration overrides during development mode 13 | 'module_listener_options' => [ 14 | 'config_glob_paths' => [realpath(__DIR__) . '/autoload/{,*.}{global,local}-development.php'], 15 | 'config_cache_enabled' => false, 16 | 'module_map_cache_enabled' => false, 17 | ], 18 | ]; 19 | -------------------------------------------------------------------------------- /userdemo/config/modules.config.php: -------------------------------------------------------------------------------- 1 | createTable('user'); 31 | $table->addColumn('id', 'integer', ['autoincrement'=>true]); 32 | $table->addColumn('email', 'string', ['notnull'=>true, 'length'=>128]); 33 | $table->addColumn('full_name', 'string', ['notnull'=>true, 'length'=>512]); 34 | $table->addColumn('password', 'string', ['notnull'=>true, 'length'=>256]); 35 | $table->addColumn('status', 'integer', ['notnull'=>true]); 36 | $table->addColumn('date_created', 'datetime', ['notnull'=>true]); 37 | $table->addColumn('pwd_reset_token', 'string', ['notnull'=>false, 'length'=>256]); 38 | $table->addColumn('pwd_reset_token_creation_date', 'datetime', ['notnull'=>false]); 39 | $table->setPrimaryKey(['id']); 40 | $table->addUniqueIndex(['email'], 'email_idx'); 41 | $table->addOption('engine' , 'InnoDB'); 42 | } 43 | 44 | /** 45 | * Reverts the schema changes. 46 | * @param Schema $schema 47 | */ 48 | public function down(Schema $schema) 49 | { 50 | $schema->dropTable('user'); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /userdemo/data/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /userdemo/data/font/thorne_shaded.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/userdemo/data/font/thorne_shaded.ttf -------------------------------------------------------------------------------- /userdemo/docker-compose.yml: -------------------------------------------------------------------------------- 1 | zf: 2 | build: . 3 | dockerfile: Dockerfile 4 | ports: 5 | - "8080:80" 6 | volumes: 7 | - .:/var/www 8 | -------------------------------------------------------------------------------- /userdemo/module/Application/src/Controller/Factory/IndexControllerFactory.php: -------------------------------------------------------------------------------- 1 | get('doctrine.entitymanager.orm_default'); 17 | 18 | // Instantiate the controller and inject dependencies 19 | return new IndexController($entityManager); 20 | } 21 | } -------------------------------------------------------------------------------- /userdemo/module/Application/src/Module.php: -------------------------------------------------------------------------------- 1 | getApplication(); 28 | $serviceManager = $application->getServiceManager(); 29 | 30 | // The following line instantiates the SessionManager and automatically 31 | // makes the SessionManager the 'default' one to avoid passing the 32 | // session manager as a dependency to other models. 33 | $sessionManager = $serviceManager->get(SessionManager::class); 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /userdemo/module/Application/src/Service/Factory/NavManagerFactory.php: -------------------------------------------------------------------------------- 1 | get(\Zend\Authentication\AuthenticationService::class); 19 | 20 | $viewHelperManager = $container->get('ViewHelperManager'); 21 | $urlHelper = $viewHelperManager->get('url'); 22 | 23 | return new NavManager($authService, $urlHelper); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /userdemo/module/Application/src/View/Helper/Factory/MenuFactory.php: -------------------------------------------------------------------------------- 1 | get(NavManager::class); 18 | 19 | // Get menu items. 20 | $items = $navManager->getMenuItems(); 21 | 22 | // Instantiate the helper. 23 | return new Menu($items); 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /userdemo/module/Application/view/application/index/about.phtml: -------------------------------------------------------------------------------- 1 | headTitle('About'); 3 | 4 | $this->mainMenu()->setActiveItemId('about'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home'), 8 | 'About'=>$this->url('about'), 9 | ]); 10 | ?> 11 | 12 |

About

13 | 14 |

15 | Application name: escapeHtml($appName) ?> 16 |

17 | 18 |

19 | Application description: escapeHtml($appDescription) ?> 20 |

21 | -------------------------------------------------------------------------------- /userdemo/module/Application/view/application/index/index.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Welcome'); 3 | 4 | $this->mainMenu()->setActiveItemId('home'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home') 8 | ]); 9 | ?> 10 | 11 |

Welcome

12 | 13 |

14 | This is the User Demo application powered by Zend Framework 3. It demonstrates 15 | how to implement user authentication and how to restrict certain pages to be 16 | accessed by unauthorized users. 17 |

18 | 19 |

20 | Click the Sign in button at the top right. To sign in, use the 21 | following credentials: 22 |

    23 |
  • Username: admin@example.com
  • 24 |
  • Password: Secur1ty
  • 25 |
26 |

27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /userdemo/module/Application/view/application/index/settings.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Settings'); 3 | 4 | $this->mainMenu()->setActiveItemId('settings'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home'), 8 | 'Settings'=>$this->url('application', ['action'=>'settings']), 9 | ]); 10 | ?> 11 | 12 |

Settings

13 | 14 |
15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
ID:escapeHtml($user->getId()) ?>
E-mail:escapeHtml($user->getEmail()) ?>
Full Name:escapeHtml($user->getFullName()) ?>
Date Created:escapeHtml($user->getDateCreated()) ?>
34 |
35 |
36 | -------------------------------------------------------------------------------- /userdemo/module/User/src/Controller/Factory/AuthControllerFactory.php: -------------------------------------------------------------------------------- 1 | get('doctrine.entitymanager.orm_default'); 19 | $authManager = $container->get(AuthManager::class); 20 | $userManager = $container->get(UserManager::class); 21 | 22 | return new AuthController($entityManager, $authManager, $userManager); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /userdemo/module/User/src/Controller/Factory/UserControllerFactory.php: -------------------------------------------------------------------------------- 1 | get('doctrine.entitymanager.orm_default'); 18 | $userManager = $container->get(UserManager::class); 19 | 20 | // Instantiate the controller and inject dependencies 21 | return new UserController($entityManager, $userManager); 22 | } 23 | } -------------------------------------------------------------------------------- /userdemo/module/User/src/Controller/Plugin/Factory/CurrentUserPluginFactory.php: -------------------------------------------------------------------------------- 1 | get('doctrine.entitymanager.orm_default'); 12 | $authService = $container->get(\Zend\Authentication\AuthenticationService::class); 13 | 14 | return new CurrentUserPlugin($entityManager, $authService); 15 | } 16 | } 17 | 18 | 19 | -------------------------------------------------------------------------------- /userdemo/module/User/src/Repository/UserRepository.php: -------------------------------------------------------------------------------- 1 | getEntityManager(); 19 | 20 | $queryBuilder = $entityManager->createQueryBuilder(); 21 | 22 | $queryBuilder->select('u') 23 | ->from(User::class, 'u') 24 | ->orderBy('u.dateCreated', 'DESC'); 25 | 26 | return $queryBuilder->getQuery(); 27 | } 28 | } -------------------------------------------------------------------------------- /userdemo/module/User/src/Service/Factory/AuthAdapterFactory.php: -------------------------------------------------------------------------------- 1 | get('doctrine.entitymanager.orm_default'); 21 | 22 | // Create the AuthAdapter and inject dependency to its constructor. 23 | return new AuthAdapter($entityManager); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /userdemo/module/User/src/Service/Factory/AuthManagerFactory.php: -------------------------------------------------------------------------------- 1 | get(\Zend\Authentication\AuthenticationService::class); 24 | $sessionManager = $container->get(SessionManager::class); 25 | 26 | // Get contents of 'access_filter' config key (the AuthManager service 27 | // will use this data to determine whether to allow currently logged in user 28 | // to execute the controller action or not. 29 | $config = $container->get('Config'); 30 | if (isset($config['access_filter'])) 31 | $config = $config['access_filter']; 32 | else 33 | $config = []; 34 | 35 | // Instantiate the AuthManager service and inject dependencies to its constructor. 36 | return new AuthManager($authenticationService, $sessionManager, $config); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /userdemo/module/User/src/Service/Factory/AuthenticationServiceFactory.php: -------------------------------------------------------------------------------- 1 | get(SessionManager::class); 23 | $authStorage = new SessionStorage('Zend_Auth', 'session', $sessionManager); 24 | $authAdapter = $container->get(AuthAdapter::class); 25 | 26 | // Create the service and inject dependencies into its constructor. 27 | return new AuthenticationService($authStorage, $authAdapter); 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /userdemo/module/User/src/Service/Factory/UserManagerFactory.php: -------------------------------------------------------------------------------- 1 | get('doctrine.entitymanager.orm_default'); 19 | $viewRenderer = $container->get('ViewRenderer'); 20 | $config = $container->get('Config'); 21 | 22 | return new UserManager($entityManager, $viewRenderer, $config); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /userdemo/module/User/src/View/Helper/Factory/CurrentUserFactory.php: -------------------------------------------------------------------------------- 1 | get('doctrine.entitymanager.orm_default'); 12 | $authService = $container->get(\Zend\Authentication\AuthenticationService::class); 13 | 14 | return new CurrentUser($entityManager, $authService); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /userdemo/module/User/view/user/auth/login.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Sign in'); 3 | 4 | $this->mainMenu()->setActiveItemId('login'); 5 | 6 | $form->get('email')->setAttributes([ 7 | 'class'=>'form-control', 8 | 'placeholder'=>'Email address', 9 | 'required' => true, 10 | 'autofocus' => true 11 | ]) 12 | ->setLabelAttributes([ 13 | 'class' => 'sr-only' 14 | ]); 15 | 16 | $form->get('password')->setAttributes([ 17 | 'class'=>'form-control', 18 | 'placeholder'=>'Password', 19 | 'required' => true, 20 | ]) 21 | ->setLabelAttributes([ 22 | 'class' => 'sr-only' 23 | ]); 24 | ?> 25 | 26 |
27 |
28 | 49 |
50 |
-------------------------------------------------------------------------------- /userdemo/module/User/view/user/partial/paginator.phtml: -------------------------------------------------------------------------------- 1 | pageCount): ?> 2 | 3 | 46 | -------------------------------------------------------------------------------- /userdemo/module/User/view/user/user/message.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Thank You'); 3 | ?> 4 | 5 |
6 |
7 |

Reset Password

8 | 9 | 10 |

11 | Password reset instructions have been sent to your email address. 12 |

13 | 14 |

15 | There is no user with such an email or the user is inactive. 16 |

17 | 18 |

19 | Your new password has been set successfully. 20 |

21 |

22 | Return to login page. 23 |

24 | 25 | 26 | Invalid reset key or it may have expired. Please return 27 | here and try reset your password again. 28 |

29 | 30 |
31 |
-------------------------------------------------------------------------------- /userdemo/module/User/view/user/user/reset-password.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Reset Password'); 3 | 4 | $form->get('email')->setAttributes([ 5 | 'class'=>'form-control', 6 | 'placeholder'=>'Email address' 7 | ]); 8 | 9 | $form->get('submit')->setAttributes([ 10 | 'class'=>'btn btn-large btn-primary' 11 | ]); 12 | 13 | $form->prepare(); 14 | ?> 15 | 16 |
17 |
18 | form()->openTag($form); ?> 19 | 20 |

Reset Password

21 | 22 |

Enter your e-mail address below to reset your password

23 | 24 | formElement($form->get('email')); ?> 25 | formElementErrors($form->get('email')); ?> 26 | 27 | formElement($form->get('captcha')); ?> 28 |

Enter the letters above as you see them.

29 | 30 | formElement($form->get('submit')); ?> 31 | 32 | formElement($form->get('csrf')); ?> 33 | 34 | form()->closeTag(); ?> 35 |
36 |
37 | -------------------------------------------------------------------------------- /userdemo/module/User/view/user/user/set-password.phtml: -------------------------------------------------------------------------------- 1 | headTitle('Set New Password'); 3 | 4 | $form->get('new_password')->setAttributes(array( 5 | 'class'=>'form-control', 6 | 'placeholder'=>'Type New Password' 7 | )); 8 | $form->get('confirm_new_password')->setAttributes(array( 9 | 'class'=>'form-control', 10 | 'placeholder'=>'Confirm New Password' 11 | )); 12 | $form->get('submit')->setAttributes(array( 13 | 'class'=>'btn btn-primary' 14 | )); 15 | $form->prepare(); 16 | ?> 17 | 18 |
19 |
20 | form()->openTag($form); ?> 21 | 22 |

Set New Password

23 | 24 |

Enter your new password in the form below

25 | 26 |
27 | formLabel($form->get('new_password')); ?> 28 | formElement($form->get('new_password')); ?> 29 | formElementErrors($form->get('new_password')); ?> 30 |
31 | 32 |
33 | formLabel($form->get('confirm_new_password')); ?> 34 | formElement($form->get('confirm_new_password')); ?> 35 | formElementErrors($form->get('confirm_new_password')); ?> 36 |
37 | 38 | formElement($form->get('submit')); ?> 39 | 40 | formElement($form->get('csrf')); ?> 41 | 42 | form()->closeTag(); ?> 43 |
44 |
45 | 46 | -------------------------------------------------------------------------------- /userdemo/module/User/view/user/user/view.phtml: -------------------------------------------------------------------------------- 1 | headTitle('View User'); 3 | 4 | $this->mainMenu()->setActiveItemId('users'); 5 | 6 | $this->pageBreadcrumbs()->setItems([ 7 | 'Home'=>$this->url('home'), 8 | 'Manage Users'=>$this->url('users'), 9 | 'View User'=>$this->url('users', ['action'=>'view', 'id'=>$user->getId()]) 10 | ]); 11 | ?> 12 | 13 | flashMessenger()->render('error', ['alert', 'alert-warning']); ?> 14 | flashMessenger()->render('success', ['alert', 'alert-success']); ?> 15 | flashMessenger()->render('info', ['alert', 'alert-info']); ?> 16 | 17 |

View User

18 | 19 |
20 |
21 | 22 | 23 | 24 | 26 | 27 | 28 | 30 | 31 | 32 | 34 | 35 | 36 | 38 | 39 | 40 | 42 |
ID:escapeHtml($user->getId()) ?> 25 |
E-mail:escapeHtml($user->getEmail()) ?> 29 |
Full Name:escapeHtml($user->getFullName()) ?> 33 |
Date Created:escapeHtml($user->getDateCreated()) ?> 37 |
Status:escapeHtml($user->getStatusAsString()) ?> 41 |
43 |
44 |
-------------------------------------------------------------------------------- /userdemo/phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ./module/Application/test 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /userdemo/public/.htaccess: -------------------------------------------------------------------------------- 1 | RewriteEngine On 2 | # The following rule tells Apache that if the requested filename 3 | # exists, simply serve it. 4 | RewriteCond %{REQUEST_FILENAME} -s [OR] 5 | RewriteCond %{REQUEST_FILENAME} -l [OR] 6 | RewriteCond %{REQUEST_FILENAME} -d 7 | RewriteRule ^.*$ - [L] 8 | # The following rewrites all other queries to index.php. The 9 | # condition ensures that if you are using Apache aliases to do 10 | # mass virtual hosting or installed the project in a subdirectory, 11 | # the base path will be prepended to allow proper resolution of 12 | # the index.php file; it will work in non-aliased environments 13 | # as well, providing a safe, one-size fits all solution. 14 | RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ 15 | RewriteRule ^(.*) - [E=BASE:%1] 16 | RewriteRule ^(.*)$ %{ENV:BASE}/index.php [L] 17 | -------------------------------------------------------------------------------- /userdemo/public/css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-bottom: 40px; 3 | } 4 | 5 | .zf-green { 6 | color: #68b604; 7 | } 8 | 9 | .btn-success { 10 | background-color: #57a900; 11 | background-image: -moz-linear-gradient(top, #70d900, #57a900); 12 | background-image: -ms-linear-gradient(top, #70d900, #57a900); 13 | background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#70d900), to(#57a900)); 14 | background-image: -webkit-linear-gradient(top, #70d900, #57a900); 15 | background-image: -o-linear-gradient(top, #70d900, #57a900); 16 | background-image: linear-gradient(top, #70d900, #57a900); 17 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#70d900', endColorstr='#57a900', GradientType=0); 18 | } 19 | 20 | .btn-success:hover, 21 | .btn-success:active, 22 | .btn-success.active, 23 | .btn-success.disabled, 24 | .btn-success[disabled] { 25 | background-color: #57a900; 26 | } 27 | 28 | .btn-success:active, .btn-success.active { 29 | background-color: #57a900; 30 | } 31 | 32 | div.container a.navbar-brand > img { 33 | display: inline; 34 | margin-right: 4px; 35 | } 36 | 37 | div.app-caption { 38 | padding: 25px 0px; 39 | font-size:3.0em; 40 | font-weight: bold; 41 | color:#6aacaf 42 | } 43 | 44 | form ul { 45 | list-style-type: none; 46 | padding: 0px; 47 | margin: 0px 5px; 48 | } 49 | 50 | form ul li { 51 | color: red; 52 | } 53 | 54 | .alert ul { 55 | list-style-type: none; 56 | padding: 0px; 57 | margin: 0px 5px; 58 | } 59 | -------------------------------------------------------------------------------- /userdemo/public/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/userdemo/public/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /userdemo/public/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/userdemo/public/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /userdemo/public/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/userdemo/public/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /userdemo/public/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/userdemo/public/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /userdemo/public/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/userdemo/public/img/favicon.ico -------------------------------------------------------------------------------- /userdemo/public/img/zf-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olegkrivtsov/using-zf3-book-samples/c5d69d704dc29766ac81b2ebbd313ef7c5a7c8e9/userdemo/public/img/zf-logo.png -------------------------------------------------------------------------------- /userdemo/public/index.php: -------------------------------------------------------------------------------- 1 | run(); 41 | --------------------------------------------------------------------------------