horat1us / yii2-advanced-package
Yii2 Advanced Package Template
Installs: 10
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:project
Requires
- php: >=7.0
- yiisoft/yii2: ~2.0.13.1
Requires (Dev)
- phpunit/phpunit: ^6.5
- yiisoft/yii2-phpunit: dev-master
This package is auto-updated.
Last update: 2024-10-24 01:52:32 UTC
README
Yii 2 Advanced Package Template is a skeleton Yii 2 package best for developing complex composer packages with migrations and unit tests.
Installation
As dependency
- install using composer
composer require horat1us/yii2-advanced-package
- add to your
bootstrap.php
:
<?php // bootstrap.php Yii::setAlias( '@Horat1us/Package/Migrations', // your namespace here "path-to-vendor/horat1us/yii2-advanced-package/migrations" // path to package migrations folder );
- add to your console
config.php
:
<?php // console/config.php use yii\console\controllers\MigrateController; return [ // some code 'controllerMap' => [ 'migrate' => [ 'class' => MigrateController::class, 'migrationNamespaces' => [ 'Horat1us\\Package\\Migrations', ], ], ], ];
As new project
composer create-project horat1us/yii2-advanced-package path-to-new-project
then you need to change project name in composer.json and modify namespaces
Tests
Run tests:
./vendor/bin/phpunit
Configuration
Default project configuration available in tests/config.php.
If you want to use local config just create tests/config-local.php
with configuration array.
Structure
migrations/ contains namespaced migrations (using Yii2 namespace autoloader)
src/ contains all source files (using composer autoloader)
tests/
Mocks/ contains mocks for tests
Fixtures/ contains Yii2 fixtures
Unit/ contains PHPUnit tests
vendor/ contains dependent 3rd-party packages