├── console ├── controllers │ └── .gitkeep ├── models │ └── .gitkeep ├── config │ ├── bootstrap.php │ ├── .gitignore │ ├── params.php │ └── main.php ├── runtime │ └── .gitignore └── migrations │ └── m130524_201442_init.php ├── backend ├── config │ ├── bootstrap.php │ ├── params.php │ ├── .gitignore │ └── main.php ├── runtime │ └── .gitignore ├── assets │ └── .gitignore ├── robots.txt ├── .gitignore ├── favicon.ico ├── assets_b │ ├── font-awesome │ │ ├── fonts │ │ │ ├── FontAwesome.otf │ │ │ ├── fontawesome-webfont.eot │ │ │ ├── fontawesome-webfont.ttf │ │ │ └── fontawesome-webfont.woff │ │ ├── less │ │ │ ├── fixed-width.less │ │ │ ├── bordered-pulled.less │ │ │ ├── larger.less │ │ │ ├── list.less │ │ │ ├── font-awesome.less │ │ │ ├── core.less │ │ │ ├── stacked.less │ │ │ ├── rotated-flipped.less │ │ │ ├── path.less │ │ │ ├── spinning.less │ │ │ └── mixins.less │ │ └── scss │ │ │ ├── _fixed-width.scss │ │ │ ├── _bordered-pulled.scss │ │ │ ├── _larger.scss │ │ │ ├── _list.scss │ │ │ ├── font-awesome.scss │ │ │ ├── _core.scss │ │ │ ├── _stacked.scss │ │ │ ├── _rotated-flipped.scss │ │ │ ├── _path.scss │ │ │ ├── _spinning.scss │ │ │ └── _mixins.scss │ ├── Flot.php │ ├── AppAsset.php │ └── css │ │ └── site.css ├── helper │ └── Common.php ├── models │ ├── InstallerForm.php │ ├── DatabaseSettingForm.php │ ├── BasicSettingForm.php │ └── MailFormSetting.php ├── views │ ├── layouts │ │ ├── footer.php │ │ ├── main.php │ │ ├── nav.php │ │ └── admin.php │ ├── admin │ │ ├── about.php │ │ ├── setting │ │ │ ├── install.php │ │ │ ├── self-test.php │ │ │ ├── database.php │ │ │ ├── index.php │ │ │ └── mail.php │ │ └── index.php │ └── site │ │ ├── error.php │ │ └── index.php ├── controllers │ ├── AdminController.php │ ├── SiteController.php │ └── admin │ │ └── SettingController.php └── .htaccess ├── robots.txt ├── assets └── .gitignore ├── frontend ├── config │ ├── bootstrap.php │ ├── .gitignore │ ├── params.php │ └── main.php ├── runtime │ └── .gitignore ├── views │ ├── site │ │ ├── about.php │ │ ├── error.php │ │ ├── contact.php │ │ └── index.php │ └── layouts │ │ └── main.php ├── assets │ ├── AppAsset.php │ └── css │ │ └── site.css ├── models │ └── ContactForm.php ├── controllers │ └── SiteController.php └── widgets │ └── Alert.php ├── FAQ.md ├── tests ├── codeception │ ├── backend │ │ ├── unit │ │ │ ├── fixtures │ │ │ │ └── data │ │ │ │ │ └── .gitkeep │ │ │ ├── _bootstrap.php │ │ │ ├── TestCase.php │ │ │ └── DbTestCase.php │ │ ├── _output │ │ │ └── .gitignore │ │ ├── acceptance │ │ │ ├── _bootstrap.php │ │ │ └── LoginCept.php │ │ ├── functional │ │ │ ├── _bootstrap.php │ │ │ └── LoginCept.php │ │ ├── .gitignore │ │ ├── unit.suite.yml │ │ ├── codeception.yml │ │ ├── functional.suite.yml │ │ ├── acceptance.suite.yml │ │ └── _bootstrap.php │ ├── console │ │ ├── unit │ │ │ ├── fixtures │ │ │ │ └── data │ │ │ │ │ └── .gitkeep │ │ │ ├── _bootstrap.php │ │ │ ├── TestCase.php │ │ │ └── DbTestCase.php │ │ ├── _output │ │ │ └── .gitignore │ │ ├── .gitignore │ │ ├── unit.suite.yml │ │ ├── codeception.yml │ │ └── _bootstrap.php │ ├── _output │ │ └── .gitignore │ ├── common │ │ ├── _output │ │ │ └── .gitignore │ │ ├── unit │ │ │ ├── _bootstrap.php │ │ │ ├── TestCase.php │ │ │ ├── DbTestCase.php │ │ │ ├── fixtures │ │ │ │ └── data │ │ │ │ │ └── models │ │ │ │ │ └── user.php │ │ │ └── models │ │ │ │ └── LoginFormTest.php │ │ ├── .gitignore │ │ ├── unit.suite.yml │ │ ├── fixtures │ │ │ ├── UserFixture.php │ │ │ └── data │ │ │ │ └── init_login.php │ │ ├── codeception.yml │ │ ├── templates │ │ │ └── fixtures │ │ │ │ └── user.php │ │ ├── _bootstrap.php │ │ ├── _pages │ │ │ └── LoginPage.php │ │ └── _support │ │ │ └── FixtureHelper.php │ ├── frontend │ │ ├── _output │ │ │ └── .gitignore │ │ ├── unit │ │ │ ├── _bootstrap.php │ │ │ ├── TestCase.php │ │ │ ├── DbTestCase.php │ │ │ ├── fixtures │ │ │ │ └── data │ │ │ │ │ └── models │ │ │ │ │ └── user.php │ │ │ └── models │ │ │ │ ├── ResetPasswordFormTest.php │ │ │ │ ├── SignupFormTest.php │ │ │ │ ├── ContactFormTest.php │ │ │ │ └── PasswordResetRequestFormTest.php │ │ ├── acceptance │ │ │ ├── _bootstrap.php │ │ │ ├── AboutCept.php │ │ │ ├── HomeCept.php │ │ │ ├── LoginCept.php │ │ │ ├── ContactCept.php │ │ │ └── SignupCest.php │ │ ├── functional │ │ │ ├── _bootstrap.php │ │ │ ├── AboutCept.php │ │ │ ├── HomeCept.php │ │ │ ├── LoginCept.php │ │ │ ├── ContactCept.php │ │ │ └── SignupCest.php │ │ ├── .gitignore │ │ ├── unit.suite.yml │ │ ├── _pages │ │ │ ├── AboutPage.php │ │ │ ├── ContactPage.php │ │ │ └── SignupPage.php │ │ ├── codeception.yml │ │ ├── functional.suite.yml │ │ ├── acceptance.suite.yml │ │ └── _bootstrap.php │ ├── config │ │ ├── backend │ │ │ ├── config.php │ │ │ ├── unit.php │ │ │ ├── acceptance.php │ │ │ └── functional.php │ │ ├── frontend │ │ │ ├── config.php │ │ │ ├── unit.php │ │ │ ├── functional.php │ │ │ └── acceptance.php │ │ ├── unit.php │ │ ├── acceptance.php │ │ ├── config.php │ │ ├── common │ │ │ └── unit.php │ │ ├── console │ │ │ └── unit.php │ │ └── functional.php │ └── bin │ │ ├── yii.bat │ │ ├── _bootstrap.php │ │ └── yii ├── codeception.yml └── README.md ├── .bowerrc ├── environments ├── dev │ ├── console │ │ ├── main-local.php │ │ └── params-local.php │ ├── backend │ │ ├── config │ │ │ ├── params-local.php │ │ │ └── main-local.php │ │ ├── index.php │ │ ├── index-test.php │ │ └── .htaccess │ ├── common │ │ └── config │ │ │ ├── main-local.php │ │ │ └── params-local.php │ ├── frontend │ │ └── config │ │ │ ├── params-local.php │ │ │ └── main-local.php │ ├── index-test.php │ ├── index.php │ ├── yii │ └── .htaccess ├── prod │ ├── console │ │ ├── main-local.php │ │ └── params-local.php │ ├── backend │ │ ├── config │ │ │ ├── params-local.php │ │ │ └── main-local.php │ │ ├── index.php │ │ └── .htaccess │ ├── common │ │ └── config │ │ │ ├── params-local.php │ │ │ └── main-local.php │ ├── frontend │ │ └── config │ │ │ ├── params-local.php │ │ │ └── main-local.php │ ├── index.php │ ├── yii │ └── .htaccess └── index.php ├── common └── config │ ├── .gitignore │ ├── params.php │ ├── bootstrap.php │ └── main.php ├── favicon.ico ├── .github └── FUNDING.yml ├── .gitignore ├── init.bat ├── yii.bat ├── index-test.php ├── index.php ├── CHANGE.md ├── LICENSE.md ├── composer.json ├── .htaccess ├── requirements.php ├── README.md └── init /console/controllers/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /console/models/.gitkeep: -------------------------------------------------------------------------------- 1 | * 2 | -------------------------------------------------------------------------------- /backend/config/bootstrap.php: -------------------------------------------------------------------------------- 1 | 'admin@example.com', 4 | ]; 5 | -------------------------------------------------------------------------------- /frontend/config/params.php: -------------------------------------------------------------------------------- 1 | 'admin@example.com', 4 | ]; 5 | -------------------------------------------------------------------------------- /backend/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhi1693/yii2-app-advanced-startup-kit/HEAD/backend/favicon.ico -------------------------------------------------------------------------------- /tests/codeception/backend/unit/_bootstrap.php: -------------------------------------------------------------------------------- 1 | [ 5 | 'db' => [ 6 | 'class' => 'yii\db\Connection', 7 | ], 8 | ] 9 | ]; -------------------------------------------------------------------------------- /backend/assets_b/font-awesome/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhi1693/yii2-app-advanced-startup-kit/HEAD/backend/assets_b/font-awesome/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /backend/assets_b/font-awesome/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhi1693/yii2-app-advanced-startup-kit/HEAD/backend/assets_b/font-awesome/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /tests/codeception/backend/.gitignore: -------------------------------------------------------------------------------- 1 | # these files are auto generated by codeception build 2 | /unit/UnitTester.php 3 | /functional/FunctionalTester.php 4 | /acceptance/AcceptanceTester.php 5 | -------------------------------------------------------------------------------- /tests/codeception/common/.gitignore: -------------------------------------------------------------------------------- 1 | # these files are auto generated by codeception build 2 | /unit/UnitTester.php 3 | /functional/FunctionalTester.php 4 | /acceptance/AcceptanceTester.php 5 | -------------------------------------------------------------------------------- /backend/assets_b/font-awesome/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhi1693/yii2-app-advanced-startup-kit/HEAD/backend/assets_b/font-awesome/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /backend/assets_b/font-awesome/less/fixed-width.less: -------------------------------------------------------------------------------- 1 | // Fixed Width Icons 2 | // ------------------------- 3 | .@{fa-css-prefix}-fw { 4 | width: (18em / 14); 5 | text-align: center; 6 | } 7 | -------------------------------------------------------------------------------- /backend/assets_b/font-awesome/scss/_fixed-width.scss: -------------------------------------------------------------------------------- 1 | // Fixed Width Icons 2 | // ------------------------- 3 | .#{$fa-css-prefix}-fw { 4 | width: (18em / 14); 5 | text-align: center; 6 | } 7 | -------------------------------------------------------------------------------- /tests/codeception/frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # these files are auto generated by codeception build 2 | /unit/UnitTester.php 3 | /functional/FunctionalTester.php 4 | /acceptance/AcceptanceTester.php 5 | -------------------------------------------------------------------------------- /tests/codeception/backend/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 | -------------------------------------------------------------------------------- /tests/codeception/common/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 | -------------------------------------------------------------------------------- /tests/codeception/console/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 | -------------------------------------------------------------------------------- /tests/codeception/frontend/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 | -------------------------------------------------------------------------------- /tests/codeception/backend/unit/TestCase.php: -------------------------------------------------------------------------------- 1 | dirname(__FILE__) . '/main-local.php', 7 | Enum::PARAMS_FILE => dirname(__FILE__) . '/params-local.php' 8 | ]; 9 | -------------------------------------------------------------------------------- /tests/codeception/common/unit/TestCase.php: -------------------------------------------------------------------------------- 1 | wantTo('ensure that about works'); 7 | AboutPage::openBy($I); 8 | $I->see('About', 'h1'); 9 | -------------------------------------------------------------------------------- /tests/codeception/frontend/functional/AboutCept.php: -------------------------------------------------------------------------------- 1 | wantTo('ensure that about works'); 7 | AboutPage::openBy($I); 8 | $I->see('About', 'h1'); 9 | -------------------------------------------------------------------------------- /environments/prod/frontend/config/main-local.php: -------------------------------------------------------------------------------- 1 | [ 4 | 'request' => [ 5 | // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation 6 | 'cookieValidationKey' => '', 7 | ], 8 | ], 9 | ]; 10 | -------------------------------------------------------------------------------- /tests/codeception/frontend/functional/HomeCept.php: -------------------------------------------------------------------------------- 1 | wantTo('ensure that home page works'); 5 | $I->amOnPage(Yii::$app->homeUrl); 6 | $I->see('My Company'); 7 | $I->seeLink('About'); 8 | $I->click('About'); 9 | $I->see('This is the About page.'); 10 | -------------------------------------------------------------------------------- /tests/codeception/common/codeception.yml: -------------------------------------------------------------------------------- 1 | namespace: tests\codeception\common 2 | actor: Tester 3 | paths: 4 | tests: . 5 | log: _output 6 | data: _data 7 | helpers: _support 8 | settings: 9 | bootstrap: _bootstrap.php 10 | suite_class: \PHPUnit_Framework_TestSuite 11 | colors: true 12 | memory_limit: 1024M 13 | log: true 14 | -------------------------------------------------------------------------------- /tests/codeception/frontend/acceptance/HomeCept.php: -------------------------------------------------------------------------------- 1 | wantTo('ensure that home page works'); 6 | $I->amOnPage(Yii::$app->homeUrl); 7 | $I->see('My Company'); 8 | $I->seeLink('About'); 9 | $I->click('About'); 10 | $I->see('This is the About page.'); 11 | -------------------------------------------------------------------------------- /environments/prod/backend/config/main-local.php: -------------------------------------------------------------------------------- 1 | [ 4 | 'request' => [ 5 | // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation 6 | 'cookieValidationKey' => '', 7 | 'csrfParam' => '_backendCsrf', 8 | ], 9 | ], 10 | ]; 11 | -------------------------------------------------------------------------------- /tests/codeception/console/codeception.yml: -------------------------------------------------------------------------------- 1 | namespace: tests\codeception\console 2 | actor: Tester 3 | paths: 4 | tests: . 5 | log: _output 6 | data: _data 7 | helpers: _support 8 | settings: 9 | bootstrap: _bootstrap.php 10 | suite_class: \PHPUnit_Framework_TestSuite 11 | colors: true 12 | memory_limit: 1024M 13 | log: true 14 | -------------------------------------------------------------------------------- /tests/codeception/frontend/_pages/AboutPage.php: -------------------------------------------------------------------------------- 1 | title = 'About'; 6 | $this->params['breadcrumbs'][] = $this->title; 7 | ?> 8 |
9 |

title) ?>

10 | 11 |

This is the About page. You may modify the following file to customize its content:

