Skip to content

Commit fe1fe5a

Browse files
committed
Prepare sample app
1 parent df19150 commit fe1fe5a

31 files changed

+1150
-0
lines changed

sample-app/.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## Editors - OS
2+
.idea
3+
.DS_Store
4+
Thumbs.db
5+
6+
## builders
7+
bower_components
8+
node_modules
9+
10+
## Yii directories
11+
assets/*
12+
protected/runtime/*
13+
protected/vendor/*
14+
15+
## Angular directories
16+
protected/assets/angular/sources/app/generated
17+
protected/assets/angular/sources/vendor
18+
protected/assets/angular/build
19+
20+
## Disallow config stuff in git
21+
protected/config/*-dev.php
22+
protected/config/dev
23+
protected/config/int
24+
protected/config/prp
25+
protected/config/prd
26+
27+
## Keep clean tests dir
28+
tests/codeception/_output/*
29+
tests/codeception/_support/*
30+
31+
## Force files to keep
32+
!.gitkeep

sample-app/.htaccess

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#In order to define current system change environment
2+
# prd | prp | int | dev
3+
SetEnv YII_ENV prd
4+
#If debug is needed define YII DEBUG
5+
#SetEnv YII_DEBUG
6+
#If maintenance mode is needed define YII_MAINTENANCE
7+
#SetEnv YII_MAINTENANCE
8+
9+
Options +Multiviews
10+
11+
RewriteEngine on
12+
13+
## Force HTTPS if needed
14+
#RewriteCond %{HTTPS} off
15+
#RewriteCond %{REQUEST_URI} !^/images/.*$ [NC]
16+
#RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
17+
18+
## Disallow access to git and dev resources
19+
RewriteRule ^(.*/)?\.git+ - [R=404,L]
20+
RewriteRule ^(.*/)?\.yml+ - [R=404,L]
21+
RewriteRule ^(.*/)?\.ht+ - [R=404,L]
22+
RewriteRule ^\.buildpacks$ - [R=404,L]
23+
RewriteRule ^(.*)\.md$ - [R=404,L]
24+
RewriteRule ^composer\.+ - [R=404,L]
25+
RewriteRule ^package\.+ - [R=404,L]
26+
RewriteRule ^bower\.+ - [R=404,L]
27+
RewriteRule ^gulpfile\.+ - [R=404,L]
28+
RewriteRule ^webpack\.+ - [R=404,L]
29+
RewriteRule ^tsconfig\.+ - [R=404,L]
30+
31+
RewriteCond %{REQUEST_FILENAME} !-f
32+
RewriteCond %{REQUEST_FILENAME} !-d
33+
RewriteCond %{REQUEST_FILENAME} !/assets/.*$
34+
RewriteRule . index.php

sample-app/composer.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"name": "sweelix/yii2-webpack",
3+
"description": "Sweelix Yii2 webpack",
4+
"keywords": ["yii2", "framework", "sweelix", "webpack"],
5+
"type": "project",
6+
"license": "proprietary",
7+
"authors": [
8+
{
9+
"name": "Philippe Gaultier",
10+
"email": "[email protected]"
11+
}
12+
],
13+
"repositories": [
14+
],
15+
"require": {
16+
"php": ">=5.6.0",
17+
"ext-mcrypt": "*",
18+
"ext-openssl": "*",
19+
"ext-curl": "*",
20+
"ext-gd": "*",
21+
"ext-intl": "*",
22+
"yiisoft/yii2": "~2.0",
23+
"sweelix/yii2-webpack": "*"
24+
},
25+
"require-dev" : {
26+
"yiisoft/yii2-debug":"~2.0",
27+
"yiisoft/yii2-gii": "~2.0"
28+
},
29+
"config": {
30+
"vendor-dir": "protected/vendor",
31+
"process-timeout": 1800
32+
},
33+
"scripts": {
34+
"pre-install-cmd": [
35+
"@composer global require \"fxp/composer-asset-plugin:^1.2.0\""
36+
],
37+
"post-create-project-cmd": [
38+
"yii\\composer\\Installer::postCreateProject"
39+
]
40+
},
41+
"extra": {
42+
"yii\\composer\\Installer::postCreateProject": {
43+
"setPermission": [
44+
{
45+
"protected/runtime": "0777",
46+
"assets": "0777",
47+
"cache": "0777",
48+
"protected/yii": "0755"
49+
}
50+
],
51+
"generateCookieValidationKey": [
52+
"protected/config/web.php"
53+
]
54+
},
55+
"asset-installer-paths": {
56+
"npm-asset-library": "protected/vendor/npm",
57+
"bower-asset-library": "protected/vendor/bower"
58+
}
59+
}
60+
}

