├── 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 |
This is the About page. You may modify the following file to customize its content:
12 | 13 |= __FILE__ ?>
14 | Version: = Common::getVersion() ?>
19 | 20 |Created By = Common::getCreator() ?>
21 | 22 | 23 | 24 |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 |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 |17 | If you have business inquiries or other questions, please fill out the following form to contact us. Thank you. 18 |
19 | 20 |Checking = Yii::$app->name ?> software prerequisites
23 |You have successfully created your Yii-powered application.
44 | 45 | 46 | 47 |You have successfully created your Yii-powered application.
44 | 45 | 46 | 47 || Model | 34 |= $systemInfo::getCpuModel() ?> | 35 |
| Architecture | 39 |= $systemInfo::getCpuArchitecture() ?> | 40 |
| No. of Cores | 44 |= $systemInfo::getCpuCores() ?> | 45 |
| OS | 63 |= $systemInfo::getOS() ?> | 64 |
| Server System | 68 |= $systemInfo::getServerSoftware() ?> | 69 |
| Load Average | 73 |= $systemInfo::getLoad() ?> | 74 |
| Total Memory | 94 |= Yii::$app->formatter->asShortSize($systemInfo::getTotalMemory()) ?> | 95 |
| PHP | 114 |= $systemInfo::getPhpVersion() ?> | 115 |
| DB | 119 |= $systemInfo::getDbType() ?> | 120 |
| DB Version | 124 |= $systemInfo::getDbVersion() ?> | 125 |
| Name | 144 |= Yii::powered() ?> | 145 |
| Version | 148 |= Yii::getVersion() ?> | 149 |
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 totrue.' : ''
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 | [](https://www.versioneye.com/user/projects/54e1e4630a910b08650001c6)
5 | [](https://codeclimate.com/github/abhi1693/yii2-app-advanced-startup-kit)
6 | [](https://packagist.org/packages/abhi1693/yii2-app-advanced-startup-kit) [](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 | [](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 | [](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 | }
--------------------------------------------------------------------------------