12 | 13 | 14 |
15 | -------------------------------------------------------------------------------- /backend/assets_b/font-awesome/less/bordered-pulled.less: -------------------------------------------------------------------------------- 1 | // Bordered & Pulled 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-border { 5 | padding: .2em .25em .15em; 6 | border: solid .08em @fa-border-color; 7 | border-radius: .1em; 8 | } 9 | 10 | .pull-right { float: right; } 11 | .pull-left { float: left; } 12 | 13 | .@{fa-css-prefix} { 14 | &.pull-left { margin-right: .3em; } 15 | &.pull-right { margin-left: .3em; } 16 | } 17 | -------------------------------------------------------------------------------- /backend/assets_b/Flot.php: -------------------------------------------------------------------------------- 1 | [ 7 | 'db' => [ 8 | 'dsn' => 'mysql:host=localhost;dbname=yii2_advanced_tests', 9 | ], 10 | 'mailer' => [ 11 | 'useFileTransport' => true, 12 | ], 13 | 'urlManager' => [ 14 | 'showScriptName' => true, 15 | ], 16 | ], 17 | ]; 18 | -------------------------------------------------------------------------------- /backend/helper/Common.php: -------------------------------------------------------------------------------- 1 | 'app-common', 12 | 'basePath' => dirname(__DIR__), 13 | ] 14 | ); 15 | -------------------------------------------------------------------------------- /backend/assets_b/font-awesome/less/list.less: -------------------------------------------------------------------------------- 1 | // List Icons 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-ul { 5 | padding-left: 0; 6 | margin-left: @fa-li-width; 7 | list-style-type: none; 8 | > li { position: relative; } 9 | } 10 | .@{fa-css-prefix}-li { 11 | position: absolute; 12 | left: -@fa-li-width; 13 | width: @fa-li-width; 14 | top: (2em / 14); 15 | text-align: center; 16 | &.@{fa-css-prefix}-lg { 17 | left: (-@fa-li-width + (4em / 14)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /backend/assets_b/font-awesome/scss/_list.scss: -------------------------------------------------------------------------------- 1 | // List Icons 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-ul { 5 | padding-left: 0; 6 | margin-left: $fa-li-width; 7 | list-style-type: none; 8 | > li { position: relative; } 9 | } 10 | .#{$fa-css-prefix}-li { 11 | position: absolute; 12 | left: -$fa-li-width; 13 | width: $fa-li-width; 14 | top: (2em / 14); 15 | text-align: center; 16 | &.#{$fa-css-prefix}-lg { 17 | left: -$fa-li-width + (4em / 14); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /backend/assets_b/font-awesome/scss/font-awesome.scss: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome 4.3.0 by @davegandy - http://fontawesome.io - @fontawesome 3 | * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) 4 | */ 5 | 6 | @import "variables"; 7 | @import "mixins"; 8 | @import "path"; 9 | @import "core"; 10 | @import "larger"; 11 | @import "fixed-width"; 12 | @import "list"; 13 | @import "bordered-pulled"; 14 | @import "animated"; 15 | @import "rotated-flipped"; 16 | @import "stacked"; 17 | @import "icons"; 18 | -------------------------------------------------------------------------------- /backend/models/InstallerForm.php: -------------------------------------------------------------------------------- 1 | 'Re-install Application' 27 | ]; 28 | } 29 | } -------------------------------------------------------------------------------- /tests/codeception/common/fixtures/data/init_login.php: -------------------------------------------------------------------------------- 1 | 'erau', 6 | 'auth_key' => 'tUu1qHcde0diwUol3xeI-18MuHkkprQI', 7 | // password_0 8 | 'password_hash' => '$2y$13$nJ1WDlBaGcbCdbNC5.5l4.sgy.OMEKCqtDQOdQ2OWpgiKRWYyzzne', 9 | 'password_reset_token' => 'RkD_Jw0_8HEedzLk7MM-ZKEFfYR7VbMr_1392559490', 10 | 'created_at' => '1392559490', 11 | 'updated_at' => '1392559490', 12 | 'email' => 'sfriesen@jenkins.info', 13 | ], 14 | ]; 15 | -------------------------------------------------------------------------------- /tests/codeception/common/unit/fixtures/data/models/user.php: -------------------------------------------------------------------------------- 1 | 'bayer.hudson', 6 | 'auth_key' => 'HP187Mvq7Mmm3CTU80dLkGmni_FUH_lR', 7 | //password_0 8 | 'password_hash' => '$2y$13$EjaPFBnZOQsHdGuHI.xvhuDp1fHpo8hKRSk6yshqa9c5EG8s3C3lO', 9 | 'password_reset_token' => 'ExzkCOaYc1L8IOBs4wdTGGbgNiG3Wz1I_1402312317', 10 | 'created_at' => '1402312317', 11 | 'updated_at' => '1402312317', 12 | 'email' => 'nicole.paucek@schultz.info', 13 | ], 14 | ]; 15 | -------------------------------------------------------------------------------- /tests/codeception/config/console/unit.php: -------------------------------------------------------------------------------- 1 | getSecurity(); 8 | 9 | return [ 10 | 'username' => $faker->userName, 11 | 'email' => $faker->email, 12 | 'auth_key' => $security->generateRandomString(), 13 | 'password_hash' => $security->generatePasswordHash('password_' . $index), 14 | 'password_reset_token' => $security->generateRandomString() . '_' . time(), 15 | 'created_at' => time(), 16 | 'updated_at' => time(), 17 | ]; 18 | -------------------------------------------------------------------------------- /backend/views/layouts/footer.php: -------------------------------------------------------------------------------- 1 | 13 | 14 | -------------------------------------------------------------------------------- /backend/assets_b/font-awesome/less/font-awesome.less: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome 4.3.0 by @davegandy - http://fontawesome.io - @fontawesome 3 | * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) 4 | */ 5 | 6 | @import "variables.less"; 7 | @import "mixins.less"; 8 | @import "path.less"; 9 | @import "core.less"; 10 | @import "larger.less"; 11 | @import "fixed-width.less"; 12 | @import "list.less"; 13 | @import "bordered-pulled.less"; 14 | @import "animated.less"; 15 | @import "rotated-flipped.less"; 16 | @import "stacked.less"; 17 | @import "icons.less"; 18 | -------------------------------------------------------------------------------- /tests/codeception/backend/codeception.yml: -------------------------------------------------------------------------------- 1 | namespace: tests\codeception\backend 2 | actor: Tester 3 | paths: 4 | tests: . 5 | log: _output 6 | data: _data 7 | helpers: _support 8 | settings: 9 | bootstrap: _bootstrap.php 10 | suite_class: \PHPUnit_Framework_TestSuite 11 | colors: true 12 | memory_limit: 1024M 13 | log: true 14 | config: 15 | # the entry script URL (with host info) for functional and acceptance tests 16 | # PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL 17 | test_entry_url: http://localhost:8080/backend/web/index-test.php 18 | -------------------------------------------------------------------------------- /tests/codeception/frontend/codeception.yml: -------------------------------------------------------------------------------- 1 | namespace: tests\codeception\frontend 2 | actor: Tester 3 | paths: 4 | tests: . 5 | log: _output 6 | data: _data 7 | helpers: _support 8 | settings: 9 | bootstrap: _bootstrap.php 10 | suite_class: \PHPUnit_Framework_TestSuite 11 | colors: true 12 | memory_limit: 1024M 13 | log: true 14 | config: 15 | # the entry script URL (with host info) for functional and acceptance tests 16 | # PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL 17 | test_entry_url: http://localhost:8080/frontend/web/index-test.php 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # yii console command 2 | /yii 3 | 4 | # phpstorm project files 5 | .idea 6 | 7 | # netbeans project files 8 | nbproject 9 | 10 | # zend studio for eclipse project files 11 | .buildpath 12 | .project 13 | .settings 14 | 15 | # windows thumbnail cache 16 | Thumbs.db 17 | 18 | # composer vendor dir 19 | /vendor 20 | 21 | # composer itself is not needed 22 | composer.phar 23 | composer.lock 24 | 25 | # Mac DS_Store Files 26 | .DS_Store 27 | 28 | # phpunit itself is not needed 29 | phpunit.phar 30 | # local phpunit config 31 | /phpunit.xml 32 | 33 | # modules directory 34 | modules -------------------------------------------------------------------------------- /tests/codeception/backend/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 | - tests\codeception\common\_support\FixtureHelper 15 | config: 16 | Yii2: 17 | configFile: '../config/backend/functional.php' 18 | -------------------------------------------------------------------------------- /tests/codeception/config/functional.php: -------------------------------------------------------------------------------- 1 | [ 7 | 'request' => [ 8 | // it's not recommended to run functional tests with CSRF validation enabled 9 | 'enableCsrfValidation' => false, 10 | // but if you absolutely need it set cookie domain to localhost 11 | /* 12 | 'csrfCookie' => [ 13 | 'domain' => 'localhost', 14 | ], 15 | */ 16 | ], 17 | ], 18 | ]; -------------------------------------------------------------------------------- /tests/codeception/frontend/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 | - tests\codeception\common\_support\FixtureHelper 15 | config: 16 | Yii2: 17 | configFile: '../config/frontend/functional.php' 18 | -------------------------------------------------------------------------------- /backend/assets_b/font-awesome/less/core.less: -------------------------------------------------------------------------------- 1 | // Base Class Definition 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix} { 5 | display: inline-block; 6 | font: normal normal normal @fa-font-size-base/1 FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | transform: translate(0, 0); // ensures no half-pixel rendering in firefox 12 | 13 | } 14 | -------------------------------------------------------------------------------- /init.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem ------------------------------------------------------------- 4 | rem Yii command line init script for Windows. 5 | rem 6 | rem @author Qiang Xue 7 | rem @link http://www.yiiframework.com/ 8 | rem @copyright Copyright (c) 2008 Yii Software LLC 9 | rem @license http://www.yiiframework.com/license/ 10 | rem ------------------------------------------------------------- 11 | 12 | @setlocal 13 | 14 | set YII_PATH=%~dp0 15 | 16 | if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe 17 | 18 | "%PHP_COMMAND%" "%YII_PATH%init" %* 19 | 20 | @endlocal 21 | -------------------------------------------------------------------------------- /yii.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem ------------------------------------------------------------- 4 | rem Yii command line bootstrap script for Windows. 5 | rem 6 | rem @author Qiang Xue 7 | rem @link http://www.yiiframework.com/ 8 | rem @copyright Copyright (c) 2008 Yii Software LLC 9 | rem @license http://www.yiiframework.com/license/ 10 | rem ------------------------------------------------------------- 11 | 12 | @setlocal 13 | 14 | set YII_PATH=%~dp0 15 | 16 | if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe 17 | 18 | "%PHP_COMMAND%" "%YII_PATH%yii" %* 19 | 20 | @endlocal 21 | -------------------------------------------------------------------------------- /backend/assets_b/font-awesome/less/stacked.less: -------------------------------------------------------------------------------- 1 | // Stacked Icons 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-stack { 5 | position: relative; 6 | display: inline-block; 7 | width: 2em; 8 | height: 2em; 9 | line-height: 2em; 10 | vertical-align: middle; 11 | } 12 | .@{fa-css-prefix}-stack-1x, .@{fa-css-prefix}-stack-2x { 13 | position: absolute; 14 | left: 0; 15 | width: 100%; 16 | text-align: center; 17 | } 18 | .@{fa-css-prefix}-stack-1x { line-height: inherit; } 19 | .@{fa-css-prefix}-stack-2x { font-size: 2em; } 20 | .@{fa-css-prefix}-inverse { color: @fa-inverse; } 21 | -------------------------------------------------------------------------------- /backend/assets_b/font-awesome/scss/_core.scss: -------------------------------------------------------------------------------- 1 | // Base Class Definition 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix} { 5 | display: inline-block; 6 | font: normal normal normal #{$fa-font-size-base}/1 FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | transform: translate(0, 0); // ensures no half-pixel rendering in firefox 12 | 13 | } 14 | -------------------------------------------------------------------------------- /tests/codeception/config/backend/unit.php: -------------------------------------------------------------------------------- 1 | title = 'About - ' . Yii::$app->name; 14 | ?> 15 |
16 |
About name ?>
17 |
18 |

Version:

19 | 20 |

Created By

21 | 22 |

23 | 24 |
25 |
26 | -------------------------------------------------------------------------------- /tests/codeception/bin/yii.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem ------------------------------------------------------------- 4 | rem Yii command line bootstrap script for Windows. 5 | rem 6 | rem @author Qiang Xue 7 | rem @link http://www.yiiframework.com/ 8 | rem @copyright Copyright (c) 2008 Yii Software LLC 9 | rem @license http://www.yiiframework.com/license/ 10 | rem ------------------------------------------------------------- 11 | 12 | @setlocal 13 | 14 | set YII_PATH=%~dp0 15 | 16 | if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe 17 | 18 | "%PHP_COMMAND%" "%YII_PATH%yii" %* 19 | 20 | @endlocal 21 | -------------------------------------------------------------------------------- /tests/codeception/common/_bootstrap.php: -------------------------------------------------------------------------------- 1 | [ 5 | 'request' => [ 6 | // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation 7 | 'cookieValidationKey' => '', 8 | ], 9 | ], 10 | ]; 11 | 12 | if (!YII_ENV_TEST) { 13 | // configuration adjustments for 'dev' environment 14 | $config['bootstrap'][] = 'debug'; 15 | $config['modules']['debug'] = 'yii\debug\Module'; 16 | 17 | $config['bootstrap'][] = 'gii'; 18 | $config['modules']['gii'] = 'yii\gii\Module'; 19 | } 20 | 21 | return $config; 22 | -------------------------------------------------------------------------------- /backend/views/site/error.php: -------------------------------------------------------------------------------- 1 | title = $name; 11 | ?> 12 |
13 | 14 |

title) ?>

15 | 16 |
17 | 18 |
19 | 20 |

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 |
28 | -------------------------------------------------------------------------------- /frontend/views/site/error.php: -------------------------------------------------------------------------------- 1 | title = $name; 11 | ?> 12 |
13 | 14 |

title) ?>

