Skip to content

Instantly share code, notes, and snippets.

@jepster
jepster / my.html
Created July 31, 2015 06:16
my.html
<script src="/assets/3598bbc6/js/YOUR-JavaScriptFile.js"></script>
<?php
// that class is usually used, if you work with html in your view.
use yii\helpers\Html;
// here comes your Yii2 asset's class!
use app\modules\YOUR-MODULE\assets\YOUR-ASSER-CLASS;
// now Yii puts your css and javascript files into your view's html.
MyModuleAsset::register($this);
<?php
namespace app\modules\MY-MODULE\assets;
use yii\web\AssetBundle;
class MyModuleAsset extends AssetBundle
{
// the alias to your assets folder in your file system
public $sourcePath = '@yiipass-assets';
<?php
namespace app\modules\MY-MODULE;
class Module extends \yii\base\Module
{
public $controllerNamespace = 'app\modules\MY-MODULE\controllers';
public function init()
{
<?php
/* @var $xml app\modules\yiipass\services\xml */
$xml = \Yii::$app->getModule('MY-MODULE')->get('xml');
<?php
namespace app\modules\MY-MODULE;
class Module extends \yii\base\Module
{
public $controllerNamespace = 'app\modules\MY-MODULE\controllers';
public function init()
{
@jepster
jepster / yii_boot_console.inc.php
Created December 18, 2014 17:55
yii_boot_console.inc.php
<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
// fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));
require_once(__DIR__ . '/vendor/autoload.php');
require_once(__DIR__ . '/vendor/yiisoft/yii2/Yii.php');
@jepster
jepster / yii2-phpunit-test.php
Created December 18, 2014 17:45
Yii2 PHPUnit Test
<?php
use app\tests\fixtures\ModelFixtureDataCreator;
class MyTest extends PHPUnit_Framework_TestCase
{
protected function setUp()
{
require_once 'yii_booter_for_tests.php';
@jepster
jepster / yii2-phpunit-test.php
Created December 18, 2014 17:44
Yii2 PHPUnit Test
<?php
use app\commands\ObjectExportController;
use app\tests\fixtures\ModelFixtureDataCreator;
class MyTest extends PHPUnit_Framework_TestCase
{
protected function setUp()
{
require_once 'yii_booter_for_tests.php';
@jepster
jepster / yii2-phpunit-test
Created December 18, 2014 17:44
Yii2 PHPUnit Test
use app\commands\ObjectExportController;
use app\tests\fixtures\ModelFixtureDataCreator;
class MyTest extends PHPUnit_Framework_TestCase
{
protected function setUp()
{
require_once 'yii_booter_for_tests.php';
$test_classname = get_class($this);