Skip to content

Use Yii2 22. #315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
100 changes: 26 additions & 74 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,80 +1,32 @@
on:
- pull_request
- push
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'psalm.xml'

push:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'psalm.xml'

name: build

jobs:
tests:
name: PHP ${{ matrix.php }} - ${{ matrix.os }}

env:
build:
uses: yiisoft/actions/.github/workflows/codeception.yml@master
with:
extensions: dom, json, gd, imagick
key: cache-v1

runs-on: ${{ matrix.os }}

strategy:
matrix:
os:
- ubuntu-latest
- windows-latest

php:
- "7.4"
- "8.0"
- "8.1"

steps:
- name: Checkout
uses: actions/checkout@v2

- 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@v1
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'

- name: Determine composer cache directory on Linux
if: matrix.os == 'ubuntu-latest'
run: |
echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Determine composer cache directory on Windows
if: matrix.os == 'windows-latest'
run: |
echo "COMPOSER_CACHE_DIR=~\AppData\Local\Composer" >> $GITHUB_ENV

- name: Cache dependencies installed with composer
uses: actions/cache@v1
with:
path: ${{ steps.cache-env.outputs.dir }}
key: php${{ matrix.php }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-${{ matrix.dependencies }}-

- name: Install dependencies with composer php PHP [5.6 - 8.0]
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Run tests with codeception
run: |
sed -i "s/'cookieValidationKey' => ''/'cookieValidationKey' => 'testkey'/" config/web.php
php -S 127.0.0.1:8080 -t public > ./runtime/yii.log 2>&1 &
vendor/bin/codecept run
shell: bash
os: >-
['ubuntu-latest', 'windows-latest']
php: >-
['8.1', '8.2', '8.3', '8.4']
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,10 @@ tests/_output/*
tests/_support/_generated

#vagrant folder
/.vagrant
/.vagrant

# node_modules
node_modules

#codeception
/c3.php
44 changes: 44 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
checks:
php: true

filter:
paths:
- "/*"
excluded_paths:
- "/config/*"
- "/runtime/*"
- "/tests/Support/*"
- "/vagrant/*"
- "/vendor/*"

build:
image: default-bionic

environment:
variables:
YII_ENV: test

php:
version: 8.4.7
ini:
xdebug.mode: coverage

nodes:
analysis:
tests:
override:
- php-scrutinizer-run

codeception:
dependencies:
override:
- composer self-update
- composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

tests:
override:
- command: vendor/bin/codecept run --coverage-xml
on_node: 1
coverage:
file: runtime/_output/coverage.xml
format: php-clover
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,31 @@ DIRECTORY STRUCTURE
REQUIREMENTS
------------

The minimum requirement by this project template that your Web server supports PHP 7.4.
The minimum requirement by this project template that your Web server supports PHP 8.1.


INSTALLATION
------------

### Install via Composer

This package requires [npm-asset](https://www.npmjs.com/) for [php-forge/foxy](https://www.github.com/php-forge/foxy),
which manages the installation of npm packages and resource compilation.

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:

~~~
composer create-project --prefer-dist yiisoft/yii2-app-basic basic
composer create-project --prefer-dist yiisoft/yii2-app-basic:22.x.dev basic
~~~

Now you should be able to access the application through the following URL, assuming `basic` is the directory
directly under the Web root.

~~~
http://localhost/basic/web/
http://localhost:8080/basic/web/
~~~

### Install from an Archive File
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions assets/AppAsset.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
Expand Down
13 changes: 10 additions & 3 deletions codeception.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@ actor: Tester
bootstrap: _bootstrap.php
paths:
tests: tests
output: tests/_output
data: tests/_data
helpers: tests/_support
output: runtime/_output
data: tests/Support/data
helpers: tests/Support
settings:
memory_limit: 1024M
colors: true
modules:
config:
Yii2:
configFile: 'config/test.php'
coverage:
enabled: true
include:
- /*
exclude:
- tests/*
- vendor/*

# To enable code coverage:
#coverage:
Expand Down
9 changes: 7 additions & 2 deletions commands/HelloController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
Expand All @@ -18,14 +21,16 @@
* @author Qiang Xue <[email protected]>
* @since 2.0
*/
class HelloController extends Controller
final class HelloController extends Controller
{
/**
* This command echoes what you have entered as the message.
*
* @param string $message the message to be echoed.
*
* @return int Exit code
*/
public function actionIndex($message = 'hello world')
public function actionIndex(string $message = 'hello world'): int
{
echo $message . "\n";

Expand Down
45 changes: 21 additions & 24 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,33 @@
},
"minimum-stability": "dev",
"require": {
"php": ">=7.4.0",
"yiisoft/yii2": "~2.0.45",
"yiisoft/yii2-bootstrap5": "~2.0.2",
"yiisoft/yii2-symfonymailer": "~2.0.3"
"php": ">=8.1.0",
"php-forge/foxy": "^0.1",
"yiisoft/yii2": "22.0.x-dev",
"yiisoft/yii2-bootstrap5": "22.x-dev",
"yiisoft/yii2-symfonymailer": "22.x-dev"
},
"require-dev": {
"yiisoft/yii2-debug": "~2.1.0",
"yiisoft/yii2-gii": "~2.2.0",
"yiisoft/yii2-faker": "~2.0.0",
"codeception/codeception": "^5.0.0 || ^4.0",
"codeception/lib-innerbrowser": "^4.0 || ^3.0 || ^1.1",
"codeception/module-asserts": "^3.0 || ^1.1",
"codeception/c3": "^2.9",
"codeception/codeception": "^5.0",
"codeception/lib-innerbrowser": "^4.0",
"codeception/module-asserts": "^3.0",
"codeception/module-filesystem": "^3.0",
"codeception/module-yii2": "^1.1",
"codeception/module-filesystem": "^3.0 || ^2.0 || ^1.1",
"codeception/verify": "^3.0 || ^2.2"
"codeception/verify": "^3.0",
"symfony/browser-kit": "^6.4|^7.3",
"symfony/process": "^6.4|^7.3",
"yiisoft/yii2-debug": "22.x-dev",
"yiisoft/yii2-faker": "22.x-dev",
"yiisoft/yii2-gii": "22.x-dev"
},
"config": {
"allow-plugins": {
"yiisoft/yii2-composer" : true
"yiisoft/yii2-composer": true,
"php-forge/foxy": true,
"codeception/c3": true
},
"process-timeout": 1800,
"fxp-asset": {
"enabled": false
}
"process-timeout": 1800
},
"scripts": {
"post-install-cmd": [
Expand All @@ -63,11 +66,5 @@
"config/web.php"
]
}
},
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
]
}
}
Loading