15 | 16 |
17 | 18 |
19 | 20 |

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 |
28 | -------------------------------------------------------------------------------- /environments/dev/backend/config/main-local.php: -------------------------------------------------------------------------------- 1 | [ 5 | 'request' => [ 6 | // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation 7 | 'cookieValidationKey' => '', 8 | 'csrfParam' => '_backendCsrf', 9 | ], 10 | ], 11 | ]; 12 | 13 | if (!YII_ENV_TEST) { 14 | // configuration adjustments for 'dev' environment 15 | $config['bootstrap'][] = 'debug'; 16 | $config['modules']['debug'] = 'yii\debug\Module'; 17 | 18 | $config['bootstrap'][] = 'gii'; 19 | $config['modules']['gii'] = 'yii\gii\Module'; 20 | } 21 | 22 | return $config; 23 | -------------------------------------------------------------------------------- /index-test.php: -------------------------------------------------------------------------------- 1 | run(); 19 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | run(); 19 | -------------------------------------------------------------------------------- /tests/codeception/console/_bootstrap.php: -------------------------------------------------------------------------------- 1 | run(); -------------------------------------------------------------------------------- /frontend/assets/AppAsset.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | class AppAsset extends AssetBundle 16 | { 17 | public $basePath = '@webroot'; 18 | public $baseUrl = '@web/frontend/assets'; 19 | public $css = [ 20 | 'css/site.css', 21 | ]; 22 | public $js = [ 23 | ]; 24 | public $depends = [ 25 | 'yii\web\YiiAsset', 26 | 'raoul2000\bootswatch\BootswatchAsset', 27 | ]; 28 | } 29 | -------------------------------------------------------------------------------- /environments/dev/backend/index.php: -------------------------------------------------------------------------------- 1 | run(); 19 | -------------------------------------------------------------------------------- /environments/dev/index-test.php: -------------------------------------------------------------------------------- 1 | run(); 19 | -------------------------------------------------------------------------------- /environments/dev/index.php: -------------------------------------------------------------------------------- 1 | run(); 19 | -------------------------------------------------------------------------------- /environments/prod/index.php: -------------------------------------------------------------------------------- 1 | run(); 19 | -------------------------------------------------------------------------------- /tests/codeception/config/backend/acceptance.php: -------------------------------------------------------------------------------- 1 | run(); 20 | -------------------------------------------------------------------------------- /tests/codeception/config/backend/functional.php: -------------------------------------------------------------------------------- 1 | 'Hostname', 30 | 'username' => 'Username', 31 | 'password' => 'Password', 32 | 'database' => 'Name of Database' 33 | ]; 34 | } 35 | } -------------------------------------------------------------------------------- /backend/assets_b/font-awesome/scss/_rotated-flipped.scss: -------------------------------------------------------------------------------- 1 | // Rotated & Flipped Icons 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-rotate-90 { @include fa-icon-rotate(90deg, 1); } 5 | .#{$fa-css-prefix}-rotate-180 { @include fa-icon-rotate(180deg, 2); } 6 | .#{$fa-css-prefix}-rotate-270 { @include fa-icon-rotate(270deg, 3); } 7 | 8 | .#{$fa-css-prefix}-flip-horizontal { @include fa-icon-flip(-1, 1, 0); } 9 | .#{$fa-css-prefix}-flip-vertical { @include fa-icon-flip(1, -1, 2); } 10 | 11 | // Hook for IE8-9 12 | // ------------------------- 13 | 14 | :root .#{$fa-css-prefix}-rotate-90, 15 | :root .#{$fa-css-prefix}-rotate-180, 16 | :root .#{$fa-css-prefix}-rotate-270, 17 | :root .#{$fa-css-prefix}-flip-horizontal, 18 | :root .#{$fa-css-prefix}-flip-vertical { 19 | filter: none; 20 | } 21 | -------------------------------------------------------------------------------- /backend/assets_b/AppAsset.php: -------------------------------------------------------------------------------- 1 | 14 | * @author Kartik Visweswaran 15 | * @since 2.0 16 | */ 17 | class AppAsset extends AssetBundle 18 | { 19 | public $basePath = '@webroot'; 20 | public $baseUrl = '@web/assets_b'; 21 | public $css = [ 22 | 'css/site.css', 23 | 'font-awesome/css/font-awesome.min.css', 24 | ]; 25 | public $js = [ 26 | ]; 27 | public $depends = [ 28 | 'yii\web\YiiAsset', 29 | 'raoul2000\bootswatch\BootswatchAsset', 30 | ]; 31 | } 32 | -------------------------------------------------------------------------------- /tests/codeception/frontend/_pages/ContactPage.php: -------------------------------------------------------------------------------- 1 | $value) { 21 | $inputType = $field === 'body' ? 'textarea' : 'input'; 22 | $this->actor->fillField($inputType . '[name="ContactForm[' . $field . ']"]', $value); 23 | } 24 | $this->actor->click('contact-button'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tests/codeception/frontend/_pages/SignupPage.php: -------------------------------------------------------------------------------- 1 | $value) { 22 | $inputType = $field === 'body' ? 'textarea' : 'input'; 23 | $this->actor->fillField($inputType . '[name="SignupForm[' . $field . ']"]', $value); 24 | } 25 | $this->actor->click('signup-button'); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tests/codeception/common/_pages/LoginPage.php: -------------------------------------------------------------------------------- 1 | actor->fillField('input[name="LoginForm[username]"]', $username); 22 | $this->actor->fillField('input[name="LoginForm[password]"]', $password); 23 | $this->actor->click('login-button'); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /backend/assets_b/font-awesome/less/path.less: -------------------------------------------------------------------------------- 1 | /* FONT PATH 2 | * -------------------------- */ 3 | 4 | @font-face { 5 | font-family: 'FontAwesome'; 6 | src: url('@{fa-font-path}/fontawesome-webfont.eot?v=@{fa-version}'); 7 | src: url('@{fa-font-path}/fontawesome-webfont.eot?#iefix&v=@{fa-version}') format('embedded-opentype'), 8 | url('@{fa-font-path}/fontawesome-webfont.woff2?v=@{fa-version}') format('woff2'), 9 | url('@{fa-font-path}/fontawesome-webfont.woff?v=@{fa-version}') format('woff'), 10 | url('@{fa-font-path}/fontawesome-webfont.ttf?v=@{fa-version}') format('truetype'), 11 | url('@{fa-font-path}/fontawesome-webfont.svg?v=@{fa-version}#fontawesomeregular') format('svg'); 12 | // src: url('@{fa-font-path}/FontAwesome.otf') format('opentype'); // used when developing fonts 13 | font-weight: normal; 14 | font-style: normal; 15 | } 16 | -------------------------------------------------------------------------------- /console/config/main.php: -------------------------------------------------------------------------------- 1 | 'app-console', 11 | 'basePath' => dirname(__DIR__), 12 | 'bootstrap' => ['log', 'gii'], 13 | 'controllerNamespace' => 'console\controllers', 14 | 'modules' => [ 15 | 'gii' => 'yii\gii\Module', 16 | ], 17 | 'components' => [ 18 | 'log' => [ 19 | 'targets' => [ 20 | [ 21 | 'class' => 'yii\log\FileTarget', 22 | 'levels' => ['error', 'warning'], 23 | ], 24 | ], 25 | ], 26 | ], 27 | 'params' => $params, 28 | ]; 29 | -------------------------------------------------------------------------------- /backend/assets_b/font-awesome/scss/_path.scss: -------------------------------------------------------------------------------- 1 | /* FONT PATH 2 | * -------------------------- */ 3 | 4 | @font-face { 5 | font-family: 'FontAwesome'; 6 | src: url('#{$fa-font-path}/fontawesome-webfont.eot?v=#{$fa-version}'); 7 | src: url('#{$fa-font-path}/fontawesome-webfont.eot?#iefix&v=#{$fa-version}') format('embedded-opentype'), 8 | url('#{$fa-font-path}/fontawesome-webfont.woff2?v=#{$fa-version}') format('woff2'), 9 | url('#{$fa-font-path}/fontawesome-webfont.woff?v=#{$fa-version}') format('woff'), 10 | url('#{$fa-font-path}/fontawesome-webfont.ttf?v=#{$fa-version}') format('truetype'), 11 | url('#{$fa-font-path}/fontawesome-webfont.svg?v=#{$fa-version}#fontawesomeregular') format('svg'); 12 | // src: url('#{$fa-font-path}/FontAwesome.otf') format('opentype'); // used when developing fonts 13 | font-weight: normal; 14 | font-style: normal; 15 | } 16 | -------------------------------------------------------------------------------- /backend/config/main.php: -------------------------------------------------------------------------------- 1 | 'app-backend', 11 | 'basePath' => dirname(__DIR__), 12 | 'controllerNamespace' => 'backend\controllers', 13 | 'bootstrap' => ['log'], 14 | 'components' => [ 15 | 'log' => [ 16 | 'traceLevel' => YII_DEBUG ? 3 : 0, 17 | 'targets' => [ 18 | [ 19 | 'class' => \yii\log\FileTarget::className(), 20 | 'levels' => ['error', 'warning'], 21 | ], 22 | ], 23 | ], 24 | 'errorHandler' => [ 25 | 'errorAction' => 'site/error', 26 | ], 27 | ], 28 | 'params' => $params, 29 | ]; 30 | -------------------------------------------------------------------------------- /backend/controllers/AdminController.php: -------------------------------------------------------------------------------- 1 | [ 22 | 'class' => AccessControl::className(), 23 | 'rules' => [ 24 | [ 25 | 'actions' => ['index', 'about'], 26 | 'allow' => TRUE, 27 | 'roles' => ['@'], 28 | ], 29 | ], 30 | ], 31 | ]; 32 | } 33 | 34 | public function actionIndex() 35 | { 36 | return $this->render('index'); 37 | } 38 | 39 | public function actionAbout() 40 | { 41 | return $this->render('about'); 42 | } 43 | } -------------------------------------------------------------------------------- /CHANGE.md: -------------------------------------------------------------------------------- 1 | v0.0.4-dev 2 | ---------- 3 | **Date:** 2015-03-03 4 | 5 | - Added User Account Settings 6 | - Added User Module Settings 7 | - Added Admin Panel Sidenav User Module Settings Url 8 | - Updated Frontend 9 | - Added Quick Links on the frontend for easy access 10 | - Added admin mail input to admin panel 11 | - Removed Admin LTE css 12 | 13 | v0.0.3 14 | ------ 15 | **Date:** 2015-03-01 16 | 17 | - Added Menu Helper to backend 18 | - Added Database Settings to admin panel 19 | - Added FAQ 20 | - Added Application Re-installer to admin panel 21 | - Fixed Typos 22 | 23 | v0.0.2 24 | ------ 25 | **Date:** 2015-02-20 26 | 27 | - Added new features 28 | - Fixed small bugs 29 | - Fixed typos 30 | - Added AccessControl Filter 31 | - (enh)Moved settings to common/main.php 32 | 33 | v0.0.1 34 | ------ 35 | **Date:** 2015-02-19 36 | 37 | - Initial release. 38 | - Based on latest yii2-advanced-app until 19-Dec-2014 39 | -------------------------------------------------------------------------------- /backend/assets_b/font-awesome/less/spinning.less: -------------------------------------------------------------------------------- 1 | // Spinning Icons 2 | // -------------------------- 3 | 4 | .@{fa-css-prefix}-spin { 5 | -webkit-animation: spin 2s infinite linear; 6 | -moz-animation: spin 2s infinite linear; 7 | -o-animation: spin 2s infinite linear; 8 | animation: spin 2s infinite linear; 9 | } 10 | 11 | @-moz-keyframes spin { 12 | 0% { -moz-transform: rotate(0deg); } 13 | 100% { -moz-transform: rotate(359deg); } 14 | } 15 | @-webkit-keyframes spin { 16 | 0% { -webkit-transform: rotate(0deg); } 17 | 100% { -webkit-transform: rotate(359deg); } 18 | } 19 | @-o-keyframes spin { 20 | 0% { -o-transform: rotate(0deg); } 21 | 100% { -o-transform: rotate(359deg); } 22 | } 23 | @keyframes spin { 24 | 0% { 25 | -webkit-transform: rotate(0deg); 26 | transform: rotate(0deg); 27 | } 28 | 100% { 29 | -webkit-transform: rotate(359deg); 30 | transform: rotate(359deg); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /backend/assets_b/font-awesome/scss/_spinning.scss: -------------------------------------------------------------------------------- 1 | // Spinning Icons 2 | // -------------------------- 3 | 4 | .#{$fa-css-prefix}-spin { 5 | -webkit-animation: spin 2s infinite linear; 6 | -moz-animation: spin 2s infinite linear; 7 | -o-animation: spin 2s infinite linear; 8 | animation: spin 2s infinite linear; 9 | } 10 | 11 | @-moz-keyframes spin { 12 | 0% { -moz-transform: rotate(0deg); } 13 | 100% { -moz-transform: rotate(359deg); } 14 | } 15 | @-webkit-keyframes spin { 16 | 0% { -webkit-transform: rotate(0deg); } 17 | 100% { -webkit-transform: rotate(359deg); } 18 | } 19 | @-o-keyframes spin { 20 | 0% { -o-transform: rotate(0deg); } 21 | 100% { -o-transform: rotate(359deg); } 22 | } 23 | @keyframes spin { 24 | 0% { 25 | -webkit-transform: rotate(0deg); 26 | transform: rotate(0deg); 27 | } 28 | 100% { 29 | -webkit-transform: rotate(359deg); 30 | transform: rotate(359deg); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /frontend/config/main.php: -------------------------------------------------------------------------------- 1 | 'app-practical-a-frontend', 11 | 'basePath' => dirname(__DIR__), 12 | 'bootstrap' => ['log'], 13 | 'controllerNamespace' => 'frontend\controllers', 14 | 'components' => [ 15 | 'log' => [ 16 | 'traceLevel' => YII_DEBUG ? 3 : 0, 17 | 'targets' => [ 18 | [ 19 | 'class' => \yii\log\FileTarget::className(), 20 | 'levels' => ['error'], 21 | ], 22 | ], 23 | ], 24 | 'errorHandler' => [ 25 | 'errorAction' => 'site/error', 26 | ] 27 | ], 28 | 'params' => $params, 29 | ]; 30 | -------------------------------------------------------------------------------- /tests/codeception/bin/_bootstrap.php: -------------------------------------------------------------------------------- 1 | title = 'Application Installer - ' . Yii::$app->name; 16 | ?> 17 |
18 |
Restart Installer
19 | 20 |
21 | FALSE 23 | ]) ?> 24 | 25 |
26 | field($model, 'install')->checkbox()->hint('Logout in order to invoke application installer') ?> 27 |
28 | 29 | 'btn btn-danger']) ?> 30 | 31 | 32 |
33 |
-------------------------------------------------------------------------------- /tests/codeception/frontend/unit/fixtures/data/models/user.php: -------------------------------------------------------------------------------- 1 | 'okirlin', 6 | 'auth_key' => 'iwTNae9t34OmnK6l4vT4IeaTk-YWI2Rv', 7 | 'password_hash' => '$2y$13$CXT0Rkle1EMJ/c1l5bylL.EylfmQ39O5JlHJVFpNn618OUS1HwaIi', 8 | 'password_reset_token' => 't5GU9NwpuGYSfb7FEZMAxqtuz2PkEvv_' . time(), 9 | 'created_at' => '1391885313', 10 | 'updated_at' => '1391885313', 11 | 'email' => 'brady.renner@rutherford.com', 12 | ], 13 | [ 14 | 'username' => 'troy.becker', 15 | 'auth_key' => 'EdKfXrx88weFMV0vIxuTMWKgfK2tS3Lp', 16 | 'password_hash' => '$2y$13$g5nv41Px7VBqhS3hVsVN2.MKfgT3jFdkXEsMC4rQJLfaMa7VaJqL2', 17 | 'password_reset_token' => '4BSNyiZNAuxjs5Mty990c47sVrgllIi_' . time(), 18 | 'created_at' => '1391885313', 19 | 'updated_at' => '1391885313', 20 | 'email' => 'nicolas.dianna@hotmail.com', 21 | 'status' => '0', 22 | ], 23 | ]; 24 | -------------------------------------------------------------------------------- /tests/codeception/frontend/functional/LoginCept.php: -------------------------------------------------------------------------------- 1 | wantTo('ensure login page works'); 7 | 8 | $loginPage = LoginPage::openBy($I); 9 | 10 | $I->amGoingTo('submit login form with no data'); 11 | $loginPage->login('', ''); 12 | $I->expectTo('see validations errors'); 13 | $I->see('Username cannot be blank.', '.help-block'); 14 | $I->see('Password cannot be blank.', '.help-block'); 15 | 16 | $I->amGoingTo('try to login with wrong credentials'); 17 | $I->expectTo('see validations errors'); 18 | $loginPage->login('admin', 'wrong'); 19 | $I->expectTo('see validations errors'); 20 | $I->see('Incorrect username or password.', '.help-block'); 21 | 22 | $I->amGoingTo('try to login with correct credentials'); 23 | $loginPage->login('erau', 'password_0'); 24 | $I->expectTo('see that user is logged'); 25 | $I->seeLink('Logout (erau)'); 26 | $I->dontSeeLink('Login'); 27 | $I->dontSeeLink('Signup'); 28 | -------------------------------------------------------------------------------- /tests/codeception/backend/functional/LoginCept.php: -------------------------------------------------------------------------------- 1 | wantTo('ensure login page works'); 8 | 9 | $loginPage = LoginPage::openBy($I); 10 | 11 | $I->amGoingTo('submit login form with no data'); 12 | $loginPage->login('', ''); 13 | $I->expectTo('see validations errors'); 14 | $I->see('Username cannot be blank.', '.help-block'); 15 | $I->see('Password cannot be blank.', '.help-block'); 16 | 17 | $I->amGoingTo('try to login with wrong credentials'); 18 | $I->expectTo('see validations errors'); 19 | $loginPage->login('admin', 'wrong'); 20 | $I->expectTo('see validations errors'); 21 | $I->see('Incorrect username or password.', '.help-block'); 22 | 23 | $I->amGoingTo('try to login with correct credentials'); 24 | $loginPage->login('erau', 'password_0'); 25 | $I->expectTo('see that user is logged'); 26 | $I->seeLink('Logout (erau)'); 27 | $I->dontSeeLink('Login'); 28 | $I->dontSeeLink('Signup'); 29 | -------------------------------------------------------------------------------- /common/config/main.php: -------------------------------------------------------------------------------- 1 | dirname(dirname(__DIR__)) . '/vendor', 4 | 'modules' => [ 5 | 'user' => [ 6 | 'class' => \abhimanyu\user\UserModule::className(), 7 | 'layout' => '@backend/views/layouts/admin' 8 | ], 9 | 'installer' => [ 10 | 'class' => \abhimanyu\installer\InstallerModule::className() 11 | ], 12 | 'gridview' => [ 13 | 'class' => \kartik\grid\Module::className() 14 | ], 15 | ], 16 | 'components' => [ 17 | 'db' => [ 18 | 'class' => \yii\db\Connection::className(), 19 | 'dsn' => 'mysql:host=localhost;dbname=' 20 | ], 21 | 'user' => [ 22 | 'identityClass' => \abhimanyu\user\models\UserIdentity::className(), 23 | 'loginUrl' => ['/user/auth/login'], 24 | ], 25 | 'config' => [ 26 | 'class' => \abhimanyu\config\components\Config::className(), 27 | ], 28 | 'urlManager' => [ 29 | 'enablePrettyUrl' => TRUE, 30 | 'showScriptName' => FALSE, 31 | ], 32 | ], 33 | 'params' => [ 34 | 'installed' => FALSE 35 | ] 36 | ]; 37 | -------------------------------------------------------------------------------- /backend/assets_b/font-awesome/less/mixins.less: -------------------------------------------------------------------------------- 1 | // Mixins 2 | // -------------------------- 3 | 4 | .fa-icon() { 5 | display: inline-block; 6 | font: normal normal normal @fa-font-size-base/1 FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | transform: translate(0, 0); // ensures no half-pixel rendering in firefox 12 | 13 | } 14 | 15 | .fa-icon-rotate(@degrees, @rotation) { 16 | filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=@rotation); 17 | -webkit-transform: rotate(@degrees); 18 | -ms-transform: rotate(@degrees); 19 | transform: rotate(@degrees); 20 | } 21 | 22 | .fa-icon-flip(@horiz, @vert, @rotation) { 23 | filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=@rotation, mirror=1); 24 | -webkit-transform: scale(@horiz, @vert); 25 | -ms-transform: scale(@horiz, @vert); 26 | transform: scale(@horiz, @vert); 27 | } 28 | -------------------------------------------------------------------------------- /backend/assets_b/font-awesome/scss/_mixins.scss: -------------------------------------------------------------------------------- 1 | // Mixins 2 | // -------------------------- 3 | 4 | @mixin fa-icon() { 5 | display: inline-block; 6 | font: normal normal normal #{$fa-font-size-base}/1 FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | transform: translate(0, 0); // ensures no half-pixel rendering in firefox 12 | 13 | } 14 | 15 | @mixin fa-icon-rotate($degrees, $rotation) { 16 | filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=#{$rotation}); 17 | -webkit-transform: rotate($degrees); 18 | -ms-transform: rotate($degrees); 19 | transform: rotate($degrees); 20 | } 21 | 22 | @mixin fa-icon-flip($horiz, $vert, $rotation) { 23 | filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=#{$rotation}); 24 | -webkit-transform: scale($horiz, $vert); 25 | -ms-transform: scale($horiz, $vert); 26 | transform: scale($horiz, $vert); 27 | } 28 | -------------------------------------------------------------------------------- /environments/dev/yii: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | run(); 32 | exit($exitCode); 33 | -------------------------------------------------------------------------------- /environments/prod/yii: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | run(); 32 | exit($exitCode); 33 | -------------------------------------------------------------------------------- /tests/codeception/frontend/acceptance/LoginCept.php: -------------------------------------------------------------------------------- 1 | wantTo('ensure login page works'); 7 | 8 | $loginPage = LoginPage::openBy($I); 9 | 10 | $I->amGoingTo('submit login form with no data'); 11 | $loginPage->login('', ''); 12 | $I->expectTo('see validations errors'); 13 | $I->see('Username cannot be blank.', '.help-block'); 14 | $I->see('Password cannot be blank.', '.help-block'); 15 | 16 | $I->amGoingTo('try to login with wrong credentials'); 17 | $I->expectTo('see validations errors'); 18 | $loginPage->login('admin', 'wrong'); 19 | $I->expectTo('see validations errors'); 20 | $I->see('Incorrect username or password.', '.help-block'); 21 | 22 | $I->amGoingTo('try to login with correct credentials'); 23 | $loginPage->login('erau', 'password_0'); 24 | $I->expectTo('see that user is logged'); 25 | $I->seeLink('Logout (erau)'); 26 | $I->dontSeeLink('Login'); 27 | $I->dontSeeLink('Signup'); 28 | /** Uncomment if using WebDriver 29 | * $I->click('Logout (erau)'); 30 | * $I->dontSeeLink('Logout (erau)'); 31 | * $I->seeLink('Login'); 32 | */ 33 | -------------------------------------------------------------------------------- /tests/codeception/backend/acceptance/LoginCept.php: -------------------------------------------------------------------------------- 1 | wantTo('ensure login page works'); 8 | 9 | $loginPage = LoginPage::openBy($I); 10 | 11 | $I->amGoingTo('submit login form with no data'); 12 | $loginPage->login('', ''); 13 | $I->expectTo('see validations errors'); 14 | $I->see('Username cannot be blank.', '.help-block'); 15 | $I->see('Password cannot be blank.', '.help-block'); 16 | 17 | $I->amGoingTo('try to login with wrong credentials'); 18 | $I->expectTo('see validations errors'); 19 | $loginPage->login('admin', 'wrong'); 20 | $I->expectTo('see validations errors'); 21 | $I->see('Incorrect username or password.', '.help-block'); 22 | 23 | $I->amGoingTo('try to login with correct credentials'); 24 | $loginPage->login('erau', 'password_0'); 25 | $I->expectTo('see that user is logged'); 26 | $I->seeLink('Logout (erau)'); 27 | $I->dontSeeLink('Login'); 28 | $I->dontSeeLink('Signup'); 29 | /** Uncomment if using WebDriver 30 | * $I->click('Logout (erau)'); 31 | * $I->dontSeeLink('Logout (erau)'); 32 | * $I->seeLink('Login'); 33 | */ 34 | -------------------------------------------------------------------------------- /backend/views/layouts/main.php: -------------------------------------------------------------------------------- 1 | config->get(Enum::APP_BACKEND_THEME, 'yeti'); 11 | AppAsset::register($this); 12 | ?> 13 | beginPage() ?> 14 | 15 | 16 | 17 | 18 | 19 | 20 | <?= Html::encode($this->title) ?> 21 | head() ?> 22 | 23 | 24 | beginBody() ?> 25 |
26 | render('nav') ?> 27 | 28 |
29 | isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], 31 | ]) ?> 32 | 33 |
34 |
35 | 36 | render('footer') ?> 37 | 38 | endBody() ?> 39 | 40 | 41 | endPage() ?> 42 | -------------------------------------------------------------------------------- /tests/codeception/backend/acceptance.suite.yml: -------------------------------------------------------------------------------- 1 | # Codeception Test Suite Configuration 2 | 3 | # suite for acceptance tests. 4 | # perform tests in browser using the Selenium-like tools. 5 | # powered by Mink (http://mink.behat.org). 6 | # (tip: that's what your customer will see). 7 | # (tip: test your ajax and javascript by one of Mink drivers). 8 | 9 | # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. 10 | 11 | class_name: AcceptanceTester 12 | modules: 13 | enabled: 14 | - PhpBrowser 15 | - tests\codeception\common\_support\FixtureHelper 16 | # you can use WebDriver instead of PhpBrowser to test javascript and ajax. 17 | # This will require you to install selenium. See http://codeception.com/docs/04-AcceptanceTests#Selenium 18 | # "restart" option is used by the WebDriver to start each time per test-file new session and cookies, 19 | # it is useful if you want to login in your app in each test. 20 | # - WebDriver 21 | config: 22 | PhpBrowser: 23 | # PLEASE ADJUST IT TO THE ACTUAL ENTRY POINT WITHOUT PATH INFO 24 | url: http://localhost:8080 25 | # WebDriver: 26 | # url: http://localhost:8080 27 | # browser: firefox 28 | # restart: true 29 | -------------------------------------------------------------------------------- /tests/codeception/frontend/acceptance.suite.yml: -------------------------------------------------------------------------------- 1 | # Codeception Test Suite Configuration 2 | 3 | # suite for acceptance tests. 4 | # perform tests in browser using the Selenium-like tools. 5 | # powered by Mink (http://mink.behat.org). 6 | # (tip: that's what your customer will see). 7 | # (tip: test your ajax and javascript by one of Mink drivers). 8 | 9 | # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. 10 | 11 | class_name: AcceptanceTester 12 | modules: 13 | enabled: 14 | - PhpBrowser 15 | - tests\codeception\common\_support\FixtureHelper 16 | # you can use WebDriver instead of PhpBrowser to test javascript and ajax. 17 | # This will require you to install selenium. See http://codeception.com/docs/04-AcceptanceTests#Selenium 18 | # "restart" option is used by the WebDriver to start each time per test-file new session and cookies, 19 | # it is useful if you want to login in your app in each test. 20 | # - WebDriver 21 | config: 22 | PhpBrowser: 23 | # PLEASE ADJUST IT TO THE ACTUAL ENTRY POINT WITHOUT PATH INFO 24 | url: http://localhost:8080 25 | # WebDriver: 26 | # url: http://localhost:8080 27 | # browser: firefox 28 | # restart: true 29 | -------------------------------------------------------------------------------- /tests/codeception/bin/yii: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | [ 21 | 'fixture' => [ 22 | 'class' => 'yii\faker\FixtureController', 23 | 'fixtureDataPath' => '@tests/codeception/common/fixtures/data', 24 | 'templatePath' => '@tests/codeception/common/templates/fixtures', 25 | 'namespace' => 'tests\codeception\common\fixtures', 26 | ], 27 | ], 28 | ] 29 | ); 30 | 31 | $application = new yii\console\Application($config); 32 | $exitCode = $application->run(); 33 | exit($exitCode); 34 | -------------------------------------------------------------------------------- /console/migrations/m130524_201442_init.php: -------------------------------------------------------------------------------- 1 | db->driverName === 'mysql') { 12 | // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci 13 | $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; 14 | } 15 | 16 | $this->createTable('{{%user}}', [ 17 | 'id' => Schema::TYPE_PK, 18 | 'username' => Schema::TYPE_STRING . ' NOT NULL', 19 | 'auth_key' => Schema::TYPE_STRING . '(32) NOT NULL', 20 | 'password_hash' => Schema::TYPE_STRING . ' NOT NULL', 21 | 'password_reset_token' => Schema::TYPE_STRING, 22 | 'email' => Schema::TYPE_STRING . ' NOT NULL', 23 | 24 | 'status' => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 10', 25 | 'created_at' => Schema::TYPE_INTEGER . ' NOT NULL', 26 | 'updated_at' => Schema::TYPE_INTEGER . ' NOT NULL', 27 | ], $tableOptions); 28 | } 29 | 30 | public function down() 31 | { 32 | $this->dropTable('{{%user}}'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tests/codeception/frontend/unit/models/ResetPasswordFormTest.php: -------------------------------------------------------------------------------- 1 | user[0]['password_reset_token']); 31 | expect('password should be resetted', $form->resetPassword())->true(); 32 | } 33 | 34 | public function fixtures() 35 | { 36 | return [ 37 | 'user' => [ 38 | 'class' => UserFixture::className(), 39 | 'dataFile' => '@tests/codeception/frontend/unit/fixtures/data/models/user.php' 40 | ], 41 | ]; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /tests/codeception/frontend/_bootstrap.php: -------------------------------------------------------------------------------- 1 | 150], 28 | 29 | // 30 | ['adminMail', 'required'], 31 | ['adminMail', 'email'], 32 | 33 | // Application Backend Theme 34 | ['appBackendTheme', 'required'], 35 | 36 | // Application Frontend Theme 37 | ['appFrontendTheme', 'required'], 38 | 39 | // Cache Class 40 | ['cacheClass', 'required'], 41 | ['cacheClass', 'string', 'max' => 128], 42 | 43 | // Application Tour 44 | ['appTour', 'boolean'] 45 | ]; 46 | } 47 | 48 | public function attributeLabels() 49 | { 50 | return [ 51 | 'appName' => 'Application Name', 52 | 'appFrontendTheme' => 'Frontend Theme', 53 | 'appBackendTheme' => 'Backend Theme', 54 | 'cacheClass' => 'Cache Class', 55 | 'appTour' => 'Show introduction tour for new users' 56 | ]; 57 | } 58 | } -------------------------------------------------------------------------------- /tests/codeception/backend/_bootstrap.php: -------------------------------------------------------------------------------- 1 | [ 19 | 'class' => AccessControl::className(), 20 | 'rules' => [ 21 | [ 22 | 'actions' => ['index', 'error'], 23 | 'allow' => TRUE, 24 | 'roles' => ['@'], 25 | ], 26 | ], 27 | ], 28 | ]; 29 | } 30 | 31 | /** 32 | * @inheritdoc 33 | */ 34 | public function actions() 35 | { 36 | return [ 37 | 'error' => [ 38 | 'class' => ErrorAction::className(), 39 | ], 40 | ]; 41 | } 42 | 43 | public function beforeAction($action) 44 | { 45 | // Verifies application is installed properly 46 | if (!Yii::$app->params[Enum::APP_INSTALLED]) { 47 | return $this->redirect(Yii::$app->urlManager->createUrl('//installer/install/index')); 48 | } 49 | 50 | return parent::beforeAction($action); 51 | } 52 | 53 | /** 54 | * @return string|\yii\web\Response 55 | */ 56 | public function actionIndex() 57 | { 58 | return $this->render('index'); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /backend/models/MailFormSetting.php: -------------------------------------------------------------------------------- 1 | 255], 28 | 29 | // Username 30 | ['mailUsername', 'required'], 31 | ['mailUsername', 'string', 'max' => 255], 32 | 33 | // Password 34 | ['mailPassword', 'required'], 35 | ['mailPassword', 'string', 'max' => 255], 36 | 37 | // Port 38 | ['mailPort', 'required'], 39 | ['mailPort', 'integer'], 40 | 41 | // Encryption 42 | ['mailEncryption', 'string', 'max' => 10], 43 | 44 | // Use Transport 45 | ['mailUseTransport', 'boolean'] 46 | ]; 47 | } 48 | 49 | public function attributeLabels() 50 | { 51 | return [ 52 | 'mailHost' => 'Host', 53 | 'mailUsername' => 'Username', 54 | 'mailPassword' => 'Password', 55 | 'mailPort' => 'Port', 56 | 'mailEncryption' => 'Encryption', 57 | 'mailUseTransport' => 'Use Transport' 58 | ]; 59 | } 60 | } -------------------------------------------------------------------------------- /frontend/views/site/contact.php: -------------------------------------------------------------------------------- 1 | title = 'Contact'; 11 | $this->params['breadcrumbs'][] = $this->title; 12 | ?> 13 |
14 |

