diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 000000000..011c056bb --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,8 @@ +# Reformat code te be PSR-2 compatible +93cc82c4bf42cea403e1acaab201338bea304b6e +# Convert to short syntax (array) +332030325fbad38a64c5e60980d3b14b6434d6dd +# Convert to short syntax +b0fcdfab1aecaeb620f75a83f15aa02bc25765a0 +# Fix codestyle +0f91f32ecff52ef479addb0a5013342d59fe0697 diff --git a/.gitattributes b/.gitattributes index 3e9092c68..705fb391d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,7 @@ # Ignore all test and documentation for archive -/.github export-ignore -/.gitattributes export-ignore -/.scrutinizer.yml export-ignore -/.travis.yml export-ignore -/docs export-ignore +/.github export-ignore +/.git-blame-ignore-revs export-ignore +/.gitattributes export-ignore +/.scrutinizer.yml export-ignore +/.travis.yml export-ignore +/docs export-ignore diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 3d8d32c25..ea75bda5f 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -3,5 +3,5 @@ Contributing to Yii2 - [Report an issue](https://github.com/yiisoft/yii2/blob/master/docs/internals/report-an-issue.md) - [Translate documentation or messages](https://github.com/yiisoft/yii2/blob/master/docs/internals/translation-workflow.md) -- [Give us feedback or start a design discussion](http://www.yiiframework.com/forum/index.php/forum/42-general-discussions-for-yii-20/) +- [Give us feedback or start a design discussion](https://www.yiiframework.com/forum/index.php/forum/42-general-discussions-for-yii-20/) - [Contribute to the core code or fix bugs](https://github.com/yiisoft/yii2/blob/master/docs/internals/git-workflow.md) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f1065f909..a5beac653 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: env: extensions: dom, json, gd, imagick - key: cache-v1 + key: cache-v4 runs-on: ${{ matrix.os }} @@ -24,10 +24,13 @@ jobs: - "7.4" - "8.0" - "8.1" + - "8.2" + - "8.3" + - "8.4" steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v5 - name: Setup cache environment id: cache-env @@ -38,7 +41,7 @@ jobs: key: ${{ env.key }} - name: Cache extensions - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: ${{ steps.cache-env.outputs.dir }} key: ${{ steps.cache-env.outputs.key }} @@ -62,7 +65,7 @@ jobs: echo "COMPOSER_CACHE_DIR=~\AppData\Local\Composer" >> $GITHUB_ENV - name: Cache dependencies installed with composer - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: ${{ steps.cache-env.outputs.dir }} key: php${{ matrix.php }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }} diff --git a/.gitignore b/.gitignore index 28419e445..05fb29d1b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ # phpstorm project files .idea +# visual studio code project files +.vscode + # netbeans project files nbproject @@ -18,9 +21,6 @@ Thumbs.db # composer itself is not needed composer.phar -# composer lock -composer.lock - # Mac DS_Store Files .DS_Store diff --git a/README.md b/README.md index fd9b5f6a1..981a7f9d9 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@