sample-app/index.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* index.php
4+
*
5+
* PHP version 5.6+
6+
*
7+
* Initial application script
8+
*
9+
* @author Philippe Gaultier <[email protected]>
10+
* @copyright 2010-2017 Sweelix
11+
* @license http://www.sweelix.net/license license
12+
* @version 1.3.1
13+
* @link http://www.sweelix.net
14+
* @package application\base
15+
*/
16+
17+
$configFile = __DIR__.'/protected/config/web.php';
18+
$modePath = __DIR__.'/protected/config';
19+
20+
$debug = isset($_SERVER['YII_DEBUG']) ? true : false;
21+
22+
if (isset($_SERVER['YII_ENV']) && (in_array($_SERVER['YII_ENV'], array('prd', 'dev')) === true)) {
23+
if (file_exists($modePath.'/web-'.$_SERVER['YII_ENV'].'.php') === true) {
24+
$configFile = $modePath.'/web-'.$_SERVER['YII_ENV'].'.php';
25+
}
26+
defined('YII_ENV') or define('YII_ENV', $_SERVER['YII_ENV']);
27+
}
28+
29+
if (isset($_SERVER['YII_MAINTENANCE']) === true) {
30+
defined('YII_MAINTENANCE') or define('YII_MAINTENANCE', true);
31+
} else {
32+
defined('YII_MAINTENANCE') or define('YII_MAINTENANCE', false);
33+
}
34+
35+
if ($debug === true) {
36+
// remove the following lines when in production mode
37+
defined('YII_DEBUG') or define('YII_DEBUG', true);
38+
// specify how many levels of call stack should be shown in each log message
39+
defined('YII_ENV') or define('YII_ENV', 'dev');
40+
ini_set('display_errors', '1');
41+
error_reporting(E_ALL);
42+
} else {
43+
defined('YII_ENV') or define('YII_ENV', 'prd');
44+
}
45+
46+
require(__DIR__ . '/protected/vendor/autoload.php');
47+
require(__DIR__ . '/protected/vendor/yiisoft/yii2/Yii.php');
48+
49+
$config = require($configFile);
50+
51+
(new yii\web\Application($config))->run();

sample-app/package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "ibitux-yii2-template",
3+
"version": "1.0.0",
4+
"description": "Ibitux Yii2 template",
5+
"scripts": {
6+
"test": "echo \"Error: no test specified\" && exit 1"
7+
},
8+
"author": "Philippe Gaultier <[email protected]>",
9+
"license": "proprietary",
10+
"devDependencies": {
11+
"@types\/node": "^7.0.11",
12+
"assets-webpack-plugin": "^3.5.1",
13+
"clean-webpack-plugin": "^0.1.16",
14+
"compression-webpack-plugin": "^0.3.2",
15+
"css-loader": "^0.27.3",
16+
"extract-text-webpack-plugin": "^2.1.0",
17+
"file-loader": "^0.10.1",
18+
"less": "^2.7.2",
19+
"less-loader": "^4.0.2",
20+
"node-sass": "^4.5.1",
21+
"sass-loader": "^6.0.3",
22+
"source-map-loader": "^0.2.0",
23+
"style-loader": "^0.14.1",
24+
"ts-loader": "^2.0.2",
25+
"typescript": "^2.2.1",
26+
"webpack": "^2.2.1"
27+
}
28+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* WebpackAsset.php
4+
*
5+
* PHP version 5.6+
6+
*
7+
* @author Philippe Gaultier <[email protected]>
8+
* @copyright 2010-2017 Sweelix
9+
* @license http://www.sweelix.net/license license
10+
* @version 1.3.1
11+
* @link http://www.sweelix.net
12+
* @package application\assets
13+
*/
14+
15+
namespace app\assets;
16+
17+
use sweelix\webpack\WebpackAssetBundle;
18+
use yii\web\View;
19+
20+
/**
21+
* Base webpack assets
22+
*
23+
* @author Philippe Gaultier <[email protected]>
24+
* @copyright 2010-2017 Sweelix
25+
* @license http://www.sweelix.net/license license
26+
* @version 1.3.1
27+
* @link http://www.sweelix.net
28+
* @package application\assets
29+
* @since 1.3.0
30+
*/
31+
class WebpackAsset extends WebpackAssetBundle
32+
{
33+
/**
34+
* @var string base webpack alias
35+
*/
36+
public $webpackPath = '@app/assets/webpack';
37+
38+
/**
39+
* @var array list of webpack bundles to add
40+
*/
41+
public $webpackBundles = [
42+
'manifest',
43+
'app'
44+
];
45+
46+
/**
47+
* @inheritdoc
48+
*/
49+
public $jsOptions = [
50+
'position' => View::POS_HEAD
51+
];
52+
53+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"app": {
3+
"js": "js/app.js"
4+
},
5+
"manifest": {
6+
"js": "js/manifest.js"
7+
}
8+
}

sample-app/protected/assets/webpack/dist/js/app.js

Lines changed: 80 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

sample-app/protected/assets/webpack/dist/js/app.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)