title) ?>

15 | 16 |

17 | If you have business inquiries or other questions, please fill out the following form to contact us. Thank you. 18 |

19 | 20 |
21 |
22 | 'contact-form']); ?> 23 | field($model, 'name') ?> 24 | field($model, 'email') ?> 25 | field($model, 'subject') ?> 26 | field($model, 'body')->textArea(['rows' => 6]) ?> 27 | field($model, 'verifyCode')->widget(Captcha::className(), [ 28 | 'template' => '
{image}
{input}
', 29 | ]) ?> 30 |
31 | 'btn btn-primary', 'name' => 'contact-button']) ?> 32 |
33 | 34 |
35 |
36 | 37 |
38 | -------------------------------------------------------------------------------- /backend/views/layouts/nav.php: -------------------------------------------------------------------------------- 1 | Yii::$app->config->get(Enum::APP_NAME), 16 | 'brandUrl' => Yii::$app->homeUrl, 17 | 'options' => [ 18 | 'class' => 'navbar-inverse navbar-fixed-top', 19 | ], 20 | ]); 21 | if (Yii::$app->user->isGuest) { 22 | $menuItems = [ 23 | ['label' => 'Login', 'url' => ['/user/auth/login']] 24 | ]; 25 | } else { 26 | $menuItems = [ 27 | ['label' => 'Home', 'url' => ['/site/index']], 28 | ['label' => 'Admin Panel', 'url' => ['/admin/index'], 'visible' => 29 | Yii::$app->user->identity->isAdmin], 30 | [ 31 | 'label' => Profile::findOne(['uid' => Yii::$app->user->getId()]) 32 | ['name_first'] ?: Yii::$app->user->identity->username, 33 | 'items' => [ 34 | ['label' => 'Account Settings', 'url' => ['/user/account/profile']], 35 | ['label' => 'Logout', 'url' => ['/user/auth/logout'], 'linkOptions' => ['data-method' => 'post']] 36 | ] 37 | ] 38 | ]; 39 | } 40 | 41 | echo Nav::widget([ 42 | 'options' => ['class' => 'navbar-nav navbar-right'], 43 | 'items' => $menuItems, 44 | ]); 45 | NavBar::end(); -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The Yii framework is free software. It is released under the terms of the following BSD License. 2 | 3 | Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com) All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | Neither the name of Yii Software LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 11 | -------------------------------------------------------------------------------- /frontend/models/ContactForm.php: -------------------------------------------------------------------------------- 1 | 'Verification Code', 41 | ]; 42 | } 43 | 44 | /** 45 | * Sends an email to the specified email address using the information collected by this model. 46 | * 47 | * @param string $email the target email address 48 | * @return boolean whether the email was sent 49 | */ 50 | public function sendEmail($email) 51 | { 52 | return Yii::$app->mailer->compose() 53 | ->setTo($email) 54 | ->setFrom([$this->email => $this->name]) 55 | ->setSubject($this->subject) 56 | ->setTextBody($this->body) 57 | ->send(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /frontend/controllers/SiteController.php: -------------------------------------------------------------------------------- 1 | [ 20 | 'class' => 'yii\web\ErrorAction', 21 | ], 22 | 'captcha' => [ 23 | 'class' => 'yii\captcha\CaptchaAction', 24 | 'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, 25 | ], 26 | ]; 27 | } 28 | 29 | public function actionIndex() 30 | { 31 | return $this->render('index'); 32 | } 33 | 34 | public function actionContact() 35 | { 36 | $model = new ContactForm(); 37 | if ($model->load(Yii::$app->request->post()) && $model->validate()) { 38 | if ($model->sendEmail(Yii::$app->params['adminEmail'])) { 39 | Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.'); 40 | } else { 41 | Yii::$app->session->setFlash('error', 'There was an error sending email.'); 42 | } 43 | 44 | return $this->refresh(); 45 | } else { 46 | return $this->render('contact', [ 47 | 'model' => $model, 48 | ]); 49 | } 50 | } 51 | 52 | public function actionAbout() 53 | { 54 | return $this->render('about'); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /backend/views/admin/setting/self-test.php: -------------------------------------------------------------------------------- 1 | title = 'Self Test - ' . Yii::$app->name; 16 | ?> 17 | 18 |
19 |
Self-Test
20 | 21 |
22 |

Checking name ?> software prerequisites

23 |
24 | 25 |
26 |
    27 | 29 |
  • 30 | 32 | 33 | 36 | 37 | 40 | 41 | 43 | 44 | 45 | 46 | 47 | (Hint: ) 48 | 49 |
  • 50 | 52 |
53 |
54 | 55 |
56 | 57 |
58 | Database Updated! 59 |
60 | 61 | ' . 'Re-Run Tests', ['//admin/setting/self-test'], ['class' => 'btn 62 | btn-info']) ?> 63 |
64 |
-------------------------------------------------------------------------------- /tests/codeception/frontend/acceptance/ContactCept.php: -------------------------------------------------------------------------------- 1 | wantTo('ensure that contact works'); 7 | 8 | $contactPage = ContactPage::openBy($I); 9 | 10 | $I->see('Contact', 'h1'); 11 | 12 | $I->amGoingTo('submit contact form with no data'); 13 | $contactPage->submit([]); 14 | $I->expectTo('see validations errors'); 15 | $I->see('Contact', 'h1'); 16 | $I->see('Name cannot be blank', '.help-block'); 17 | $I->see('Email cannot be blank', '.help-block'); 18 | $I->see('Subject cannot be blank', '.help-block'); 19 | $I->see('Body cannot be blank', '.help-block'); 20 | $I->see('The verification code is incorrect', '.help-block'); 21 | 22 | $I->amGoingTo('submit contact form with not correct email'); 23 | $contactPage->submit([ 24 | 'name' => 'tester', 25 | 'email' => 'tester.email', 26 | 'subject' => 'test subject', 27 | 'body' => 'test content', 28 | 'verifyCode' => 'testme', 29 | ]); 30 | $I->expectTo('see that email adress is wrong'); 31 | $I->dontSee('Name cannot be blank', '.help-block'); 32 | $I->see('Email is not a valid email address.', '.help-block'); 33 | $I->dontSee('Subject cannot be blank', '.help-block'); 34 | $I->dontSee('Body cannot be blank', '.help-block'); 35 | $I->dontSee('The verification code is incorrect', '.help-block'); 36 | 37 | $I->amGoingTo('submit contact form with correct data'); 38 | $contactPage->submit([ 39 | 'name' => 'tester', 40 | 'email' => 'tester@example.com', 41 | 'subject' => 'test subject', 42 | 'body' => 'test content', 43 | 'verifyCode' => 'testme', 44 | ]); 45 | $I->see('Thank you for contacting us. We will respond to you as soon as possible.'); 46 | -------------------------------------------------------------------------------- /tests/codeception/frontend/functional/ContactCept.php: -------------------------------------------------------------------------------- 1 | wantTo('ensure that contact works'); 7 | 8 | $contactPage = ContactPage::openBy($I); 9 | 10 | $I->see('Contact', 'h1'); 11 | 12 | $I->amGoingTo('submit contact form with no data'); 13 | $contactPage->submit([]); 14 | $I->expectTo('see validations errors'); 15 | $I->see('Contact', 'h1'); 16 | $I->see('Name cannot be blank', '.help-block'); 17 | $I->see('Email cannot be blank', '.help-block'); 18 | $I->see('Subject cannot be blank', '.help-block'); 19 | $I->see('Body cannot be blank', '.help-block'); 20 | $I->see('The verification code is incorrect', '.help-block'); 21 | 22 | $I->amGoingTo('submit contact form with not correct email'); 23 | $contactPage->submit([ 24 | 'name' => 'tester', 25 | 'email' => 'tester.email', 26 | 'subject' => 'test subject', 27 | 'body' => 'test content', 28 | 'verifyCode' => 'testme', 29 | ]); 30 | $I->expectTo('see that email adress is wrong'); 31 | $I->dontSee('Name cannot be blank', '.help-block'); 32 | $I->see('Email is not a valid email address.', '.help-block'); 33 | $I->dontSee('Subject cannot be blank', '.help-block'); 34 | $I->dontSee('Body cannot be blank', '.help-block'); 35 | $I->dontSee('The verification code is incorrect', '.help-block'); 36 | 37 | $I->amGoingTo('submit contact form with correct data'); 38 | $contactPage->submit([ 39 | 'name' => 'tester', 40 | 'email' => 'tester@example.com', 41 | 'subject' => 'test subject', 42 | 'body' => 'test content', 43 | 'verifyCode' => 'testme', 44 | ]); 45 | $I->see('Thank you for contacting us. We will respond to you as soon as possible.'); 46 | -------------------------------------------------------------------------------- /tests/codeception/frontend/unit/models/SignupFormTest.php: -------------------------------------------------------------------------------- 1 | 'some_username', 19 | 'email' => 'some_email@example.com', 20 | 'password' => 'some_password', 21 | ]); 22 | 23 | $user = $model->signup(); 24 | 25 | $this->assertInstanceOf('common\models\User', $user, 'user should be valid'); 26 | 27 | expect('username should be correct', $user->username)->equals('some_username'); 28 | expect('email should be correct', $user->email)->equals('some_email@example.com'); 29 | expect('password should be correct', $user->validatePassword('some_password'))->true(); 30 | } 31 | 32 | public function testNotCorrectSignup() 33 | { 34 | $model = new SignupForm([ 35 | 'username' => 'troy.becker', 36 | 'email' => 'nicolas.dianna@hotmail.com', 37 | 'password' => 'some_password', 38 | ]); 39 | 40 | expect('username and email are in use, user should not be created', $model->signup())->null(); 41 | } 42 | 43 | public function fixtures() 44 | { 45 | return [ 46 | 'user' => [ 47 | 'class' => UserFixture::className(), 48 | 'dataFile' => '@tests/codeception/frontend/unit/fixtures/data/models/user.php', 49 | ], 50 | ]; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "abhi1693/yii2-app-advanced-startup-kit", 3 | "description": "Yii 2 Practical Advanced Application Template (Startup Kit)", 4 | "keywords": [ 5 | "yii2", 6 | "framework", 7 | "practical", 8 | "application template", 9 | "advanced" 10 | ], 11 | "type": "project", 12 | "license": "MIT License", 13 | "authors": [ 14 | { 15 | "name": "Abhimanyu Saharan", 16 | "email": "desk.abhimanyu@gmail.com", 17 | "homepage": "http://abhi1693.github.io/yii2-app-advanced-startup-kit", 18 | "role": "Developer" 19 | } 20 | ], 21 | "support": { 22 | "issues": "https://github.com/abhi1693/yii2-app-advanced-startup-kit/issues?state=open", 23 | "source": "https://github.com/abhi1693/yii2-app-advanced-startup-kit/" 24 | }, 25 | "minimum-stability": "dev", 26 | "require": { 27 | "php": ">=5.4.0", 28 | "yiisoft/yii2": "*", 29 | "yiisoft/yii2-bootstrap": "*", 30 | "yiisoft/yii2-swiftmailer": "*", 31 | "abhi1693/yii2-user": "*", 32 | "abhi1693/yii2-config": "1.0.0", 33 | "abhi1693/yii2-installer": "*", 34 | "abhi1693/yii2-system-info": "*", 35 | "raoul2000/yii2-bootswatch-asset": "*", 36 | "kartik-v/yii2-widget-sidenav": "*", 37 | "kartik-v/yii2-widget-alert": "*", 38 | "himiklab/yii2-recaptcha-widget": "*", 39 | "wbraganca/yii2-dynamicform": "*" 40 | }, 41 | "require-dev": { 42 | "yiisoft/yii2-codeception": "*", 43 | "yiisoft/yii2-debug": "*", 44 | "yiisoft/yii2-gii": "*", 45 | "yiisoft/yii2-faker": "*" 46 | }, 47 | "config": { 48 | "process-timeout": 1800 49 | }, 50 | "extra": { 51 | "asset-installer-paths": { 52 | "npm-asset-library": "vendor/npm", 53 | "bower-asset-library": "vendor/bower" 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /frontend/assets/css/site.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | height: 100%; 4 | } 5 | 6 | .wrap { 7 | min-height: 100%; 8 | height: auto; 9 | margin: 0 auto -60px; 10 | padding: 0 0 60px; 11 | } 12 | 13 | .wrap > .container { 14 | padding: 70px 15px 20px; 15 | } 16 | 17 | .footer { 18 | height: 60px; 19 | background-color: #f5f5f5; 20 | border-top: 1px solid #ddd; 21 | padding-top: 20px; 22 | } 23 | 24 | .jumbotron { 25 | text-align: center; 26 | background-color: transparent; 27 | } 28 | 29 | .jumbotron .btn { 30 | font-size: 21px; 31 | padding: 14px 24px; 32 | } 33 | 34 | .not-set { 35 | color: #c55; 36 | font-style: italic; 37 | } 38 | 39 | /* add sorting icons to gridview sort links */ 40 | a.asc:after, a.desc:after { 41 | position: relative; 42 | top: 1px; 43 | display: inline-block; 44 | font-family: 'Glyphicons Halflings'; 45 | font-style: normal; 46 | font-weight: normal; 47 | line-height: 1; 48 | padding-left: 5px; 49 | } 50 | 51 | a.asc:after { 52 | content: /*"\e113"*/ "\e151"; 53 | } 54 | 55 | a.desc:after { 56 | content: /*"\e114"*/ "\e152"; 57 | } 58 | 59 | .sort-numerical a.asc:after { 60 | content: "\e153"; 61 | } 62 | 63 | .sort-numerical a.desc:after { 64 | content: "\e154"; 65 | } 66 | 67 | .sort-ordinal a.asc:after { 68 | content: "\e155"; 69 | } 70 | 71 | .sort-ordinal a.desc:after { 72 | content: "\e156"; 73 | } 74 | 75 | .grid-view th { 76 | white-space: nowrap; 77 | } 78 | 79 | .hint-block { 80 | display: block; 81 | margin-top: 5px; 82 | color: #999; 83 | } 84 | 85 | .error-summary { 86 | color: #a94442; 87 | background: #fdf7f7; 88 | border-left: 3px solid #eed3d7; 89 | padding: 10px 20px; 90 | margin: 0 0 15px 0; 91 | } 92 | -------------------------------------------------------------------------------- /backend/assets_b/css/site.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | height: 100%; 4 | } 5 | 6 | .wrap { 7 | min-height: 100%; 8 | height: auto; 9 | margin: 0 auto -60px; 10 | padding: 0 0 60px; 11 | } 12 | 13 | .wrap > .container { 14 | padding: 70px 15px 20px; 15 | } 16 | 17 | .footer { 18 | height: 60px; 19 | background-color: #f5f5f5; 20 | border-top: 1px solid #ddd; 21 | padding-top: 20px; 22 | } 23 | 24 | .jumbotron { 25 | text-align: center; 26 | background-color: transparent; 27 | } 28 | 29 | .jumbotron .btn { 30 | font-size: 21px; 31 | padding: 14px 24px; 32 | } 33 | 34 | .not-set { 35 | color: #c55; 36 | font-style: italic; 37 | } 38 | 39 | /* add sorting icons to gridview sort links */ 40 | a.asc:after, a.desc:after { 41 | position: relative; 42 | top: 1px; 43 | display: inline-block; 44 | font-family: 'Glyphicons Halflings'; 45 | font-style: normal; 46 | font-weight: normal; 47 | line-height: 1; 48 | padding-left: 5px; 49 | } 50 | 51 | a.asc:after { 52 | content: /*"\e113"*/ "\e151"; 53 | } 54 | 55 | a.desc:after { 56 | content: /*"\e114"*/ "\e152"; 57 | } 58 | 59 | .sort-numerical a.asc:after { 60 | content: "\e153"; 61 | } 62 | 63 | .sort-numerical a.desc:after { 64 | content: "\e154"; 65 | } 66 | 67 | .sort-ordinal a.asc:after { 68 | content: "\e155"; 69 | } 70 | 71 | .sort-ordinal a.desc:after { 72 | content: "\e156"; 73 | } 74 | 75 | .grid-view th { 76 | white-space: nowrap; 77 | } 78 | 79 | .hint-block { 80 | display: block; 81 | margin-top: 5px; 82 | color: #999; 83 | } 84 | 85 | .error-summary { 86 | color: #a94442; 87 | background: #fdf7f7; 88 | border-left: 3px solid #eed3d7; 89 | padding: 10px 20px; 90 | margin: 0 0 15px 0; 91 | } 92 | -------------------------------------------------------------------------------- /.htaccess: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------- 2 | # Adds some security for the Apache server configuration for use with 3 | # yii2-app-practical template. 4 | # @author Kartik Visweswaran 5 | # @see http://demos.krajee.com/app-practical 6 | # ---------------------------------------------------------------------- 7 | 8 | # "-Indexes" will have Apache block users from browsing folders without a default document 9 | # Usually you should leave this activated, because you shouldn't allow everybody to surf through 10 | # every folder on your server (which includes rather private places like CMS system folders). 11 | 12 | Options -Indexes 13 | 14 | 15 | 16 | # Block access to "hidden" directories whose names begin with a period. This 17 | # includes directories used by version control systems such as Subversion or Git. 18 | 19 | RewriteCond %{SCRIPT_FILENAME} -d 20 | RewriteCond %{SCRIPT_FILENAME} -f 21 | RewriteRule "(^|/)\." - [F] 22 | 23 | 24 | 25 | # Block access to backup and source files 26 | # This files may be left by some text/html editors and 27 | # pose a great security danger, when someone can access them 28 | 29 | Order allow,deny 30 | Deny from all 31 | Satisfy All 32 | 33 | 34 | # Increase cookie security 35 | 36 | php_value session.cookie_httponly true 37 | 38 | 39 | # Settings to hide index.php and ensure pretty urls 40 | RewriteEngine on 41 | 42 | # if a directory or a file exists, use it directly 43 | RewriteCond %{REQUEST_FILENAME} !-f 44 | RewriteCond %{REQUEST_FILENAME} !-d 45 | 46 | # otherwise forward it to index.php 47 | RewriteRule . index.php -------------------------------------------------------------------------------- /backend/.htaccess: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------- 2 | # Adds some security for the Apache server configuration for use with 3 | # yii2-app-practical template. 4 | # @author Kartik Visweswaran 5 | # @see http://demos.krajee.com/app-practical 6 | # ---------------------------------------------------------------------- 7 | 8 | # "-Indexes" will have Apache block users from browsing folders without a default document 9 | # Usually you should leave this activated, because you shouldn't allow everybody to surf through 10 | # every folder on your server (which includes rather private places like CMS system folders). 11 | 12 | Options -Indexes 13 | 14 | 15 | 16 | # Block access to "hidden" directories whose names begin with a period. This 17 | # includes directories used by version control systems such as Subversion or Git. 18 | 19 | RewriteCond %{SCRIPT_FILENAME} -d 20 | RewriteCond %{SCRIPT_FILENAME} -f 21 | RewriteRule "(^|/)\." - [F] 22 | 23 | 24 | 25 | # Block access to backup and source files 26 | # This files may be left by some text/html editors and 27 | # pose a great security danger, when someone can access them 28 | 29 | Order allow,deny 30 | Deny from all 31 | Satisfy All 32 | 33 | 34 | # Increase cookie security 35 | 36 | php_value session.cookie_httponly true 37 | 38 | 39 | # Settings to hide index.php and ensure pretty urls 40 | RewriteEngine on 41 | 42 | # if a directory or a file exists, use it directly 43 | RewriteCond %{REQUEST_FILENAME} !-f 44 | RewriteCond %{REQUEST_FILENAME} !-d 45 | 46 | # otherwise forward it to index.php 47 | RewriteRule . index.php -------------------------------------------------------------------------------- /environments/dev/.htaccess: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------- 2 | # Adds some security for the Apache server configuration for use with 3 | # yii2-app-practical template. 4 | # @author Kartik Visweswaran 5 | # @see http://demos.krajee.com/app-practical 6 | # ---------------------------------------------------------------------- 7 | 8 | # "-Indexes" will have Apache block users from browsing folders without a default document 9 | # Usually you should leave this activated, because you shouldn't allow everybody to surf through 10 | # every folder on your server (which includes rather private places like CMS system folders). 11 | 12 | Options -Indexes 13 | 14 | 15 | 16 | # Block access to "hidden" directories whose names begin with a period. This 17 | # includes directories used by version control systems such as Subversion or Git. 18 | 19 | RewriteCond %{SCRIPT_FILENAME} -d 20 | RewriteCond %{SCRIPT_FILENAME} -f 21 | RewriteRule "(^|/)\." - [F] 22 | 23 | 24 | 25 | # Block access to backup and source files 26 | # This files may be left by some text/html editors and 27 | # pose a great security danger, when someone can access them 28 | 29 | Order allow,deny 30 | Deny from all 31 | Satisfy All 32 | 33 | 34 | # Increase cookie security 35 | 36 | php_value session.cookie_httponly true 37 | 38 | 39 | # Settings to hide index.php and ensure pretty urls 40 | RewriteEngine on 41 | 42 | # if a directory or a file exists, use it directly 43 | RewriteCond %{REQUEST_FILENAME} !-f 44 | RewriteCond %{REQUEST_FILENAME} !-d 45 | 46 | # otherwise forward it to index.php 47 | RewriteRule . index.php -------------------------------------------------------------------------------- /environments/prod/.htaccess: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------- 2 | # Adds some security for the Apache server configuration for use with 3 | # yii2-app-practical template. 4 | # @author Kartik Visweswaran 5 | # @see http://demos.krajee.com/app-practical 6 | # ---------------------------------------------------------------------- 7 | 8 | # "-Indexes" will have Apache block users from browsing folders without a default document 9 | # Usually you should leave this activated, because you shouldn't allow everybody to surf through 10 | # every folder on your server (which includes rather private places like CMS system folders). 11 | 12 | Options -Indexes 13 | 14 | 15 | 16 | # Block access to "hidden" directories whose names begin with a period. This 17 | # includes directories used by version control systems such as Subversion or Git. 18 | 19 | RewriteCond %{SCRIPT_FILENAME} -d 20 | RewriteCond %{SCRIPT_FILENAME} -f 21 | RewriteRule "(^|/)\." - [F] 22 | 23 | 24 | 25 | # Block access to backup and source files 26 | # This files may be left by some text/html editors and 27 | # pose a great security danger, when someone can access them 28 | 29 | Order allow,deny 30 | Deny from all 31 | Satisfy All 32 | 33 | 34 | # Increase cookie security 35 | 36 | php_value session.cookie_httponly true 37 | 38 | 39 | # Settings to hide index.php and ensure pretty urls 40 | RewriteEngine on 41 | 42 | # if a directory or a file exists, use it directly 43 | RewriteCond %{REQUEST_FILENAME} !-f 44 | RewriteCond %{REQUEST_FILENAME} !-d 45 | 46 | # otherwise forward it to index.php 47 | RewriteRule . index.php -------------------------------------------------------------------------------- /environments/dev/backend/.htaccess: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------- 2 | # Adds some security for the Apache server configuration for use with 3 | # yii2-app-practical template. 4 | # @author Kartik Visweswaran 5 | # @see http://demos.krajee.com/app-practical 6 | # ---------------------------------------------------------------------- 7 | 8 | # "-Indexes" will have Apache block users from browsing folders without a default document 9 | # Usually you should leave this activated, because you shouldn't allow everybody to surf through 10 | # every folder on your server (which includes rather private places like CMS system folders). 11 | 12 | Options -Indexes 13 | 14 | 15 | 16 | # Block access to "hidden" directories whose names begin with a period. This 17 | # includes directories used by version control systems such as Subversion or Git. 18 | 19 | RewriteCond %{SCRIPT_FILENAME} -d 20 | RewriteCond %{SCRIPT_FILENAME} -f 21 | RewriteRule "(^|/)\." - [F] 22 | 23 | 24 | 25 | # Block access to backup and source files 26 | # This files may be left by some text/html editors and 27 | # pose a great security danger, when someone can access them 28 | 29 | Order allow,deny 30 | Deny from all 31 | Satisfy All 32 | 33 | 34 | # Increase cookie security 35 | 36 | php_value session.cookie_httponly true 37 | 38 | 39 | # Settings to hide index.php and ensure pretty urls 40 | RewriteEngine on 41 | 42 | # if a directory or a file exists, use it directly 43 | RewriteCond %{REQUEST_FILENAME} !-f 44 | RewriteCond %{REQUEST_FILENAME} !-d 45 | 46 | # otherwise forward it to index.php 47 | RewriteRule . index.php -------------------------------------------------------------------------------- /environments/prod/backend/.htaccess: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------- 2 | # Adds some security for the Apache server configuration for use with 3 | # yii2-app-practical template. 4 | # @author Kartik Visweswaran 5 | # @see http://demos.krajee.com/app-practical 6 | # ---------------------------------------------------------------------- 7 | 8 | # "-Indexes" will have Apache block users from browsing folders without a default document 9 | # Usually you should leave this activated, because you shouldn't allow everybody to surf through 10 | # every folder on your server (which includes rather private places like CMS system folders). 11 | 12 | Options -Indexes 13 | 14 | 15 | 16 | # Block access to "hidden" directories whose names begin with a period. This 17 | # includes directories used by version control systems such as Subversion or Git. 18 | 19 | RewriteCond %{SCRIPT_FILENAME} -d 20 | RewriteCond %{SCRIPT_FILENAME} -f 21 | RewriteRule "(^|/)\." - [F] 22 | 23 | 24 | 25 | # Block access to backup and source files 26 | # This files may be left by some text/html editors and 27 | # pose a great security danger, when someone can access them 28 | 29 | Order allow,deny 30 | Deny from all 31 | Satisfy All 32 | 33 | 34 | # Increase cookie security 35 | 36 | php_value session.cookie_httponly true 37 | 38 | 39 | # Settings to hide index.php and ensure pretty urls 40 | RewriteEngine on 41 | 42 | # if a directory or a file exists, use it directly 43 | RewriteCond %{REQUEST_FILENAME} !-f 44 | RewriteCond %{REQUEST_FILENAME} !-d 45 | 46 | # otherwise forward it to index.php 47 | RewriteRule . index.php -------------------------------------------------------------------------------- /tests/codeception/common/_support/FixtureHelper.php: -------------------------------------------------------------------------------- 1 | loadFixtures(); 38 | } 39 | 40 | /** 41 | * Method is called after all suite tests run 42 | */ 43 | public function _afterSuite() 44 | { 45 | $this->unloadFixtures(); 46 | } 47 | 48 | /** 49 | * @inheritdoc 50 | */ 51 | public function fixtures() 52 | { 53 | return [ 54 | 'user' => [ 55 | 'class' => UserFixture::className(), 56 | 'dataFile' => '@tests/codeception/common/fixtures/data/init_login.php', 57 | ], 58 | ]; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /tests/README.md: -------------------------------------------------------------------------------- 1 | This directory contains various tests for the advanced applications. 2 | 3 | Tests in `codeception` directory are developed with [Codeception PHP Testing Framework](http://codeception.com/). 4 | 5 | After creating and setting up the advanced application, follow these steps to prepare for the tests: 6 | 7 | 1. Install Codeception if it's not yet installed: 8 | 9 | ``` 10 | composer global require "codeception/codeception=2.0.*" "codeception/specify=*" "codeception/verify=*" 11 | ``` 12 | 13 | If you've never used Composer for global packages run `composer global status`. It should output: 14 | 15 | ``` 16 | Changed current directory to 17 | ``` 18 | 19 | Then add `/vendor/bin` to you `PATH` environment variable. Now you're able to use `codecept` from command 20 | line globally. 21 | 22 | 2. Install faker extension by running the following from template root directory where `composer.json` is: 23 | 24 | ``` 25 | composer require --dev yiisoft/yii2-faker:* 26 | ``` 27 | 28 | 3. Create `yii2_advanced_tests` database then update it by applying migrations: 29 | 30 | ``` 31 | codeception/bin/yii migrate 32 | ``` 33 | 34 | 4. In order to be able to run acceptance tests you need to start a webserver. The simplest way is to use PHP built in 35 | webserver. In the root directory where `common`, `frontend` etc. are execute the following: 36 | 37 | ``` 38 | php -S localhost:8080 39 | ``` 40 | 41 | 5. Now you can run the tests with the following commands, assuming you are in the `tests/codeception` directory: 42 | 43 | ``` 44 | # frontend tests 45 | cd frontend 46 | codecept build 47 | codecept run 48 | 49 | # backend tests 50 | 51 | cd backend 52 | codecept build 53 | codecept run 54 | 55 | # etc. 56 | ``` 57 | 58 | If you already have run `codecept build` for each application, you can skip that step and run all tests by a single `codecept run`. 59 | -------------------------------------------------------------------------------- /environments/index.php: -------------------------------------------------------------------------------- 1 | [ 11 | * 'path' => 'directory storing the local files', 12 | * 'setWritable' => [ 13 | * // list of directories that should be set writable 14 | * ], 15 | * 'setExecutable' => [ 16 | * // list of directories that should be set executable 17 | * ], 18 | * 'setCookieValidationKey' => [ 19 | * // list of config files that need to be inserted with automatically generated cookie validation keys 20 | * ], 21 | * 'createSymlink' => [ 22 | * // list of symlinks to be created. Keys are symlinks, and values are the targets. 23 | * ], 24 | * ], 25 | * ]; 26 | * ``` 27 | */ 28 | return [ 29 | 'Development' => [ 30 | 'path' => 'dev', 31 | 'setWritable' => [ 32 | 'backend/runtime', 33 | 'backend/assets', 34 | 'frontend/runtime', 35 | 'assets', 36 | ], 37 | 'setExecutable' => [ 38 | 'yii', 39 | ], 40 | 'setCookieValidationKey' => [ 41 | 'backend/config/main-local.php', 42 | 'frontend/config/main-local.php', 43 | ], 44 | ], 45 | 'Production' => [ 46 | 'path' => 'prod', 47 | 'setWritable' => [ 48 | 'backend/runtime', 49 | 'backend/assets', 50 | 'frontend/runtime', 51 | 'assets', 52 | ], 53 | 'setExecutable' => [ 54 | 'yii', 55 | ], 56 | 'setCookieValidationKey' => [ 57 | 'backend/config/main-local.php', 58 | 'frontend/config/main-local.php', 59 | ], 60 | ], 61 | ]; 62 | -------------------------------------------------------------------------------- /tests/codeception/frontend/unit/models/ContactFormTest.php: -------------------------------------------------------------------------------- 1 | mailer->fileTransportCallback = function ($mailer, $message) { 18 | return 'testing_message.eml'; 19 | }; 20 | } 21 | 22 | protected function tearDown() 23 | { 24 | unlink($this->getMessageFile()); 25 | parent::tearDown(); 26 | } 27 | 28 | public function testContact() 29 | { 30 | $model = new ContactForm(); 31 | 32 | $model->attributes = [ 33 | 'name' => 'Tester', 34 | 'email' => 'tester@example.com', 35 | 'subject' => 'very important letter subject', 36 | 'body' => 'body of current message', 37 | ]; 38 | 39 | $model->sendEmail('admin@example.com'); 40 | 41 | $this->specify('email should be send', function () { 42 | expect('email file should exist', file_exists($this->getMessageFile()))->true(); 43 | }); 44 | 45 | $this->specify('message should contain correct data', function () use ($model) { 46 | $emailMessage = file_get_contents($this->getMessageFile()); 47 | 48 | expect('email should contain user name', $emailMessage)->contains($model->name); 49 | expect('email should contain sender email', $emailMessage)->contains($model->email); 50 | expect('email should contain subject', $emailMessage)->contains($model->subject); 51 | expect('email should contain body', $emailMessage)->contains($model->body); 52 | }); 53 | } 54 | 55 | private function getMessageFile() 56 | { 57 | return Yii::getAlias(Yii::$app->mailer->fileTransportPath) . '/testing_message.eml'; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /backend/views/layouts/admin.php: -------------------------------------------------------------------------------- 1 | config->get(Enum::APP_BACKEND_THEME, 'yeti'); 19 | AppAsset::register($this); 20 | ?> 21 | beginPage() ?> 22 | 23 | 24 | 25 | 26 | 27 | 28 | <?= Html::encode($this->title) ?> 29 | head() ?> 30 | 31 | 32 | beginBody() ?> 33 |
34 | render('nav') ?> 35 | 36 |
37 | isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], 39 | ]) ?> 40 |
41 | user->isGuest && Yii::$app->controller->id != 'account') { ?> 42 |
43 | SideNav::TYPE_DEFAULT, 46 | 'heading' => ' Manage', 47 | 'items' => \backend\controllers\admin\SettingController::getMenuItems() 48 | ]); 49 | ?> 50 |
51 | 52 | 53 |
54 | 55 |
56 |
57 |
58 |
59 | 60 | render('footer') ?> 61 | 62 | endBody() ?> 63 | 64 | 65 | endPage() ?> -------------------------------------------------------------------------------- /frontend/views/layouts/main.php: -------------------------------------------------------------------------------- 1 | config->get(Enum::APP_FRONTEND_THEME, 'readable'); 14 | AppAsset::register($this); 15 | ?> 16 | beginPage() ?> 17 | 18 | 19 | 20 | 21 | 22 | 23 | <?= Html::encode($this->title) ?> 24 | head() ?> 25 | 26 | 27 | beginBody() ?> 28 |
29 | Yii::$app->config->get(Enum::APP_NAME), 32 | 'brandUrl' => Yii::$app->homeUrl, 33 | 'options' => [ 34 | 'class' => 'navbar-inverse navbar-fixed-top', 35 | ], 36 | ]); 37 | $menuItems = [ 38 | ['label' => 'Home', 'url' => ['/site/index']], 39 | ['label' => 'About', 'url' => ['/site/about']], 40 | ['label' => 'Contact', 'url' => ['/site/contact']], 41 | ]; 42 | 43 | echo Nav::widget([ 44 | 'options' => ['class' => 'navbar-nav navbar-right'], 45 | 'items' => $menuItems, 46 | ]); 47 | NavBar::end(); 48 | ?> 49 | 50 |
51 | isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], 53 | ]) ?> 54 | 55 | 56 |
57 |
58 | 59 |
60 |
61 |