-Yii 2 Basic Project Template is a skeleton [Yii 2](http://www.yiiframework.com/) application best for +Yii 2 Basic Project Template is a skeleton [Yii 2](https://www.yiiframework.com/) application best for rapidly creating small projects. The template contains the basic features including user login/logout and a contact page. @@ -37,7 +37,7 @@ DIRECTORY STRUCTURE REQUIREMENTS ------------ -The minimum requirement by this project template that your Web server supports PHP 5.6.0. +The minimum requirement by this project template that your Web server supports PHP 7.4. INSTALLATION @@ -45,8 +45,8 @@ INSTALLATION ### Install via Composer -If you do not have [Composer](http://getcomposer.org/), you may install it by following the instructions -at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix). +If you do not have [Composer](https://getcomposer.org/), you may install it by following the instructions +at [getcomposer.org](https://getcomposer.org/doc/00-intro.md#installation-nix). You can then install this project template using the following command: @@ -63,7 +63,7 @@ http://localhost/basic/web/ ### Install from an Archive File -Extract the archive file downloaded from [yiiframework.com](http://www.yiiframework.com/download/) to +Extract the archive file downloaded from [yiiframework.com](https://www.yiiframework.com/download/) to a directory named `basic` that is directly under the Web root. Set cookie validation key in `config/web.php` file to some random secret string: @@ -131,7 +131,7 @@ return [ TESTING ------- -Tests are located in `tests` directory. They are developed with [Codeception PHP Testing Framework](http://codeception.com/). +Tests are located in `tests` directory. They are developed with [Codeception PHP Testing Framework](https://codeception.com/). By default, there are 3 test suites: - `unit` @@ -164,7 +164,7 @@ To execute acceptance tests do the following: composer update ``` -4. Download [Selenium Server](http://www.seleniumhq.org/download/) and launch it: +4. Download [Selenium Server](https://www.seleniumhq.org/download/) and launch it: ``` java -jar ~/selenium-server-standalone-x.xx.x.jar diff --git a/assets/AppAsset.php b/assets/AppAsset.php index 732d48efc..d9d4cc430 100644 --- a/assets/AppAsset.php +++ b/assets/AppAsset.php @@ -1,8 +1,9 @@ =2.7 <=4.2.4" + "codeception/module-filesystem": "^3.0 || ^2.0 || ^1.1", + "codeception/verify": "^3.0 || ^2.2" }, "config": { "allow-plugins": { diff --git a/config/__autocomplete.php b/config/__autocomplete.php index d99dea50e..e5e1c00d7 100644 --- a/config/__autocomplete.php +++ b/config/__autocomplete.php @@ -11,7 +11,8 @@ * } * ``` */ -class Yii { +class Yii +{ /** * @var \yii\web\Application|\yii\console\Application|__Application */ @@ -19,15 +20,16 @@ class Yii { } /** - * @property yii\rbac\DbManager $authManager + * @property yii\rbac\DbManager $authManager * @property \yii\web\User|__WebUser $user - * */ -class __Application { +class __Application +{ } /** * @property app\models\User $identity */ -class __WebUser { +class __WebUser +{ } diff --git a/config/console.php b/config/console.php index 299656afc..ca429affa 100644 --- a/config/console.php +++ b/config/console.php @@ -43,6 +43,14 @@ $config['modules']['gii'] = [ 'class' => 'yii\gii\Module', ]; + // configuration adjustments for 'dev' environment + // requires version `2.1.21` of yii2-debug module + $config['bootstrap'][] = 'debug'; + $config['modules']['debug'] = [ + 'class' => 'yii\debug\Module', + // uncomment the following to add your IP if you are not connecting from localhost. + //'allowedIPs' => ['127.0.0.1', '::1'], + ]; } return $config; diff --git a/config/test.php b/config/test.php index 317bc1cb6..fb5e2929e 100644 --- a/config/test.php +++ b/config/test.php @@ -1,4 +1,5 @@ validate()) { - return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600*24*30 : 0); + return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0); } return false; } diff --git a/requirements.php b/requirements.php index 6cf322eb0..db69a36ee 100644 --- a/requirements.php +++ b/requirements.php @@ -1,4 +1,5 @@ 'Memcache extension', 'mandatory' => false, 'condition' => extension_loaded('memcache') || extension_loaded('memcached'), - 'by' => 'MemCache', - 'memo' => extension_loaded('memcached') ? 'To use memcached set MemCache::useMemcached to true.' : '' + 'by' => 'MemCache', + 'memo' => extension_loaded('memcached') ? 'To use memcached set MemCache::useMemcached to true.' : '' ), // CAPTCHA: array( 'name' => 'GD PHP extension with FreeType support', 'mandatory' => false, 'condition' => $gdOK, - 'by' => 'Captcha', + 'by' => 'Captcha', 'memo' => $gdMemo, ), array( 'name' => 'ImageMagick PHP extension with PNG support', 'mandatory' => false, 'condition' => $imagickOK, - 'by' => 'Captcha', + 'by' => 'Captcha', 'memo' => $imagickMemo, ), // PHP ini : @@ -153,7 +154,7 @@ 'name' => 'APC extension', 'mandatory' => false, 'condition' => extension_loaded('apc'), - 'by' => 'ApcCache', + 'by' => 'ApcCache', ); } diff --git a/tests/_bootstrap.php b/tests/_bootstrap.php index 131da42af..4b8424f73 100644 --- a/tests/_bootstrap.php +++ b/tests/_bootstrap.php @@ -1,6 +1,7 @@ amOnPage(Url::toRoute('/site/contact')); } - + public function contactPageWorks(AcceptanceTester $I) { $I->wantTo('ensure that contact page works'); @@ -25,7 +25,7 @@ public function contactFormCanBeSubmitted(AcceptanceTester $I) $I->fillField('#contactform-verifycode', 'testme'); $I->click('contact-button'); - + $I->wait(2); // wait for button to be clicked $I->dontSeeElement('#contact-form'); diff --git a/tests/acceptance/HomeCest.php b/tests/acceptance/HomeCest.php index e65df16ae..98fb6b9f7 100644 --- a/tests/acceptance/HomeCest.php +++ b/tests/acceptance/HomeCest.php @@ -6,13 +6,13 @@ class HomeCest { public function ensureThatHomePageWorks(AcceptanceTester $I) { - $I->amOnPage(Url::toRoute('/site/index')); + $I->amOnPage(Url::toRoute('/site/index')); $I->see('My Company'); - + $I->seeLink('About'); $I->click('About'); $I->wait(2); // wait for page to be opened - + $I->see('This is the About page.'); } } diff --git a/tests/bin/yii b/tests/bin/yii index 4923537fb..39df4013d 100755 --- a/tests/bin/yii +++ b/tests/bin/yii @@ -3,9 +3,9 @@ /** * Yii console bootstrap file. * - * @link http://www.yiiframework.com/ + * @link https://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC - * @license http://www.yiiframework.com/license/ + * @license https://www.yiiframework.com/license/ */ defined('YII_DEBUG') or define('YII_DEBUG', true); diff --git a/tests/bin/yii.bat b/tests/bin/yii.bat index d516b3a19..ce14c92bc 100644 --- a/tests/bin/yii.bat +++ b/tests/bin/yii.bat @@ -4,9 +4,9 @@ rem ------------------------------------------------------------- rem Yii command line bootstrap script for Windows. rem rem @author Qiang Xue -rem @link http://www.yiiframework.com/ +rem @link https://www.yiiframework.com/ rem @copyright Copyright (c) 2008 Yii Software LLC -rem @license http://www.yiiframework.com/license/ +rem @license https://www.yiiframework.com/license/ rem ------------------------------------------------------------- @setlocal diff --git a/tests/functional/ContactFormCest.php b/tests/functional/ContactFormCest.php index d17ef52fd..f1ccaf18f 100644 --- a/tests/functional/ContactFormCest.php +++ b/tests/functional/ContactFormCest.php @@ -1,6 +1,6 @@ see('Contact', 'h1'); + $I->see('Contact', 'h1'); } public function submitEmptyForm(\FunctionalTester $I) @@ -38,7 +38,7 @@ public function submitFormWithIncorrectEmail(\FunctionalTester $I) $I->see('Email is not a valid email address.'); $I->dontSee('Subject cannot be blank', '.help-inline'); $I->dontSee('Body cannot be blank', '.help-inline'); - $I->dontSee('The verification code is incorrect', '.help-inline'); + $I->dontSee('The verification code is incorrect', '.help-inline'); } public function submitFormSuccessfully(\FunctionalTester $I) @@ -52,6 +52,6 @@ public function submitFormSuccessfully(\FunctionalTester $I) ]); $I->seeEmailIsSent(); $I->dontSeeElement('#contact-form'); - $I->see('Thank you for contacting us. We will respond to you as soon as possible.'); + $I->see('Thank you for contacting us. We will respond to you as soon as possible.'); } } diff --git a/tests/functional/LoginFormCest.php b/tests/functional/LoginFormCest.php index 7a83a27d6..a1545a706 100644 --- a/tests/functional/LoginFormCest.php +++ b/tests/functional/LoginFormCest.php @@ -10,7 +10,6 @@ public function _before(\FunctionalTester $I) public function openLoginPage(\FunctionalTester $I) { $I->see('Login', 'h1'); - } // demonstrates `amLoggedInAs` method @@ -54,6 +53,6 @@ public function loginSuccessfully(\FunctionalTester $I) 'LoginForm[password]' => 'admin', ]); $I->see('Logout (admin)'); - $I->dontSeeElement('form#login-form'); + $I->dontSeeElement('form#login-form'); } -} \ No newline at end of file +} diff --git a/tests/unit/models/LoginFormTest.php b/tests/unit/models/LoginFormTest.php index 3c1dcddaa..6f96c2377 100644 --- a/tests/unit/models/LoginFormTest.php +++ b/tests/unit/models/LoginFormTest.php @@ -47,5 +47,4 @@ public function testLoginCorrect() verify(\Yii::$app->user->isGuest)->false(); verify($this->model->errors)->arrayHasNotKey('password'); } - } diff --git a/tests/unit/models/UserTest.php b/tests/unit/models/UserTest.php index 28986cbbd..3db9772a3 100644 --- a/tests/unit/models/UserTest.php +++ b/tests/unit/models/UserTest.php @@ -19,7 +19,7 @@ public function testFindUserByAccessToken() verify($user = User::findIdentityByAccessToken('100-token'))->notEmpty(); verify($user->username)->equals('admin'); - verify(User::findIdentityByAccessToken('non-existing'))->empty(); + verify(User::findIdentityByAccessToken('non-existing'))->empty(); } public function testFindUserByUsername() @@ -38,7 +38,6 @@ public function testValidateUser() verify($user->validateAuthKey('test102key'))->empty(); verify($user->validatePassword('admin'))->notEmpty(); - verify($user->validatePassword('123456'))->empty(); + verify($user->validatePassword('123456'))->empty(); } - } diff --git a/tests/unit/widgets/AlertTest.php b/tests/unit/widgets/AlertTest.php index e9857a161..af2db5d21 100644 --- a/tests/unit/widgets/AlertTest.php +++ b/tests/unit/widgets/AlertTest.php @@ -177,7 +177,8 @@ public function testMultipleWarningMessages() verify($renderingResult)->stringNotContainsString('alert-info'); } - public function testSingleMixedMessages() { + public function testSingleMixedMessages() + { $errorMessage = 'This is an error message'; $dangerMessage = 'This is a danger message'; $successMessage = 'This is a success message'; @@ -204,7 +205,8 @@ public function testSingleMixedMessages() { verify($renderingResult)->stringContainsString('alert-warning'); } - public function testMultipleMixedMessages() { + public function testMultipleMixedMessages() + { $firstErrorMessage = 'This is the first error message'; $secondErrorMessage = 'This is the second error message'; $firstDangerMessage = 'This is the first danger message'; diff --git a/views/layouts/main.php b/views/layouts/main.php index 8de99c540..c204435c0 100644 --- a/views/layouts/main.php +++ b/views/layouts/main.php @@ -11,28 +11,30 @@ use yii\bootstrap5\NavBar; AppAsset::register($this); + +$this->registerCsrfMetaTags(); +$this->registerMetaTag(['charset' => Yii::$app->charset], 'charset'); +$this->registerMetaTag(['name' => 'viewport', 'content' => 'width=device-width, initial-scale=1, shrink-to-fit=no']); +$this->registerMetaTag(['name' => 'description', 'content' => $this->params['meta_description'] ?? '']); +$this->registerMetaTag(['name' => 'keywords', 'content' => $this->params['meta_keywords'] ?? '']); +$this->registerLinkTag(['rel' => 'icon', 'type' => 'image/x-icon', 'href' => Yii::getAlias('@web/favicon.ico')]); ?> beginPage() ?> - - - registerCsrfMetaTags() ?> <?= Html::encode($this->title) ?> head() ?> beginBody() ?> -
+ -
+
- isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], - ]) ?> + params['breadcrumbs'])): ?> + $this->params['breadcrumbs']]) ?> +
-