horat1us/yii2-advanced-package

Yii2 Advanced Package Template

1.0 2018-01-03 12:07 UTC

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.

Latest Stable Version Total Downloads Build Status codecov

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

License

MIT