© config->get(Enum::APP_NAME) ?>

62 | 63 |

Maintained 64 | By config->get(Enum::ADMIN_EMAIL)) ?>

65 |
66 |
67 | 68 | endBody() ?> 69 | 70 | 71 | endPage() ?> 72 | -------------------------------------------------------------------------------- /backend/views/site/index.php: -------------------------------------------------------------------------------- 1 | title = Yii::$app->config->get(Enum::APP_NAME); 8 | ?> 9 | 10 | 37 | 38 |
39 | 40 |
41 |

Congratulations!

42 | 43 |

You have successfully created your Yii-powered application.

44 | 45 |

Get started with Yii

46 | 47 |
48 | 49 |
50 | 51 | params[Enum::APP_INSTALLED]): ?> 52 | Install Application', ['/backend/installer/install/index'], [ 53 | 'target' => '_blank', 54 | 'class' => 'circle' 55 | ]) ?> 56 | 57 | 58 | Control Panel', ['/admin/index'], [ 59 | 'target' => '_blank', 60 | 'class' => 'circle' 61 | ]) ?> 62 | 63 | 64 | Documentation', 'http://abhi1693.github.io/yii2-app-advanced-startup-kit/', [ 65 | 'target' => '_blank', 66 | 'class' => 'circle' 67 | ]) ?> 68 | 69 |
70 | 71 |
72 | 73 | 74 | 76 | 77 |
78 | 79 |
80 |
81 |
-------------------------------------------------------------------------------- /frontend/views/site/index.php: -------------------------------------------------------------------------------- 1 | title = Yii::$app->config->get(Enum::APP_NAME); 8 | ?> 9 | 10 | 37 | 38 |
39 | 40 |
41 |

