├── tests ├── _data │ └── .gitkeep ├── _output │ └── .gitignore ├── acceptance │ ├── _bootstrap.php │ ├── AboutCest.php │ ├── HomeCest.php │ ├── LoginCest.php │ └── ContactCest.php ├── functional │ ├── _bootstrap.php │ ├── LoginFormCest.php │ └── ContactFormCest.php ├── unit │ ├── _bootstrap.php │ └── models │ │ ├── UserTest.php │ │ ├── LoginFormTest.php │ │ └── ContactFormTest.php ├── _bootstrap.php ├── unit.suite.yml ├── acceptance.suite.yml.example ├── functional.suite.yml ├── bin │ ├── yii.bat │ └── yii └── _support │ ├── FunctionalTester.php │ ├── UnitTester.php │ └── AcceptanceTester.php ├── runtime └── .gitignore ├── web ├── assets │ └── .gitignore ├── robots.txt ├── favicon.ico ├── .htaccess ├── index.php ├── index-test.php └── css │ └── site.css ├── .bowerrc ├── vagrant ├── config │ ├── .gitignore │ └── vagrant-local.example.yml ├── nginx │ ├── log │ │ └── .gitignore │ └── app.conf └── provision │ ├── always-as-root.sh │ ├── once-as-vagrant.sh │ └── once-as-root.sh ├── config ├── params.php ├── test_db.php ├── db.php ├── test.php ├── console.php └── web.php ├── docker-compose.yml ├── views ├── site │ ├── about.php │ ├── error.php │ ├── login.php │ ├── index.php │ └── contact.php └── layouts │ └── main.php ├── .gitignore ├── yii.bat ├── yii ├── assets └── AppAsset.php ├── mail └── layouts │ └── html.php ├── codeception.yml ├── commands └── HelloController.php ├── LICENSE.md ├── models ├── ContactForm.php ├── LoginForm.php └── User.php ├── composer.json ├── widgets └── Alert.php ├── Vagrantfile ├── controllers └── SiteController.php ├── requirements.php └── README.md /tests/_data/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /runtime/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /tests/_output/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /tests/acceptance/_bootstrap.php: -------------------------------------------------------------------------------- 1 | 'admin@example.com', 5 | 'senderEmail' => 'noreply@example.com', 6 | 'senderName' => 'Example.com mailer', 7 | ]; 8 | -------------------------------------------------------------------------------- /tests/_bootstrap.php: -------------------------------------------------------------------------------- 1 | amOnPage(Url::toRoute('/site/about')); 10 | $I->see('About', 'h1'); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/unit.suite.yml: -------------------------------------------------------------------------------- 1 | # Codeception Test Suite Configuration 2 | 3 | # suite for unit (internal) tests. 4 | # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. 5 | 6 | class_name: UnitTester 7 | modules: 8 | enabled: 9 | - Asserts 10 | - Yii2: 11 | part: [orm, email, fixtures] 12 | -------------------------------------------------------------------------------- /tests/acceptance.suite.yml.example: -------------------------------------------------------------------------------- 1 | class_name: AcceptanceTester 2 | modules: 3 | enabled: 4 | - WebDriver: 5 | url: http://127.0.0.1:8080/ 6 | browser: firefox 7 | - Yii2: 8 | part: orm 9 | entryScript: index-test.php 10 | cleanup: false 11 | -------------------------------------------------------------------------------- /vagrant/provision/always-as-root.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #== Bash helpers == 4 | 5 | function info { 6 | echo " " 7 | echo "--> $1" 8 | echo " " 9 | } 10 | 11 | #== Provision script == 12 | 13 | info "Provision-script user: `whoami`" 14 | 15 | info "Restart web-stack" 16 | service php7.0-fpm restart 17 | service nginx restart 18 | service mysql restart -------------------------------------------------------------------------------- /config/db.php: -------------------------------------------------------------------------------- 1 | 'yii\db\Connection', 5 | 'dsn' => 'mysql:host=localhost;dbname=yii2basic', 6 | 'username' => 'root', 7 | 'password' => '', 8 | 'charset' => 'utf8', 9 | 10 | // Schema cache options (for production environment) 11 | //'enableSchemaCache' => true, 12 | //'schemaCacheDuration' => 60, 13 | //'schemaCache' => 'cache', 14 | ]; 15 | -------------------------------------------------------------------------------- /tests/functional.suite.yml: -------------------------------------------------------------------------------- 1 | # Codeception Test Suite Configuration 2 | 3 | # suite for functional (integration) tests. 4 | # emulate web requests and make application process them. 5 | # (tip: better to use with frameworks). 6 | 7 | # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. 8 | #basic/web/index.php 9 | class_name: FunctionalTester 10 | modules: 11 | enabled: 12 | - Filesystem 13 | - Yii2 14 | -------------------------------------------------------------------------------- /web/index.php: -------------------------------------------------------------------------------- 1 | run(); 13 | -------------------------------------------------------------------------------- /views/site/about.php: -------------------------------------------------------------------------------- 1 | title = 'About'; 8 | $this->params['breadcrumbs'][] = $this->title; 9 | ?> 10 |
14 | This is the About page. You may modify the following file to customize its content: 15 |
16 | 17 |= __FILE__ ?>
18 | 21 | The above error occurred while the Web server was processing your request. 22 |
23 |24 | Please contact us if you think this is a server error. Thank you. 25 |
26 | 27 |Please fill out the following fields to login:
17 | 18 | 'login-form', 20 | 'layout' => 'horizontal', 21 | 'fieldConfig' => [ 22 | 'template' => "{label}\napp\models\User::$users.
46 | You have successfully created your Yii-powered application.
13 | 14 | 15 |Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et 24 | dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip 25 | ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu 26 | fugiat nulla pariatur.
27 | 28 | 29 |Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et 34 | dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip 35 | ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu 36 | fugiat nulla pariatur.
37 | 38 | 39 |Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et 44 | dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip 45 | ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu 46 | fugiat nulla pariatur.
47 | 48 | 49 |
24 | Note that if you turn on the Yii debugger, you should be able
25 | to view the mail message on the mail panel of the debugger.
26 | mailer->useFileTransport): ?>
27 | Because the application is in development mode, the email is not sent but saved as
28 | a file under = Yii::getAlias(Yii::$app->mailer->fileTransportPath) ?>.
29 | Please configure the useFileTransport property of the mail
30 | application component to be false to enable email sending.
31 |
32 |
37 | If you have business inquiries or other questions, please fill out the following form to contact us. 38 | Thank you. 39 |
40 | 41 |The path to yii framework seems to be incorrect.
\n" 34 | . 'You need to install Yii framework via composer or adjust the framework path in file ' . basename(__FILE__) . ".
\n" 35 | . 'Please refer to the README on how to install Yii.
\n"; 36 | 37 | if (!empty($_SERVER['argv'])) { 38 | // do not print HTML when used in console mode 39 | echo strip_tags($message); 40 | } else { 41 | echo $message; 42 | } 43 | exit(1); 44 | } 45 | 46 | require_once($frameworkPath . '/requirements/YiiRequirementChecker.php'); 47 | $requirementsChecker = new YiiRequirementChecker(); 48 | 49 | $gdMemo = $imagickMemo = 'Either GD PHP extension with FreeType support or ImageMagick PHP extension with PNG support is required for image CAPTCHA.'; 50 | $gdOK = $imagickOK = false; 51 | 52 | if (extension_loaded('imagick')) { 53 | $imagick = new Imagick(); 54 | $imagickFormats = $imagick->queryFormats('PNG'); 55 | if (in_array('PNG', $imagickFormats)) { 56 | $imagickOK = true; 57 | } else { 58 | $imagickMemo = 'Imagick extension should be installed with PNG support in order to be used for image CAPTCHA.'; 59 | } 60 | } 61 | 62 | if (extension_loaded('gd')) { 63 | $gdInfo = gd_info(); 64 | if (!empty($gdInfo['FreeType Support'])) { 65 | $gdOK = true; 66 | } else { 67 | $gdMemo = 'GD extension should be installed with FreeType support in order to be used for image CAPTCHA.'; 68 | } 69 | } 70 | 71 | /** 72 | * Adjust requirements according to your application specifics. 73 | */ 74 | $requirements = array( 75 | // Database : 76 | array( 77 | 'name' => 'PDO extension', 78 | 'mandatory' => true, 79 | 'condition' => extension_loaded('pdo'), 80 | 'by' => 'All DB-related classes', 81 | ), 82 | array( 83 | 'name' => 'PDO SQLite extension', 84 | 'mandatory' => false, 85 | 'condition' => extension_loaded('pdo_sqlite'), 86 | 'by' => 'All DB-related classes', 87 | 'memo' => 'Required for SQLite database.', 88 | ), 89 | array( 90 | 'name' => 'PDO MySQL extension', 91 | 'mandatory' => false, 92 | 'condition' => extension_loaded('pdo_mysql'), 93 | 'by' => 'All DB-related classes', 94 | 'memo' => 'Required for MySQL database.', 95 | ), 96 | array( 97 | 'name' => 'PDO PostgreSQL extension', 98 | 'mandatory' => false, 99 | 'condition' => extension_loaded('pdo_pgsql'), 100 | 'by' => 'All DB-related classes', 101 | 'memo' => 'Required for PostgreSQL database.', 102 | ), 103 | // Cache : 104 | array( 105 | 'name' => 'Memcache extension', 106 | 'mandatory' => false, 107 | 'condition' => extension_loaded('memcache') || extension_loaded('memcached'), 108 | 'by' => 'MemCache', 109 | 'memo' => extension_loaded('memcached') ? 'To use memcached set MemCache::useMemcached totrue.' : ''
110 | ),
111 | // CAPTCHA:
112 | array(
113 | 'name' => 'GD PHP extension with FreeType support',
114 | 'mandatory' => false,
115 | 'condition' => $gdOK,
116 | 'by' => 'Captcha',
117 | 'memo' => $gdMemo,
118 | ),
119 | array(
120 | 'name' => 'ImageMagick PHP extension with PNG support',
121 | 'mandatory' => false,
122 | 'condition' => $imagickOK,
123 | 'by' => 'Captcha',
124 | 'memo' => $imagickMemo,
125 | ),
126 | // PHP ini :
127 | 'phpExposePhp' => array(
128 | 'name' => 'Expose PHP',
129 | 'mandatory' => false,
130 | 'condition' => $requirementsChecker->checkPhpIniOff("expose_php"),
131 | 'by' => 'Security reasons',
132 | 'memo' => '"expose_php" should be disabled at php.ini',
133 | ),
134 | 'phpAllowUrlInclude' => array(
135 | 'name' => 'PHP allow url include',
136 | 'mandatory' => false,
137 | 'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"),
138 | 'by' => 'Security reasons',
139 | 'memo' => '"allow_url_include" should be disabled at php.ini',
140 | ),
141 | 'phpSmtp' => array(
142 | 'name' => 'PHP mail SMTP',
143 | 'mandatory' => false,
144 | 'condition' => strlen(ini_get('SMTP')) > 0,
145 | 'by' => 'Email sending',
146 | 'memo' => 'PHP mail SMTP server required',
147 | ),
148 | );
149 |
150 | // OPcache check
151 | if (!version_compare(phpversion(), '5.5', '>=')) {
152 | $requirements[] = array(
153 | 'name' => 'APC extension',
154 | 'mandatory' => false,
155 | 'condition' => extension_loaded('apc'),
156 | 'by' => 'ApcCache',
157 | );
158 | }
159 |
160 | $result = $requirementsChecker->checkYii()->check($requirements)->getResult();
161 | $requirementsChecker->render();
162 | exit($result['summary']['errors'] === 0 ? 0 : 1);
163 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |