diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
new file mode 100644
index 0000000000..9dedb8f278
--- /dev/null
+++ b/.git-blame-ignore-revs
@@ -0,0 +1,8 @@
+# Short array syntax
+99c2a89b779ede42c046602b5cf22f1acc4029ca
+# Convert to short syntax [2].
+d4cf3fa62a487696bb6e4964c7c0e39cc0a1ed29
+# Reformat code te be PSR-2 compatible
+b211b9e5f22a948a4996d6432080efbdf7bf1b30
+# Fix codestyle
+a06eb4c7ef8f2e930cf489c43aa31cdcbbbb3380
diff --git a/.gitattributes b/.gitattributes
index 3e9092c685..705fb391d0 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 3d8d32c253..ea75bda5f8 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/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000000..6727e75bd0
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,4 @@
+# These are supported funding model platforms
+
+open_collective: yiisoft
+tidelift: "packagist/yiisoft/yii2-app-advanced"
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
index 52ec8692f2..a2ee924395 100644
--- a/.github/ISSUE_TEMPLATE.md
+++ b/.github/ISSUE_TEMPLATE.md
@@ -9,6 +9,6 @@
| Q | A
| ---------------- | ---
-| Yii vesion |
+| Yii version |
| PHP version |
| Operating system |
diff --git a/.github/SECURITY.md b/.github/SECURITY.md
new file mode 100644
index 0000000000..405acca4e7
--- /dev/null
+++ b/.github/SECURITY.md
@@ -0,0 +1,6 @@
+# Security Policy
+
+Please use the [security issue form](https://www.yiiframework.com/security) to report to us any security issue you find in Yii.
+DO NOT use the issue tracker or discuss it in the public forum as it will cause more damage than help.
+
+Please note that as a non-commercial OpenSource project we are not able to pay bounties at the moment.
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 0000000000..97dda9162c
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,99 @@
+on:
+ - pull_request
+ - push
+
+name: build
+
+jobs:
+ tests:
+ name: PHP ${{ matrix.php }}-mysql-${{ matrix.mysql }}
+
+ env:
+ extensions: dom, json, gd, imagick, pdo, pdo_mysql
+ key: cache-v1
+
+ runs-on: ${{ matrix.os }}
+
+ strategy:
+ matrix:
+ os:
+ - ubuntu-latest
+
+ php:
+ - "7.4"
+ - "8.0"
+ - "8.1"
+ - "8.2"
+ - "8.3"
+ - "8.4"
+
+ mysql:
+ - "5.7"
+ - "latest"
+
+ services:
+ mysql:
+ image: mysql:${{ matrix.mysql }}
+ env:
+ MYSQL_ROOT_PASSWORD: root
+ MYSQL_DATABASE: yii2advanced_test
+ ports:
+ - 3306:3306
+ options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v5
+
+ - name: Setup cache environment
+ id: cache-env
+ uses: shivammathur/cache-extensions@v1
+ with:
+ php-version: ${{ matrix.php }}
+ extensions: ${{ env.extensions }}
+ key: ${{ env.key }}
+
+ - name: Cache extensions
+ uses: actions/cache@v4
+ with:
+ path: ${{ steps.cache-env.outputs.dir }}
+ key: ${{ steps.cache-env.outputs.key }}
+ restore-keys: ${{ steps.cache-env.outputs.key }}
+
+ - name: Install PHP with extensions
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ extensions: ${{ env.extensions }}
+ ini-values: date.timezone='UTC'
+ coverage: pcov
+
+ - name: Determine composer cache directory on Linux
+ if: matrix.os == 'ubuntu-latest'
+ run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
+
+ - name: Cache dependencies installed with composer
+ uses: actions/cache@v4
+ with:
+ path: ${{ env.COMPOSER_CACHE_DIR }}
+ key: php${{ matrix.php }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}
+ restore-keys: |
+ php${{ matrix.php }}-composer-${{ matrix.dependencies }}-
+
+ - name: Install dependencies with composer
+ run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
+
+ - name: Setup app advanced
+ run: |
+ ./init --env=Development
+ sed -i "s/'dsn' => 'mysql:host=localhost;dbname=yii2advanced_test'/'dsn' => 'mysql:host=127.0.0.1;dbname=yii2advanced_test'/" common/config/test-local.php
+ sed -i "/'db'/a 'username' => 'root'," common/config/test-local.php
+ sed -i "/'db'/a 'password' => 'root'," common/config/test-local.php
+ sed -i "s/'cookieValidationKey' => ''/'cookieValidationKey' => 'testkey'/" frontend/config/main.php
+ sed -i "s/'cookieValidationKey' => ''/'cookieValidationKey' => 'testkey'/" backend/config/main.php
+
+ - name: Apply migration
+ run: php yii_test migrate --interactive=0
+
+ - name: Run tests with codeception
+ run: vendor/bin/codecept run
diff --git a/.gitignore b/.gitignore
index 6ce615566f..3ecbfdacfb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,9 @@
# phpstorm project files
.idea
+# visual studio code project files
+.vscode
+
# netbeans project files
nbproject
@@ -33,3 +36,11 @@ phpunit.phar
# vagrant runtime
/.vagrant
+
+# ignore generated files
+/frontend/web/index.php
+/frontend/web/index-test.php
+/frontend/web/robots.txt
+/backend/web/index.php
+/backend/web/index-test.php
+/backend/web/robots.txt
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 260c020cc8..0000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,45 +0,0 @@
-language: php
-
-php:
- - 5.4
- - 5.5
- - 5.6
- - 7.0
- - 7.1
-# - hhvm
-
-# faster builds on new travis setup not using sudo
-sudo: false
-
-# cache vendor dirs
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - travis_retry composer self-update && composer --version
- - travis_retry composer update --dev --prefer-dist --no-interaction
- # install php extensions
- - |
- if (php --version | grep -i HipHop > /dev/null); then
- echo "Skipping imagick and gmagick tests on HHVM"
- else
- pear config-set preferred_state beta
- printf "\n" | pecl install imagick
- # gmagick is not installed on travis currently
- #printf "\n" | pecl install gmagick
- fi
-# setup application:
- - |
- ./init --env=Development
- sed -i s/root/travis/ common/config/main-local.php
- sed -i "s/'cookieValidationKey' => ''/'cookieValidationKey' => 'testkey'/" frontend/config/main.php
- sed -i "s/'cookieValidationKey' => ''/'cookieValidationKey' => 'testkey'/" backend/config/main.php
-
-before_script:
- - mysql -e 'CREATE DATABASE yii2advanced_test;'
- - php yii_test migrate --interactive=0
-
-script:
- - composer validate --strict
- - vendor/bin/codecept run
diff --git a/LICENSE.md b/LICENSE.md
index e98f03df86..ee872b9abf 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -1,6 +1,3 @@
-The Yii framework is free software. It is released under the terms of
-the following BSD License.
-
Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
All rights reserved.
diff --git a/README.md b/README.md
index 6acca0f433..ea3d1924b1 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
-Yii 2 Advanced Project Template is a skeleton [Yii 2](http://www.yiiframework.com/) application best for
+Yii 2 Advanced Project Template is a skeleton [Yii 2](https://www.yiiframework.com/) application best for
developing complex Web applications with multiple tiers.
The template includes three tiers: front end, back end, and console, each of which
@@ -17,9 +17,9 @@ deploying the application in different environments.
Documentation is at [docs/guide/README.md](docs/guide/README.md).
-[](https://packagist.org/packages/yiisoft/yii2-app-advanced)
-[](https://packagist.org/packages/yiisoft/yii2-app-advanced)
-[](https://travis-ci.org/yiisoft/yii2-app-advanced)
+[](https://packagist.org/packages/yiisoft/yii2-app-advanced)
+[](https://packagist.org/packages/yiisoft/yii2-app-advanced)
+[](https://github.com/yiisoft/yii2-app-advanced/actions?query=workflow%3Abuild)
DIRECTORY STRUCTURE
-------------------
diff --git a/Vagrantfile b/Vagrantfile
index 5b89ee38bf..3940bfb8d4 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -1,14 +1,25 @@
require 'yaml'
require 'fileutils'
+required_plugins_installed = nil
required_plugins = %w( vagrant-hostmanager vagrant-vbguest )
required_plugins.each do |plugin|
- exec "vagrant plugin install #{plugin}" unless Vagrant.has_plugin? plugin
+ unless Vagrant.has_plugin? plugin
+ system "vagrant plugin install #{plugin}"
+ required_plugins_installed = true
+ end
+end
+
+# IF plugin[s] was just installed - restart required
+if required_plugins_installed
+ # Get CLI command[s] and call again
+ system 'vagrant' + ARGV.to_s.gsub(/\[\"|\", \"|\"\]/, ' ')
+ exit
end
domains = {
- frontend: 'y2aa-frontend.dev',
- backend: 'y2aa-backend.dev'
+ frontend: 'y2aa-frontend.test',
+ backend: 'y2aa-backend.test'
}
config = {
@@ -30,7 +41,7 @@ end
# vagrant configurate
Vagrant.configure(2) do |config|
# select the box
- config.vm.box = 'bento/ubuntu-16.04'
+ config.vm.box = 'bento/ubuntu-18.04'
# should we ask about box updates?
config.vm.box_check_update = options['box_check_update']
@@ -68,7 +79,7 @@ Vagrant.configure(2) do |config|
config.hostmanager.aliases = domains.values
# provisioners
- config.vm.provision 'shell', path: './vagrant/provision/once-as-root.sh', args: [options['timezone']]
+ config.vm.provision 'shell', path: './vagrant/provision/once-as-root.sh', args: [options['timezone'], options['ip']]
config.vm.provision 'shell', path: './vagrant/provision/once-as-vagrant.sh', args: [options['github_token']], privileged: false
config.vm.provision 'shell', path: './vagrant/provision/always-as-root.sh', run: 'always'
diff --git a/backend/Dockerfile b/backend/Dockerfile
new file mode 100644
index 0000000000..0515d351d3
--- /dev/null
+++ b/backend/Dockerfile
@@ -0,0 +1,4 @@
+FROM yiisoftware/yii2-php:8.1-apache
+
+# Change document root for Apache
+RUN sed -i -e 's|/app/web|/app/backend/web|g' /etc/apache2/sites-available/000-default.conf
diff --git a/backend/assets/AppAsset.php b/backend/assets/AppAsset.php
index 940c0af646..7494859ea9 100644
--- a/backend/assets/AppAsset.php
+++ b/backend/assets/AppAsset.php
@@ -18,6 +18,6 @@ class AppAsset extends AssetBundle
];
public $depends = [
'yii\web\YiiAsset',
- 'yii\bootstrap\BootstrapAsset',
+ 'yii\bootstrap5\BootstrapAsset',
];
}
diff --git a/backend/codeception.yml b/backend/codeception.yml
index 703b518c11..19ad7cfbae 100644
--- a/backend/codeception.yml
+++ b/backend/codeception.yml
@@ -1,15 +1,15 @@
namespace: backend\tests
-actor: Tester
+actor_suffix: Tester
paths:
tests: tests
- log: tests/_output
+ output: tests/_output
data: tests/_data
- helpers: tests/_support
+ support: tests/_support
+bootstrap: _bootstrap.php
settings:
- bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
modules:
config:
Yii2:
- configFile: 'config/test-local.php'
+ configFile: 'config/codeception-local.php'
diff --git a/backend/config/.gitignore b/backend/config/.gitignore
index 42799dd2b7..7c090d207f 100644
--- a/backend/config/.gitignore
+++ b/backend/config/.gitignore
@@ -1,3 +1,4 @@
+codeception-local.php
main-local.php
params-local.php
test-local.php
diff --git a/backend/config/main.php b/backend/config/main.php
index 6e2fe57e52..38d02b0a33 100644
--- a/backend/config/main.php
+++ b/backend/config/main.php
@@ -1,4 +1,5 @@
YII_DEBUG ? 3 : 0,
'targets' => [
[
- 'class' => 'yii\log\FileTarget',
+ 'class' => \yii\log\FileTarget::class,
'levels' => ['error', 'warning'],
],
],
diff --git a/backend/config/params.php b/backend/config/params.php
index 7f754b91fe..6ebf2792b8 100644
--- a/backend/config/params.php
+++ b/backend/config/params.php
@@ -1,4 +1,5 @@
'admin@example.com',
];
diff --git a/backend/config/test.php b/backend/config/test.php
index ec2e9a17d9..8016d71775 100644
--- a/backend/config/test.php
+++ b/backend/config/test.php
@@ -1,4 +1,5 @@
'app-backend-tests',
'components' => [
@@ -8,5 +9,8 @@
'urlManager' => [
'showScriptName' => true,
],
+ 'request' => [
+ 'cookieValidationKey' => 'test',
+ ],
],
];
diff --git a/backend/controllers/SiteController.php b/backend/controllers/SiteController.php
index 9624dcc949..45101d0628 100644
--- a/backend/controllers/SiteController.php
+++ b/backend/controllers/SiteController.php
@@ -1,11 +1,13 @@
[
- 'class' => AccessControl::className(),
+ 'class' => AccessControl::class,
'rules' => [
[
'actions' => ['login', 'error'],
@@ -33,7 +35,7 @@ public function behaviors()
],
],
'verbs' => [
- 'class' => VerbFilter::className(),
+ 'class' => VerbFilter::class,
'actions' => [
'logout' => ['post'],
],
@@ -42,13 +44,13 @@ public function behaviors()
}
/**
- * @inheritdoc
+ * {@inheritdoc}
*/
public function actions()
{
return [
'error' => [
- 'class' => 'yii\web\ErrorAction',
+ 'class' => \yii\web\ErrorAction::class,
],
];
}
@@ -66,7 +68,7 @@ public function actionIndex()
/**
* Login action.
*
- * @return string
+ * @return string|Response
*/
public function actionLogin()
{
@@ -74,20 +76,24 @@ public function actionLogin()
return $this->goHome();
}
+ $this->layout = 'blank';
+
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
- } else {
- return $this->render('login', [
- 'model' => $model,
- ]);
}
+
+ $model->password = '';
+
+ return $this->render('login', [
+ 'model' => $model,
+ ]);
}
/**
* Logout action.
*
- * @return string
+ * @return Response
*/
public function actionLogout()
{
diff --git a/backend/tests/_bootstrap.php b/backend/tests/_bootstrap.php
index 44f5e81b65..637ce14f0f 100644
--- a/backend/tests/_bootstrap.php
+++ b/backend/tests/_bootstrap.php
@@ -1,4 +1,5 @@
'erau',
diff --git a/backend/tests/_support/FunctionalTester.php b/backend/tests/_support/FunctionalTester.php
index 80a79edc55..b354ce6c43 100644
--- a/backend/tests/_support/FunctionalTester.php
+++ b/backend/tests/_support/FunctionalTester.php
@@ -1,4 +1,5 @@
[
- 'class' => UserFixture::className(),
+ 'class' => UserFixture::class,
'dataFile' => codecept_data_dir() . 'login_data.php'
]
];
}
-
+
/**
* @param FunctionalTester $I
*/
public function loginUser(FunctionalTester $I)
{
- $I->amOnPage('/site/login');
+ $I->amOnRoute('/site/login');
$I->fillField('Username', 'erau');
$I->fillField('Password', 'password_0');
$I->click('login-button');
diff --git a/backend/tests/functional/_bootstrap.php b/backend/tests/functional/_bootstrap.php
index 30ed54b830..933ad4f3b2 100644
--- a/backend/tests/functional/_bootstrap.php
+++ b/backend/tests/functional/_bootstrap.php
@@ -1,4 +1,5 @@
+beginPage() ?>
+
+
+
+
+
+ registerCsrfMetaTags() ?>
+ = Html::encode($this->title) ?>
+ head() ?>
+
+
+beginBody() ?>
+
+
+
+ = $content ?>
+
+
+
+endBody() ?>
+
+
+endPage();
diff --git a/backend/views/layouts/main.php b/backend/views/layouts/main.php
index 8585fffc3d..9cdb6c71c3 100644
--- a/backend/views/layouts/main.php
+++ b/backend/views/layouts/main.php
@@ -1,38 +1,37 @@
beginPage() ?>
-
+
-
-
- = Html::csrfMetaTags() ?>
+
+ registerCsrfMetaTags() ?>
= Html::encode($this->title) ?>
head() ?>
-
+
beginBody() ?>
-
+
Yii::$app->name,
'brandUrl' => Yii::$app->homeUrl,
'options' => [
- 'class' => 'navbar-inverse navbar-fixed-top',
+ 'class' => 'navbar navbar-expand-md navbar-dark bg-dark fixed-top',
],
]);
$menuItems = [
@@ -40,23 +39,26 @@
];
if (Yii::$app->user->isGuest) {
$menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
+ }
+ echo Nav::widget([
+ 'options' => ['class' => 'navbar-nav me-auto mb-2 mb-md-0'],
+ 'items' => $menuItems,
+ ]);
+ if (Yii::$app->user->isGuest) {
+ echo Html::tag('div',Html::a('Login',['/site/login'],['class' => ['btn btn-link login text-decoration-none']]),['class' => ['d-flex']]);
} else {
- $menuItems[] = ''
- . Html::beginForm(['/site/logout'], 'post')
+ echo Html::beginForm(['/site/logout'], 'post', ['class' => 'd-flex'])
. Html::submitButton(
'Logout (' . Yii::$app->user->identity->username . ')',
- ['class' => 'btn btn-link logout']
+ ['class' => 'btn btn-link logout text-decoration-none']
)
- . Html::endForm()
- . '';
+ . Html::endForm();
}
- echo Nav::widget([
- 'options' => ['class' => 'navbar-nav navbar-right'],
- 'items' => $menuItems,
- ]);
NavBar::end();
?>
+
+
= Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
@@ -64,17 +66,16 @@
= Alert::widget() ?>
= $content ?>
-
+
-