Congratulations!

42 | 43 |

You have successfully created your Yii-powered application.

44 | 45 |

Get started with Yii

46 | 47 |
48 | 49 |
50 | 51 | params[Enum::APP_INSTALLED]): ?> 52 | Install Application', ['/backend/installer/install/index'], [ 53 | 'target' => '_blank', 54 | 'class' => 'circle' 55 | ]) ?> 56 | 57 | 58 | Control Panel', ['/backend/'], [ 59 | 'target' => '_blank', 60 | 'class' => 'circle' 61 | ]) ?> 62 | 63 | 64 | Documentation', 'http://abhi1693.github.io/yii2-app-advanced-startup-kit/', [ 65 | 'target' => '_blank', 66 | 'class' => 'circle' 67 | ]) ?> 68 | 69 |
70 | 71 |
72 | 73 | 74 | 76 | 77 |
78 | 79 |
80 |
81 |
82 | -------------------------------------------------------------------------------- /backend/views/admin/setting/database.php: -------------------------------------------------------------------------------- 1 | title = 'Database Settings - ' . Yii::$app->name; 17 | 18 | echo AlertBlock::widget([ 19 | 'delay' => 5000, 20 | 'useSessionFlash' => TRUE 21 | ]); 22 | ?> 23 | 24 |
25 |
Database Setting
26 |
27 | 28 | FALSE, 31 | ]); 32 | ?> 33 | 34 |
35 | field($model, 'hostname')->textInput([ 37 | 'autofocus' => 'on', 38 | 'autocomplete' => 'off', 39 | 'class' => 'form-control' 40 | ])->hint('You should be able to get this info from your web host, if localhost does not work.') ?> 41 |
42 | 43 |
44 | 45 |
46 | field($model, 'username')->textInput([ 48 | 'autocomplete' => 'off', 49 | 'class' => 'form-control' 50 | ])->hint('Your MySQL username') ?> 51 |
52 | 53 |
54 | field($model, 'password')->passwordInput([ 56 | 'class' => 'form-control' 57 | ])->hint('Your MySQL password') ?> 58 |
59 | 60 |
61 | 62 |
63 | field($model, 'database')->textInput([ 65 | 'autocomplete' => 'off', 66 | 'class' => 'form-control' 67 | ])->hint('The name of the database you want to run your application in.') ?> 68 |
69 | 70 |
71 | 72 | 'btn btn-primary']) ?> 73 | 74 | 75 |
76 |
-------------------------------------------------------------------------------- /tests/codeception/frontend/acceptance/SignupCest.php: -------------------------------------------------------------------------------- 1 | 'tester.email@example.com', 27 | 'username' => 'tester', 28 | ]); 29 | } 30 | 31 | /** 32 | * This method is called when test fails. 33 | * @param \Codeception\Event\FailEvent $event 34 | */ 35 | public function _fail($event) 36 | { 37 | } 38 | 39 | /** 40 | * @param \codeception_frontend\AcceptanceTester $I 41 | * @param \Codeception\Scenario $scenario 42 | */ 43 | public function testUserSignup($I, $scenario) 44 | { 45 | $I->wantTo('ensure that signup works'); 46 | 47 | $signupPage = SignupPage::openBy($I); 48 | $I->see('Signup', 'h1'); 49 | $I->see('Please fill out the following fields to signup:'); 50 | 51 | $I->amGoingTo('submit signup form with no data'); 52 | 53 | $signupPage->submit([]); 54 | 55 | $I->expectTo('see validation errors'); 56 | $I->see('Username cannot be blank.', '.help-block'); 57 | $I->see('Email cannot be blank.', '.help-block'); 58 | $I->see('Password cannot be blank.', '.help-block'); 59 | 60 | $I->amGoingTo('submit signup form with not correct email'); 61 | $signupPage->submit([ 62 | 'username' => 'tester', 63 | 'email' => 'tester.email', 64 | 'password' => 'tester_password', 65 | ]); 66 | 67 | $I->expectTo('see that email address is wrong'); 68 | $I->dontSee('Username cannot be blank.', '.help-block'); 69 | $I->dontSee('Password cannot be blank.', '.help-block'); 70 | $I->see('Email is not a valid email address.', '.help-block'); 71 | 72 | $I->amGoingTo('submit signup form with correct email'); 73 | $signupPage->submit([ 74 | 'username' => 'tester', 75 | 'email' => 'tester.email@example.com', 76 | 'password' => 'tester_password', 77 | ]); 78 | 79 | $I->expectTo('see that user logged in'); 80 | $I->seeLink('Logout (tester)'); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /frontend/widgets/Alert.php: -------------------------------------------------------------------------------- 1 | getSession()->setFlash('error', 'This is the message'); 16 | * \Yii::$app->getSession()->setFlash('success', 'This is the message'); 17 | * \Yii::$app->getSession()->setFlash('info', 'This is the message'); 18 | * ``` 19 | * 20 | * Multiple messages could be set as follows: 21 | * 22 | * ```php 23 | * \Yii::$app->getSession()->setFlash('error', ['Error 1', 'Error 2']); 24 | * ``` 25 | * 26 | * @author Kartik Visweswaran 27 | * @author Alexander Makarov 28 | */ 29 | class Alert extends \yii\bootstrap\Widget 30 | { 31 | /** 32 | * @var array the alert types configuration for the flash messages. 33 | * This array is setup as $key => $value, where: 34 | * - $key is the name of the session flash variable 35 | * - $value is the bootstrap alert type (i.e. danger, success, info, warning) 36 | */ 37 | public $alertTypes = [ 38 | 'error' => 'alert-danger', 39 | 'danger' => 'alert-danger', 40 | 'success' => 'alert-success', 41 | 'info' => 'alert-info', 42 | 'warning' => 'alert-warning' 43 | ]; 44 | 45 | /** 46 | * @var array the options for rendering the close button tag. 47 | */ 48 | public $closeButton = []; 49 | 50 | public function init() 51 | { 52 | parent::init(); 53 | 54 | $session = \Yii::$app->getSession(); 55 | $flashes = $session->getAllFlashes(); 56 | $appendCss = isset($this->options['class']) ? ' ' . $this->options['class'] : ''; 57 | 58 | foreach ($flashes as $type => $data) { 59 | if (isset($this->alertTypes[$type])) { 60 | $data = (array) $data; 61 | foreach ($data as $i => $message) { 62 | /* initialize css class for each alert box */ 63 | $this->options['class'] = $this->alertTypes[$type] . $appendCss; 64 | 65 | /* assign unique id to each alert box */ 66 | $this->options['id'] = $this->getId() . '-' . $type . '-' . $i; 67 | 68 | echo \yii\bootstrap\Alert::widget([ 69 | 'body' => $message, 70 | 'closeButton' => $this->closeButton, 71 | 'options' => $this->options, 72 | ]); 73 | } 74 | 75 | $session->removeFlash($type); 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /tests/codeception/frontend/unit/models/PasswordResetRequestFormTest.php: -------------------------------------------------------------------------------- 1 | mailer->fileTransportCallback = function ($mailer, $message) { 21 | return 'testing_message.eml'; 22 | }; 23 | } 24 | 25 | protected function tearDown() 26 | { 27 | @unlink($this->getMessageFile()); 28 | 29 | parent::tearDown(); 30 | } 31 | 32 | public function testSendEmailWrongUser() 33 | { 34 | $this->specify('no user with such email, message should not be send', function () { 35 | 36 | $model = new PasswordResetRequestForm(); 37 | $model->email = 'not-existing-email@example.com'; 38 | 39 | expect('email not send', $model->sendEmail())->false(); 40 | 41 | }); 42 | 43 | $this->specify('user is not active, message should not be send', function () { 44 | 45 | $model = new PasswordResetRequestForm(); 46 | $model->email = $this->user[1]['email']; 47 | 48 | expect('email not send', $model->sendEmail())->false(); 49 | 50 | }); 51 | } 52 | 53 | public function testSendEmailCorrectUser() 54 | { 55 | $model = new PasswordResetRequestForm(); 56 | $model->email = $this->user[0]['email']; 57 | $user = User::findOne(['password_reset_token' => $this->user[0]['password_reset_token']]); 58 | 59 | expect('email sent', $model->sendEmail())->true(); 60 | expect('user has valid token', $user->password_reset_token)->notNull(); 61 | 62 | $this->specify('message has correct format', function () use ($model) { 63 | 64 | expect('message file exists', file_exists($this->getMessageFile()))->true(); 65 | 66 | $message = file_get_contents($this->getMessageFile()); 67 | expect('message "from" is correct', $message)->contains(Yii::$app->params['supportEmail']); 68 | expect('message "to" is correct', $message)->contains($model->email); 69 | 70 | }); 71 | } 72 | 73 | public function fixtures() 74 | { 75 | return [ 76 | 'user' => [ 77 | 'class' => UserFixture::className(), 78 | 'dataFile' => '@tests/codeception/frontend/unit/fixtures/data/models/user.php' 79 | ], 80 | ]; 81 | } 82 | 83 | private function getMessageFile() 84 | { 85 | return Yii::getAlias(Yii::$app->mailer->fileTransportPath) . '/testing_message.eml'; 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /tests/codeception/frontend/functional/SignupCest.php: -------------------------------------------------------------------------------- 1 | 'tester.email@example.com', 27 | 'username' => 'tester', 28 | ]); 29 | } 30 | 31 | /** 32 | * This method is called when test fails. 33 | * @param \Codeception\Event\FailEvent $event 34 | */ 35 | public function _fail($event) 36 | { 37 | 38 | } 39 | 40 | /** 41 | * 42 | * @param \codeception_frontend\FunctionalTester $I 43 | * @param \Codeception\Scenario $scenario 44 | */ 45 | public function testUserSignup($I, $scenario) 46 | { 47 | $I->wantTo('ensure that signup works'); 48 | 49 | $signupPage = SignupPage::openBy($I); 50 | $I->see('Signup', 'h1'); 51 | $I->see('Please fill out the following fields to signup:'); 52 | 53 | $I->amGoingTo('submit signup form with no data'); 54 | 55 | $signupPage->submit([]); 56 | 57 | $I->expectTo('see validation errors'); 58 | $I->see('Username cannot be blank.', '.help-block'); 59 | $I->see('Email cannot be blank.', '.help-block'); 60 | $I->see('Password cannot be blank.', '.help-block'); 61 | 62 | $I->amGoingTo('submit signup form with not correct email'); 63 | $signupPage->submit([ 64 | 'username' => 'tester', 65 | 'email' => 'tester.email', 66 | 'password' => 'tester_password', 67 | ]); 68 | 69 | $I->expectTo('see that email address is wrong'); 70 | $I->dontSee('Username cannot be blank.', '.help-block'); 71 | $I->dontSee('Password cannot be blank.', '.help-block'); 72 | $I->see('Email is not a valid email address.', '.help-block'); 73 | 74 | $I->amGoingTo('submit signup form with correct email'); 75 | $signupPage->submit([ 76 | 'username' => 'tester', 77 | 'email' => 'tester.email@example.com', 78 | 'password' => 'tester_password', 79 | ]); 80 | 81 | $I->expectTo('see that user is created'); 82 | $I->seeRecord('common\models\User', [ 83 | 'username' => 'tester', 84 | 'email' => 'tester.email@example.com', 85 | ]); 86 | 87 | $I->expectTo('see that user logged in'); 88 | $I->seeLink('Logout (tester)'); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /tests/codeception/common/unit/models/LoginFormTest.php: -------------------------------------------------------------------------------- 1 | [ 25 | 'user' => [ 26 | 'class' => 'yii\web\User', 27 | 'identityClass' => 'common\models\User', 28 | ], 29 | ], 30 | ]); 31 | } 32 | 33 | protected function tearDown() 34 | { 35 | Yii::$app->user->logout(); 36 | parent::tearDown(); 37 | } 38 | 39 | public function testLoginNoUser() 40 | { 41 | $model = new LoginForm([ 42 | 'username' => 'not_existing_username', 43 | 'password' => 'not_existing_password', 44 | ]); 45 | 46 | $this->specify('user should not be able to login, when there is no identity', function () use ($model) { 47 | expect('model should not login user', $model->login())->false(); 48 | expect('user should not be logged in', Yii::$app->user->isGuest)->true(); 49 | }); 50 | } 51 | 52 | public function testLoginWrongPassword() 53 | { 54 | $model = new LoginForm([ 55 | 'username' => 'bayer.hudson', 56 | 'password' => 'wrong_password', 57 | ]); 58 | 59 | $this->specify('user should not be able to login with wrong password', function () use ($model) { 60 | expect('model should not login user', $model->login())->false(); 61 | expect('error message should be set', $model->errors)->hasKey('password'); 62 | expect('user should not be logged in', Yii::$app->user->isGuest)->true(); 63 | }); 64 | } 65 | 66 | public function testLoginCorrect() 67 | { 68 | 69 | $model = new LoginForm([ 70 | 'username' => 'bayer.hudson', 71 | 'password' => 'password_0', 72 | ]); 73 | 74 | $this->specify('user should be able to login with correct credentials', function () use ($model) { 75 | expect('model should login user', $model->login())->true(); 76 | expect('error message should not be set', $model->errors)->hasntKey('password'); 77 | expect('user should be logged in', Yii::$app->user->isGuest)->false(); 78 | }); 79 | } 80 | 81 | /** 82 | * @inheritdoc 83 | */ 84 | public function fixtures() 85 | { 86 | return [ 87 | 'user' => [ 88 | 'class' => UserFixture::className(), 89 | 'dataFile' => '@tests/codeception/common/unit/fixtures/data/models/user.php' 90 | ], 91 | ]; 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /backend/views/admin/setting/index.php: -------------------------------------------------------------------------------- 1 | title = 'Basic Settings - ' . Yii::$app->name; 21 | 22 | echo AlertBlock::widget([ 23 | 'delay' => 5000, 24 | 'useSessionFlash' => TRUE 25 | ]); 26 | ?> 27 | 28 |
29 |
Basic Settings
30 | 31 |
32 | 'basic-setting-form', 34 | 'enableAjaxValidation' => FALSE, 35 | ]); ?> 36 | 37 |

Application Settings

38 | 39 |
40 | field($model, 'appName')->textInput([ 41 | 'value' => Yii::$app->config->get( 42 | Enum::APP_NAME, 'Starter Kit'), 43 | 'autofocus' => TRUE, 44 | 'autocomplete' => 'off' 45 | ]) 46 | ?> 47 |
48 | 49 |
50 | field($model, 'adminMail')->textInput([ 51 | 'value' => Yii::$app->config->get( 52 | Enum::ADMIN_EMAIL, 'no@reply.com'), 53 | 'autocomplete' => 'off' 54 | ]) ?> 55 |
56 | 57 |
58 | 59 |

Theme Settings

60 | 61 |
62 | field($model, 'appBackendTheme')->dropDownList($themes, [ 63 | 'class' => 'form-control', 64 | 'options' => [ 65 | Yii::$app->config->get(Enum::APP_BACKEND_THEME, 'yeti') => ['selected ' => TRUE] 66 | ] 67 | ]) ?> 68 |
69 | 70 |
71 | field($model, 'appFrontendTheme')->dropDownList($themes, [ 72 | 'class' => 'form-control', 73 | 'options' => [ 74 | Yii::$app->config->get(Enum::APP_FRONTEND_THEME, 'readable') => ['selected ' => TRUE] 75 | ] 76 | ]) ?> 77 |
78 | 79 |
80 | 81 |

Cache Setting

82 | 83 |
84 | field($model, 'cacheClass')->dropDownList( 85 | [ 86 | FileCache::className() => 'File Cache', 87 | DbCache::className() => 'Db Cache' 88 | ], 89 | [ 90 | 'class' => 'form-control', 91 | 'options' => [ 92 | Yii::$app->config->get(Enum::CACHE_CLASS, FileCache::className()) => ['selected ' => TRUE] 93 | ] 94 | ]) ?> 95 |
96 | 97 |
98 | 99 |

Introduction Tour

100 | 101 |
102 |
103 | field($model, 'appTour')->checkbox() ?> 104 |
105 |
106 | 107 | 'btn btn-primary']) ?> 108 | 109 | 110 |
111 |
-------------------------------------------------------------------------------- /backend/views/admin/setting/mail.php: -------------------------------------------------------------------------------- 1 | title = 'Mail Settings - ' . Yii::$app->name; 18 | 19 | echo AlertBlock::widget([ 20 | 'delay' => 5000, 21 | 'useSessionFlash' => TRUE 22 | ]); 23 | ?> 24 | 25 |
26 |
Mail Settings
27 | 28 |
29 | 'mail-form', 31 | 'enableAjaxValidation' => FALSE 32 | ]); ?> 33 | 34 |
35 | field($model, 'mailHost')->textInput([ 36 | 'value' => Yii::$app->config->get(Enum::MAILER_HOST), 37 | 'autofocus' => TRUE, 38 | 'autocomplete' => 'off' 39 | ]) ?> 40 |
41 | 42 |
43 | 44 |
45 | field($model, 'mailUsername')->textInput([ 46 | 'value' => Yii::$app->config->get 47 | (Enum::MAILER_USERNAME), 48 | 'autocomplete' => 'off' 49 | ]) ?> 50 |
51 | 52 |
53 | field($model, 'mailPassword')->textInput([ 54 | 'value' => Yii::$app->config->get 55 | (Enum::MAILER_PASSWORD), 56 | 'autocomplete' => 'off' 57 | ]) ?> 58 |
59 | 60 |
61 | 62 |
63 | field($model, 'mailPort')->textInput([ 64 | 'value' => Yii::$app->config->get(Enum::MAILER_PORT), 65 | 'autocomplete' => 'off' 66 | ]) ?> 67 |
68 | 69 |
70 | field($model, 'mailEncryption')->dropDownList( 71 | [ 72 | '' => 'Default', 73 | 'ssl' => 'SSL', 74 | 'tls' => 'TLS' 75 | ], 76 | [ 77 | 'class' => 'form-control', 78 | 'options' => 79 | [ 80 | Yii::$app->config->get(Enum::MAILER_ENCRYPTION, NULL) => 81 | [ 82 | 'selected ' => TRUE 83 | ] 84 | ] 85 | ]) ?> 86 |
87 | 88 |
89 |
90 | field($model, 'mailUseTransport')->checkbox() ?> 91 |
92 |
93 | 94 |
95 | 96 | 'btn btn-primary']) ?> 97 | 98 | 99 |
100 |
-------------------------------------------------------------------------------- /backend/views/admin/index.php: -------------------------------------------------------------------------------- 1 | title = 'Admin Panel - ' . Yii::$app->name; 14 | 15 | // Get System Information 16 | $systemInfo = new SystemInfo(); 17 | $systemInfo = $systemInfo::getInfo(); 18 | ?> 19 | 20 |
21 |
22 |
23 |
24 |
25 | 26 | 27 |

Processor

28 |
29 | 30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
Model
Architecture
No. of Cores
47 |
48 | 49 |
50 |
51 |
52 |
53 |
54 | 55 | 56 |

Server

57 |
58 | 59 |
60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |
OS
Server System
Load Average
76 |
77 |
78 |
79 |
80 | 81 |
82 |
83 |
84 |
85 | 86 | 87 |

Memory

88 |
89 | 90 |
91 | 92 | 93 | 94 | 95 | 96 |
Total Memoryformatter->asShortSize($systemInfo::getTotalMemory()) ?>
97 |
98 | 99 |
100 |
101 | 102 |
103 |
104 |
105 | 106 | 107 |

Software

108 |
109 | 110 |
111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 |
PHP
DB
DB Version
127 |
128 | 129 |
130 |
131 | 132 |
133 |
134 |
135 | 136 | 137 |

Framework

138 |
139 | 140 |
141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 |
Name
Version
151 |
152 | 153 |
154 |
155 |
156 |
-------------------------------------------------------------------------------- /requirements.php: -------------------------------------------------------------------------------- 1 | Error'; 18 | echo '

The path to yii framework seems to be incorrect.

'; 19 | echo '

You need to install Yii framework via composer or adjust the framework path in file ' . basename(__FILE__) . '.

'; 20 | echo '

Please refer to the README on how to install Yii.

'; 21 | } 22 | 23 | require_once($frameworkPath . '/requirements/YiiRequirementChecker.php'); 24 | $requirementsChecker = new YiiRequirementChecker(); 25 | 26 | $gdMemo = $imagickMemo = 'Either GD PHP extension with FreeType support or ImageMagick PHP extension with PNG support is required for image CAPTCHA.'; 27 | $gdOK = $imagickOK = false; 28 | 29 | if (extension_loaded('imagick')) { 30 | $imagick = new Imagick(); 31 | $imagickFormats = $imagick->queryFormats('PNG'); 32 | if (in_array('PNG', $imagickFormats)) { 33 | $imagickOK = true; 34 | } else { 35 | $imagickMemo = 'Imagick extension should be installed with PNG support in order to be used for image CAPTCHA.'; 36 | } 37 | } 38 | 39 | if (extension_loaded('gd')) { 40 | $gdInfo = gd_info(); 41 | if (!empty($gdInfo['FreeType Support'])) { 42 | $gdOK = true; 43 | } else { 44 | $gdMemo = 'GD extension should be installed with FreeType support in order to be used for image CAPTCHA.'; 45 | } 46 | } 47 | 48 | /** 49 | * Adjust requirements according to your application specifics. 50 | */ 51 | $requirements = array( 52 | // Database : 53 | array( 54 | 'name' => 'PDO extension', 55 | 'mandatory' => true, 56 | 'condition' => extension_loaded('pdo'), 57 | 'by' => 'All DB-related classes', 58 | ), 59 | array( 60 | 'name' => 'PDO SQLite extension', 61 | 'mandatory' => false, 62 | 'condition' => extension_loaded('pdo_sqlite'), 63 | 'by' => 'All DB-related classes', 64 | 'memo' => 'Required for SQLite database.', 65 | ), 66 | array( 67 | 'name' => 'PDO MySQL extension', 68 | 'mandatory' => false, 69 | 'condition' => extension_loaded('pdo_mysql'), 70 | 'by' => 'All DB-related classes', 71 | 'memo' => 'Required for MySQL database.', 72 | ), 73 | array( 74 | 'name' => 'PDO PostgreSQL extension', 75 | 'mandatory' => false, 76 | 'condition' => extension_loaded('pdo_pgsql'), 77 | 'by' => 'All DB-related classes', 78 | 'memo' => 'Required for PostgreSQL database.', 79 | ), 80 | // Cache : 81 | array( 82 | 'name' => 'Memcache extension', 83 | 'mandatory' => false, 84 | 'condition' => extension_loaded('memcache') || extension_loaded('memcached'), 85 | 'by' => 'MemCache', 86 | 'memo' => extension_loaded('memcached') ? 'To use memcached set MemCache::useMemcached to true.' : '' 87 | ), 88 | array( 89 | 'name' => 'APC extension', 90 | 'mandatory' => false, 91 | 'condition' => extension_loaded('apc'), 92 | 'by' => 'ApcCache', 93 | ), 94 | // CAPTCHA: 95 | array( 96 | 'name' => 'GD PHP extension with FreeType support', 97 | 'mandatory' => false, 98 | 'condition' => $gdOK, 99 | 'by' => 'Captcha', 100 | 'memo' => $gdMemo, 101 | ), 102 | array( 103 | 'name' => 'ImageMagick PHP extension with PNG support', 104 | 'mandatory' => false, 105 | 'condition' => $imagickOK, 106 | 'by' => 'Captcha', 107 | 'memo' => $imagickMemo, 108 | ), 109 | // PHP ini : 110 | 'phpSafeMode' => array( 111 | 'name' => 'PHP safe mode', 112 | 'mandatory' => false, 113 | 'condition' => $requirementsChecker->checkPhpIniOff("safe_mode"), 114 | 'by' => 'File uploading and console command execution', 115 | 'memo' => '"safe_mode" should be disabled at php.ini', 116 | ), 117 | 'phpExposePhp' => array( 118 | 'name' => 'Expose PHP', 119 | 'mandatory' => false, 120 | 'condition' => $requirementsChecker->checkPhpIniOff("expose_php"), 121 | 'by' => 'Security reasons', 122 | 'memo' => '"expose_php" should be disabled at php.ini', 123 | ), 124 | 'phpAllowUrlInclude' => array( 125 | 'name' => 'PHP allow url include', 126 | 'mandatory' => false, 127 | 'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"), 128 | 'by' => 'Security reasons', 129 | 'memo' => '"allow_url_include" should be disabled at php.ini', 130 | ), 131 | 'phpSmtp' => array( 132 | 'name' => 'PHP mail SMTP', 133 | 'mandatory' => false, 134 | 'condition' => strlen(ini_get('SMTP')) > 0, 135 | 'by' => 'Email sending', 136 | 'memo' => 'PHP mail SMTP server required', 137 | ), 138 | ); 139 | $requirementsChecker->checkYii()->check($requirements)->render(); 140 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Yii2 Practical Application Advanced Template Startup-kit 2 | ======================================================== 3 | 4 | [![Dependency Status](https://www.versioneye.com/user/projects/54e1e4630a910b08650001c6/badge.svg?style=flat)](https://www.versioneye.com/user/projects/54e1e4630a910b08650001c6) 5 | [![Code Climate](https://codeclimate.com/github/abhi1693/yii2-app-advanced-startup-kit/badges/gpa.svg)](https://codeclimate.com/github/abhi1693/yii2-app-advanced-startup-kit) 6 | [![Latest Stable Version](https://poser.pugx.org/abhi1693/yii2-app-advanced-startup-kit/v/stable.svg)](https://packagist.org/packages/abhi1693/yii2-app-advanced-startup-kit) [![Total Downloads](https://poser.pugx.org/abhi1693/yii2-app-advanced-startup-kit/downloads)](https://packagist.org/packages/abhi1693/yii2-app-advanced-startup-kit) 7 | 8 | This is Yii2 start application template. 9 | It was created and developing as a fast start for building an advanced sites based on Yii2. 10 | It covers typical use cases for a new project and will help you not to waste your time doing the same work in every project 11 | 12 | **Note: The application is still under development. Use it at your own risk** 13 | 14 | DONATE 15 | ------ 16 | 17 | Any contribution helps us to improve [Yii2 Startup Kit](https://github.com/abhi1693/yii2-app-advanced-startup-kit), if you want to help us too but don't want to get into coding, we won't say no to PayPal 18 | 19 | [![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=EHXMKZ3NLKR7W) 20 | 21 | FEATURES 22 | -------- 23 | > Note: Some features are still under development. Please use it at your own risk 24 | 25 | - Application Auto Installer includes: 26 | - Application Basic Setup such as Application Name, Cache type, backend/frontend theme etc. 27 | - Admin Account setup 28 | - Mailer Component setup 29 | - Auto migrate required tables required by the the application 30 | - Based on yii2-advanced application template 31 | - Beautiful and open source dashboard theme for backend 32 | - Sign in, Sign up, profile(avatar, locale, personal data) etc 33 | - OAuth authorization 34 | - User management: CRUD 35 | - RBAC 36 | - Yii2 log web interface 37 | - Application events component 38 | - System information web interface 39 | - many other features coming soon 40 | 41 | REQUIREMENTS 42 | ------------ 43 | 44 | The minimum requirement by this application template that your Web server supports PHP 5.4.0. 45 | 46 | 47 | INSTALLATION 48 | ------------ 49 | 50 | ### Install via Composer 51 | 52 | If you do not have [Composer](http://getcomposer.org/), you may install it by following the instructions 53 | at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix). 54 | 55 | You can then install the application using the following command: 56 | 57 | ```bash 58 | composer global require "fxp/composer-asset-plugin:1.0.0" 59 | composer create-project --prefer-dist --stability=dev abhi1693/yii2-app-advanced-startup-kit demo-app 60 | ``` 61 | 62 | ### Install from GitHub 63 | 64 | Extract the github archive file or clone this repository. 65 | 66 | ```bash 67 | git clone https://github.com/abhi1693/yii2-app-advanced-startup-kit.git 68 | ``` 69 | 70 | After extraction run 71 | 72 | ```bash 73 | php composer.phar install 74 | ``` 75 | 76 | GETTING STARTED 77 | --------------- 78 | 79 | After you install the application, just run `init` command (without altering anything in the `environment` folder) 80 | and select your environment then go to `http://yourhost/your-app/` and the application will help you setup everything else. 81 | 82 | FAQ 83 | --- 84 | 85 | See [FAQ](FAQ.md) for more details. 86 | 87 | TESTING 88 | ------- 89 | 90 | Install additional composer packages: 91 | * `php composer.phar require --dev "codeception/codeception: 1.8.*@dev" "codeception/specify: *" "codeception/verify: *"` 92 | 93 | This application boilerplate use database in testing, so you should create three databases that are used in tests: 94 | * `yii2_practical_unit` - database for unit tests; 95 | * `yii2_practical_functional` - database for functional tests; 96 | * `yii2_practical_acceptance` - database for acceptance tests. 97 | 98 | To make your database up to date, you can run in needed test folder `yii migrate`, for example 99 | if you are starting from `frontend` tests then you should run `yii migrate` in each suite folder `acceptance`, `functional`, `unit` 100 | it will upgrade your database to the last state according migrations. 101 | 102 | To be able to run acceptance tests you need a running webserver. For this you can use the php builtin server and run it in the directory where your main project folder is located. For example if your application is located in `/www/practical` all you need to is: 103 | `cd /www` and then `php -S 127.0.0.1:8080` because the default configuration of acceptance tests expects the url of the application to be `/practical/`. 104 | If you already have a server configured or your application is not located in a folder called `practical`, you may need to adjust the `TEST_ENTRY_URL` in `frontend/tests/_bootstrap.php` and `backend/tests/_bootstrap.php`. 105 | 106 | After that is done you should be able to run your tests, for example to run `frontend` tests do: 107 | 108 | * `cd frontend` 109 | * `../vendor/bin/codecept build` 110 | * `../vendor/bin/codecept run` 111 | 112 | In similar way you can run tests for other application tiers - `backend`, `console`, `common`. 113 | 114 | You also can adjust you application suite configs and `_bootstrap.php` settings to use other urls and files, as it is can be done in `yii2-basic`. 115 | 116 | ## Dependencies 117 | 118 | - [Yii2-Config](https://github.com/abhi1693/yii2-config) 119 | - [Yii2-User](https://github.com/abhi1693/yii2-user) 120 | - [Yii2-Installer](https://github.com/abhi1693/yii2-installer) 121 | - [Yii2-System-Info](https://github.com/abhi1693/yii2-system-info) 122 | - [Yii2-Rbac](https://github.com/abhi1693/yii2-rbac) 123 | 124 | # Donate 125 | 126 | Any contribution helps us to improve [Yii2 Startup Kit](https://github.com/abhi1693/yii2-app-advanced-startup-kit), if you want to help us too but don't want to get into coding, we won't say no to PayPal 127 | 128 | [![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=EHXMKZ3NLKR7W) 129 | -------------------------------------------------------------------------------- /init: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | 11 | * 12 | * @link http://www.yiiframework.com/ 13 | * @copyright Copyright (c) 2008 Yii Software LLC 14 | * @license http://www.yiiframework.com/license/ 15 | */ 16 | 17 | if (!extension_loaded('mcrypt')) { 18 | die('The mcrypt PHP extension is required by Yii2.'); 19 | } 20 | 21 | $params = getParams(); 22 | $root = str_replace('\\', '/', __DIR__); 23 | $envs = require("$root/environments/index.php"); 24 | $envNames = array_keys($envs); 25 | 26 | echo "Yii Application Initialization Tool v1.0\n\n"; 27 | 28 | $envName = null; 29 | if (empty($params['env']) || $params['env'] === '1') { 30 | echo "Which environment do you want the application to be initialized in?\n\n"; 31 | foreach ($envNames as $i => $name) { 32 | echo " [$i] $name\n"; 33 | } 34 | echo "\n Your choice [0-" . (count($envs) - 1) . ', or "q" to quit] '; 35 | $answer = trim(fgets(STDIN)); 36 | 37 | if (!ctype_digit($answer) || !in_array($answer, range(0, count($envs) - 1))) { 38 | echo "\n Quit initialization.\n"; 39 | exit(0); 40 | } 41 | 42 | if (isset($envNames[$answer])) { 43 | $envName = $envNames[$answer]; 44 | } 45 | } else { 46 | $envName = $params['env']; 47 | } 48 | 49 | if (!in_array($envName, $envNames)) { 50 | $envsList = implode(', ', $envNames); 51 | echo "\n $envName is not a valid environment. Try one of the following: $envsList. \n"; 52 | exit(2); 53 | } 54 | 55 | $env = $envs[$envName]; 56 | 57 | if (empty($params['env'])) { 58 | echo "\n Initialize the application under '{$envNames[$answer]}' environment? [yes|no] "; 59 | $answer = trim(fgets(STDIN)); 60 | if (strncasecmp($answer, 'y', 1)) { 61 | echo "\n Quit initialization.\n"; 62 | exit(0); 63 | } 64 | } 65 | 66 | echo "\n Start initialization ...\n\n"; 67 | $files = getFileList("$root/environments/{$env['path']}"); 68 | $all = false; 69 | foreach ($files as $file) { 70 | if (!copyFile($root, "environments/{$env['path']}/$file", $file, $all, $params)) { 71 | break; 72 | } 73 | } 74 | 75 | $callbacks = ['setCookieValidationKey', 'setWritable', 'setExecutable']; 76 | foreach ($callbacks as $callback) { 77 | if (!empty($env[$callback])) { 78 | $callback($root, $env[$callback]); 79 | } 80 | } 81 | 82 | echo "\n ... initialization completed.\n\n"; 83 | 84 | function getFileList($root, $basePath = '') 85 | { 86 | $files = []; 87 | $handle = opendir($root); 88 | while (($path = readdir($handle)) !== false) { 89 | if ($path === '.svn' || $path === '.' || $path === '..') { 90 | continue; 91 | } 92 | $fullPath = "$root/$path"; 93 | $relativePath = $basePath === '' ? $path : "$basePath/$path"; 94 | if (is_dir($fullPath)) { 95 | $files = array_merge($files, getFileList($fullPath, $relativePath)); 96 | } else { 97 | $files[] = $relativePath; 98 | } 99 | } 100 | closedir($handle); 101 | return $files; 102 | } 103 | 104 | function copyFile($root, $source, $target, &$all, $params) 105 | { 106 | if (!is_file($root . '/' . $source)) { 107 | echo " skip $target ($source not exist)\n"; 108 | return true; 109 | } 110 | if (is_file($root . '/' . $target)) { 111 | if (file_get_contents($root . '/' . $source) === file_get_contents($root . '/' . $target)) { 112 | echo " unchanged $target\n"; 113 | return true; 114 | } 115 | if ($all) { 116 | echo " overwrite $target\n"; 117 | } else { 118 | echo " exist $target\n"; 119 | echo " ...overwrite? [Yes|No|All|Quit] "; 120 | 121 | 122 | $answer = !empty($params['overwrite']) ? $params['overwrite'] : trim(fgets(STDIN)); 123 | if (!strncasecmp($answer, 'q', 1)) { 124 | return false; 125 | } else { 126 | if (!strncasecmp($answer, 'y', 1)) { 127 | echo " overwrite $target\n"; 128 | } else { 129 | if (!strncasecmp($answer, 'a', 1)) { 130 | echo " overwrite $target\n"; 131 | $all = true; 132 | } else { 133 | echo " skip $target\n"; 134 | return true; 135 | } 136 | } 137 | } 138 | } 139 | file_put_contents($root . '/' . $target, file_get_contents($root . '/' . $source)); 140 | return true; 141 | } 142 | echo " generate $target\n"; 143 | @mkdir(dirname($root . '/' . $target), 0777, true); 144 | file_put_contents($root . '/' . $target, file_get_contents($root . '/' . $source)); 145 | return true; 146 | } 147 | 148 | function getParams() 149 | { 150 | $rawParams = []; 151 | if (isset($_SERVER['argv'])) { 152 | $rawParams = $_SERVER['argv']; 153 | array_shift($rawParams); 154 | } 155 | 156 | $params = []; 157 | foreach ($rawParams as $param) { 158 | if (preg_match('/^--(\w+)(=(.*))?$/', $param, $matches)) { 159 | $name = $matches[1]; 160 | $params[$name] = isset($matches[3]) ? $matches[3] : true; 161 | } else { 162 | $params[] = $param; 163 | } 164 | } 165 | return $params; 166 | } 167 | 168 | function setWritable($root, $paths) 169 | { 170 | foreach ($paths as $writable) { 171 | echo " chmod 0777 $writable\n"; 172 | @chmod("$root/$writable", 0777); 173 | } 174 | } 175 | 176 | function setExecutable($root, $paths) 177 | { 178 | foreach ($paths as $executable) { 179 | echo " chmod 0755 $executable\n"; 180 | @chmod("$root/$executable", 0755); 181 | } 182 | } 183 | 184 | function setCookieValidationKey($root, $paths) 185 | { 186 | foreach ($paths as $file) { 187 | echo " generate cookie validation key in $file\n"; 188 | $file = $root . '/' . $file; 189 | $length = 32; 190 | $bytes = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM); 191 | $key = strtr(substr(base64_encode($bytes), 0, $length), '+/=', '_-.'); 192 | $content = preg_replace('/(("|\')cookieValidationKey("|\')\s*=>\s*)(""|\'\')/', "\\1'$key'", file_get_contents($file)); 193 | file_put_contents($file, $content); 194 | } 195 | } 196 | 197 | function createSymlink($links) 198 | { 199 | foreach ($links as $link => $target) { 200 | echo " symlink $target as $link\n"; 201 | if (!is_link($link)) { 202 | symlink($target, $link); 203 | } 204 | } 205 | } 206 | -------------------------------------------------------------------------------- /backend/controllers/admin/SettingController.php: -------------------------------------------------------------------------------- 1 | [ 35 | 'label' => 'Users', 36 | 'icon' => 'user', 37 | 'items' => [ 38 | ['label' => 'Manage', 'url' => ['/user/admin'], 'icon' => 'user'], 39 | ['label' => 'Settings', 'icon' => 'cog', 'items' => [ 40 | [ 41 | 'label' => 'Basic', 42 | 'url' => ['/user/settings/index'] 43 | ], 44 | [ 45 | 'label' => 'Auth Clients', 46 | 'url' => ['/user/settings/auth-client'] 47 | ] 48 | ]] 49 | ] 50 | ], 51 | ]; 52 | $autoMenuItems = [ 53 | [ 54 | 'url' => ['/admin/index'], 55 | 'label' => 'Home', 56 | 'icon' => 'home' 57 | ], 58 | [ 59 | 'url' => ['/admin/about'], 60 | 'label' => 'About', 61 | 'icon' => 'info-sign' 62 | ], 63 | [ 64 | 'label' => 'Website Settings', 65 | 'icon' => 'cog', 66 | 'items' => [ 67 | [ 68 | 'url' => ['/admin/setting/index'], 69 | 'label' => 'Basic', 70 | ], 71 | [ 72 | 'url' => ['/admin/setting/database'], 73 | 'label' => 'Database' 74 | ], 75 | [ 76 | 'url' => ['/admin/setting/mail'], 77 | 'label' => 'Mail' 78 | ], 79 | [ 80 | 'url' => ['/admin/setting/install'], 81 | 'label' => 'Installer' 82 | ], 83 | [ 84 | 'url' => ['/admin/setting/self-test'], 85 | 'label' => 'Self Test' 86 | ] 87 | ] 88 | ] 89 | ]; 90 | 91 | foreach (Yii::$app->getModules() as $name => $m) { 92 | switch ($name) { 93 | case 'user': 94 | $menuItems[] = $menuItemPresets[$name]; 95 | break; 96 | } 97 | } 98 | 99 | if (Yii::$app->user->isGuest) 100 | $menuItems = []; 101 | else 102 | $menuItems = ArrayHelper::merge($autoMenuItems, $menuItems); 103 | 104 | return $menuItems; 105 | } 106 | 107 | public function behaviors() 108 | { 109 | return [ 110 | 'access' => [ 111 | 'class' => AccessControl::className(), 112 | 'rules' => [ 113 | [ 114 | 'actions' => ['index', 'database', 'mail', 'install', 'self-test'], 115 | 'allow' => TRUE, 116 | 'roles' => ['@'], 117 | ], 118 | ], 119 | ], 120 | ]; 121 | } 122 | 123 | public function actionIndex() 124 | { 125 | $model = new BasicSettingForm(); 126 | $themes = SettingController::getThemes(); 127 | $model->appTour = Yii::$app->config->get(Enum::APP_TOUR, '1'); 128 | 129 | if ($model->load(Yii::$app->request->post())) { 130 | if ($model->validate()) { 131 | Yii::$app->config->set(Enum::APP_NAME, $model->appName); 132 | Yii::$app->config->set(Enum::ADMIN_EMAIL, $model->adminMail); 133 | Yii::$app->config->set(Enum::APP_BACKEND_THEME, $model->appBackendTheme); 134 | Yii::$app->config->set(Enum::APP_FRONTEND_THEME, $model->appFrontendTheme); 135 | Yii::$app->config->set(Enum::CACHE_CLASS, $model->cacheClass); 136 | Yii::$app->config->set(Enum::APP_TOUR, $model->appTour); 137 | 138 | $config = Configuration::get(); 139 | $config['components']['cache'] = $model->cacheClass; 140 | Configuration::set($config); 141 | 142 | Yii::$app->session->setFlash('success', 'Settings Saved'); 143 | } 144 | } 145 | 146 | return $this->render('index', ['model' => $model, 'themes' => $themes]); 147 | } 148 | 149 | private static function getThemes() 150 | { 151 | return [ 152 | 'cerulean' => 'Cerulean', 153 | 'cosmo' => 'Cosmo', 154 | 'cyborg' => 'Cyborg', 155 | 'darkly' => 'Darkly', 156 | 'flatly' => 'Flatly', 157 | 'journal' => 'Journal', 158 | 'lumen' => 'Lumen', 159 | 'paper' => 'Paper', 160 | 'readable' => 'Readable', 161 | 'sandstone' => 'Sandstone', 162 | 'simplex' => 'Simplex', 163 | 'slate' => 'Slate', 164 | 'spacelab' => 'Spacelab', 165 | 'superhero' => 'Superhero', 166 | 'united' => 'United', 167 | 'yeti' => 'Yeti' 168 | ]; 169 | } 170 | 171 | public function actionDatabase() 172 | { 173 | $config = Configuration::get(); 174 | $param = Configuration::getParam(); 175 | 176 | $form = new DatabaseSettingForm(); 177 | 178 | if ($form->load(Yii::$app->request->post())) { 179 | if ($form->validate()) { 180 | $dsn = "mysql:host=" . $form->hostname . ";dbname=" . $form->database; 181 | // Create Test DB Connection 182 | Yii::$app->set('db', [ 183 | 'class' => Connection::className(), 184 | 'dsn' => $dsn, 185 | 'username' => $form->username, 186 | 'password' => $form->password, 187 | 'charset' => 'utf8' 188 | ]); 189 | 190 | try { 191 | Yii::$app->db->open(); 192 | // Check DB Connection 193 | if (InstallerModule::checkDbConnection()) { 194 | // Write Config 195 | $config['components']['db']['class'] = Connection::className(); 196 | $config['components']['db']['dsn'] = $dsn; 197 | $config['components']['db']['username'] = $form->username; 198 | $config['components']['db']['password'] = $form->password; 199 | $config['components']['db']['charset'] = 'utf8'; 200 | 201 | // Write config for future use 202 | $param['installer']['db']['installer_hostname'] = $form->hostname; 203 | $param['installer']['db']['installer_database'] = $form->database; 204 | $param['installer']['db']['installer_username'] = $form->username; 205 | 206 | Configuration::set($config); 207 | Configuration::setParam($param); 208 | 209 | Yii::$app->getSession()->setFlash('success', 'Database settings saved'); 210 | } else { 211 | Yii::$app->getSession()->setFlash('danger', 'Incorrect configuration'); 212 | } 213 | } catch (Exception $e) { 214 | Yii::$app->getSession()->setFlash('danger', $e->getMessage()); 215 | } 216 | } 217 | } else { 218 | if (isset($param['installer']['db']['installer_hostname'])) 219 | $form->hostname = $param['installer']['db']['installer_hostname']; 220 | 221 | if (isset($param['installer']['db']['installer_database'])) 222 | $form->database = $param['installer']['db']['installer_database']; 223 | 224 | if (isset($param['installer']['db']['installer_username'])) 225 | $form->username = $param['installer']['db']['installer_username']; 226 | } 227 | 228 | return $this->render('database', ['model' => $form]); 229 | } 230 | 231 | public function actionMail() 232 | { 233 | $model = new MailFormSetting(); 234 | $model->mailUseTransport = Yii::$app->config->get(Enum::MAILER_USE_TRANSPORT) === 'true' ? '1' : '0'; 235 | 236 | if ($model->load(Yii::$app->request->post())) { 237 | if ($model->validate()) { 238 | if ($model->mailUseTransport === '0') 239 | $model->mailUseTransport = FALSE; 240 | else 241 | $model->mailUseTransport = TRUE; 242 | 243 | Yii::$app->config->set(Enum::MAILER_HOST, $model->mailHost); 244 | Yii::$app->config->set(Enum::MAILER_USERNAME, $model->mailUsername); 245 | Yii::$app->config->set(Enum::MAILER_PASSWORD, $model->mailPassword); 246 | Yii::$app->config->set(Enum::MAILER_PORT, $model->mailPort); 247 | Yii::$app->config->set(Enum::MAILER_ENCRYPTION, $model->mailEncryption); 248 | Yii::$app->config->set(Enum::MAILER_USE_TRANSPORT, $model->mailUseTransport ? 'true' : 'false'); 249 | 250 | $config = Configuration::get(); 251 | $param = Configuration::getParam(); 252 | 253 | $config['components']['mail']['useTransport'] = $model->mailUseTransport; 254 | $config['components']['mail']['transport']['host'] = $model->mailHost; 255 | $config['components']['mail']['transport']['username'] = $model->mailUsername; 256 | $config['components']['mail']['transport']['password'] = $model->mailPassword; 257 | $config['components']['mail']['transport']['port'] = $model->mailPort; 258 | $config['components']['mail']['transport']['encryption'] = $model->mailEncryption; 259 | 260 | // Write config for future use 261 | $param['installer']['mail']['useTransport'] = $model->mailUseTransport; 262 | $param['installer']['mail']['transport']['host'] = $model->mailHost; 263 | $param['installer']['mail']['transport']['username'] = $model->mailUsername; 264 | $param['installer']['mail']['transport']['password'] = $model->mailPassword; 265 | $param['installer']['mail']['transport']['port'] = $model->mailPort; 266 | $param['installer']['mail']['transport']['encryption'] = $model->mailEncryption; 267 | 268 | Configuration::set($config); 269 | Configuration::setParam($param); 270 | 271 | Yii::$app->session->setFlash('success', 'Mail Settings Saved'); 272 | } 273 | } 274 | 275 | return $this->render('mail', ['model' => $model]); 276 | } 277 | 278 | public function actionInstall() 279 | { 280 | $model = new InstallerForm(); 281 | $param = Configuration::getParam(); 282 | 283 | if ($model->load(Yii::$app->request->post())) { 284 | $model->install = $model->install === '0' ? TRUE : FALSE; 285 | $param['installed'] = $model->install; 286 | 287 | Configuration::setParam($param); 288 | } 289 | 290 | return $this->render('install', ['model' => $model]); 291 | } 292 | 293 | public function actionSelfTest() 294 | { 295 | $checks = SystemCheck::getResults(); 296 | 297 | $hasError = FALSE; 298 | foreach ($checks as $check) { 299 | if ($check['state'] == 'ERROR') 300 | $hasError = TRUE; 301 | } 302 | 303 | // todo make migration better 304 | $data = file_get_contents((dirname(__DIR__) . '/../../vendor/abhi1693/yii2-installer/migrations/data.sql')); 305 | Yii::$app->db->createCommand($data)->execute(); 306 | 307 | return $this->render('self-test', ['checks' => $checks, 'hasError' => $hasError]); 308 | } 309 | } --------------------------------------------------------------------------------