Skip to content

Commit 372dd7a

Browse files
author
shpakov
committed
Initial commit
0 parents commit 372dd7a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+2726
-0
lines changed

.bowerrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory" : "vendor/bower-asset"
3+
}

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# phpstorm project files
2+
.idea
3+
4+
# netbeans project files
5+
nbproject
6+
7+
# zend studio for eclipse project files
8+
.buildpath
9+
.project
10+
.settings
11+
12+
# windows thumbnail cache
13+
Thumbs.db
14+
15+
# composer vendor dir
16+
/vendor
17+
18+
# composer itself is not needed
19+
composer.phar
20+
21+
# composer lock
22+
composer.lock
23+
24+
# Mac DS_Store Files
25+
.DS_Store
26+
27+
# phpunit itself is not needed
28+
phpunit.phar
29+
# local phpunit config
30+
/phpunit.xml
31+
32+
tests/_output/*
33+
tests/_support/_generated
34+
35+
#vagrant folder
36+
/.vagrant

LICENSE.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions
6+
are met:
7+
8+
* Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
* Redistributions in binary form must reproduce the above copyright
11+
notice, this list of conditions and the following disclaimer in
12+
the documentation and/or other materials provided with the
13+
distribution.
14+
* Neither the name of Yii Software LLC nor the names of its
15+
contributors may be used to endorse or promote products derived
16+
from this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22+
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28+
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29+
POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
![Yii Logo](https://st.timeweb.com/cloud-static/apps-logo/yii.svg)
2+
3+
# Yii
4+
5+
Пример приложения [Yii](https://www.yiiframework.com/), которое можно развернуть в **Timeweb Cloud Apps** без настройки.
6+
7+
:tada: [Демо]()
8+
9+
:rocket: [Создать свой Apps](https://timeweb.cloud/my/apps/create)
10+
11+
:books: [Документация Timeweb Cloud Apps](https://timeweb.cloud/docs/apps)
12+
13+
## <a name="dev"></a>Локальный запуск проекта
14+
15+
```bash
16+
# установка зависимостей
17+
composer install
18+
19+
# запуск приложения
20+
php yii serve
21+
```

Vagrantfile

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
require 'yaml'
2+
require 'fileutils'
3+
4+
required_plugins_installed = nil
5+
required_plugins = %w( vagrant-hostmanager vagrant-vbguest )
6+
required_plugins.each do |plugin|
7+
unless Vagrant.has_plugin? plugin
8+
system "vagrant plugin install #{plugin}"
9+
required_plugins_installed = true
10+
end
11+
end
12+
13+
# IF plugin[s] was just installed - restart required
14+
if required_plugins_installed
15+
# Get CLI command[s] and call again
16+
system 'vagrant' + ARGV.to_s.gsub(/\[\"|\", \"|\"\]/, ' ')
17+
exit
18+
end
19+
20+
domains = {
21+
app: 'yii2basic.test'
22+
}
23+
24+
vagrantfile_dir_path = File.dirname(__FILE__)
25+
26+
config = {
27+
local: vagrantfile_dir_path + '/vagrant/config/vagrant-local.yml',
28+
example: vagrantfile_dir_path + '/vagrant/config/vagrant-local.example.yml'
29+
}
30+
31+
# copy config from example if local config not exists
32+
FileUtils.cp config[:example], config[:local] unless File.exist?(config[:local])
33+
# read config
34+
options = YAML.load_file config[:local]
35+
36+
# check github token
37+
if options['github_token'].nil? || options['github_token'].to_s.length != 40
38+
puts "You must place REAL GitHub token into configuration:\n/yii2-app-basic/vagrant/config/vagrant-local.yml"
39+
exit
40+
end
41+
42+
# vagrant configurate
43+
Vagrant.configure(2) do |config|
44+
# select the box
45+
config.vm.box = 'bento/ubuntu-18.04'
46+
47+
# should we ask about box updates?
48+
config.vm.box_check_update = options['box_check_update']
49+
50+
config.vm.provider 'virtualbox' do |vb|
51+
# machine cpus count
52+
vb.cpus = options['cpus']
53+
# machine memory size
54+
vb.memory = options['memory']
55+
# machine name (for VirtualBox UI)
56+
vb.name = options['machine_name']
57+
end
58+
59+
# machine name (for vagrant console)
60+
config.vm.define options['machine_name']
61+
62+
# machine name (for guest machine console)
63+
config.vm.hostname = options['machine_name']
64+
65+
# network settings
66+
config.vm.network 'private_network', ip: options['ip']
67+
68+
# sync: folder 'yii2-app-advanced' (host machine) -> folder '/app' (guest machine)
69+
config.vm.synced_folder './', '/app', owner: 'vagrant', group: 'vagrant'
70+
71+
# disable folder '/vagrant' (guest machine)
72+
config.vm.synced_folder '.', '/vagrant', disabled: true
73+
74+
# hosts settings (host machine)
75+
config.vm.provision :hostmanager
76+
config.hostmanager.enabled = true
77+
config.hostmanager.manage_host = true
78+
config.hostmanager.ignore_private_ip = false
79+
config.hostmanager.include_offline = true
80+
config.hostmanager.aliases = domains.values
81+
82+
# quick fix for failed guest additions installations
83+
# config.vbguest.auto_update = false
84+
85+
# provisioners
86+
config.vm.provision 'shell', path: './vagrant/provision/once-as-root.sh', args: [options['timezone'], options['ip']]
87+
config.vm.provision 'shell', path: './vagrant/provision/once-as-vagrant.sh', args: [options['github_token']], privileged: false
88+
config.vm.provision 'shell', path: './vagrant/provision/always-as-root.sh', run: 'always'
89+
90+
# post-install message (vagrant console)
91+
config.vm.post_up_message = "App URL: http://#{domains[:app]}"
92+
end

assets/AppAsset.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/**
3+
* @link https://www.yiiframework.com/
4+
* @copyright Copyright (c) 2008 Yii Software LLC
5+
* @license https://www.yiiframework.com/license/
6+
*/
7+
8+
namespace app\assets;
9+
10+
use yii\web\AssetBundle;
11+
12+
/**
13+
* Main application asset bundle.
14+
*
15+
* @author Qiang Xue <qiang.xue@gmail.com>
16+
* @since 2.0
17+
*/
18+
class AppAsset extends AssetBundle
19+
{
20+
public $basePath = '@webroot';
21+
public $baseUrl = '@web';
22+
public $css = [
23+
'css/site.css',
24+
];
25+
public $js = [
26+
];
27+
public $depends = [
28+
'yii\web\YiiAsset',
29+
'yii\bootstrap5\BootstrapAsset'
30+
];
31+
}

codeception.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
actor: Tester
2+
bootstrap: _bootstrap.php
3+
paths:
4+
tests: tests
5+
output: tests/_output
6+
data: tests/_data
7+
helpers: tests/_support
8+
settings:
9+
memory_limit: 1024M
10+
colors: true
11+
modules:
12+
config:
13+
Yii2:
14+
configFile: 'config/test.php'
15+
16+
# To enable code coverage:
17+
#coverage:
18+
# #c3_url: http://localhost:8080/index-test.php/
19+
# enabled: true
20+
# #remote: true
21+
# #remote_config: '../codeception.yml'
22+
# whitelist:
23+
# include:
24+
# - models/*
25+
# - controllers/*
26+
# - commands/*
27+
# - mail/*

commands/HelloController.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* @link https://www.yiiframework.com/
4+
* @copyright Copyright (c) 2008 Yii Software LLC
5+
* @license https://www.yiiframework.com/license/
6+
*/
7+
8+
namespace app\commands;
9+
10+
use yii\console\Controller;
11+
use yii\console\ExitCode;
12+
13+
/**
14+
* This command echoes the first argument that you have entered.
15+
*
16+
* This command is provided as an example for you to learn how to create console commands.
17+
*
18+
* @author Qiang Xue <qiang.xue@gmail.com>
19+
* @since 2.0
20+
*/
21+
class HelloController extends Controller
22+
{
23+
/**
24+
* This command echoes what you have entered as the message.
25+
* @param string $message the message to be echoed.
26+
* @return int Exit code
27+
*/
28+
public function actionIndex($message = 'hello world')
29+
{
30+
echo $message . "\n";
31+
32+
return ExitCode::OK;
33+
}
34+
}

composer.json

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"name": "yiisoft/yii2-app-basic",
3+
"description": "Yii 2 Basic Project Template",
4+
"keywords": ["yii2", "framework", "basic", "project template"],
5+
"homepage": "https://www.yiiframework.com/",
6+
"type": "project",
7+
"license": "BSD-3-Clause",
8+
"support": {
9+
"issues": "https://github.com/yiisoft/yii2/issues?state=open",
10+
"forum": "https://www.yiiframework.com/forum/",
11+
"wiki": "https://www.yiiframework.com/wiki/",
12+
"irc": "ircs://irc.libera.chat:6697/yii",
13+
"source": "https://github.com/yiisoft/yii2"
14+
},
15+
"minimum-stability": "stable",
16+
"require": {
17+
"php": ">=7.4.0",
18+
"yiisoft/yii2": "~2.0.45",
19+
"yiisoft/yii2-bootstrap5": "~2.0.2",
20+
"yiisoft/yii2-symfonymailer": "~2.0.3"
21+
},
22+
"require-dev": {
23+
"yiisoft/yii2-debug": "~2.1.0",
24+
"yiisoft/yii2-gii": "~2.2.0",
25+
"yiisoft/yii2-faker": "~2.0.0",
26+
"phpunit/phpunit": "~9.5.0",
27+
"codeception/codeception": "^5.0.0 || ^4.0",
28+
"codeception/lib-innerbrowser": "^4.0 || ^3.0 || ^1.1",
29+
"codeception/module-asserts": "^3.0 || ^1.1",
30+
"codeception/module-yii2": "^1.1",
31+
"codeception/module-filesystem": "^3.0 || ^2.0 || ^1.1",
32+
"codeception/verify": "^3.0 || ^2.2",
33+
"symfony/browser-kit": "^6.0 || >=2.7 <=4.2.4"
34+
},
35+
"config": {
36+
"allow-plugins": {
37+
"yiisoft/yii2-composer" : true
38+
},
39+
"process-timeout": 1800,
40+
"fxp-asset": {
41+
"enabled": false
42+
}
43+
},
44+
"scripts": {
45+
"post-install-cmd": [
46+
"yii\\composer\\Installer::postInstall"
47+
],
48+
"post-create-project-cmd": [
49+
"yii\\composer\\Installer::postCreateProject",
50+
"yii\\composer\\Installer::postInstall"
51+
]
52+
},
53+
"extra": {
54+
"yii\\composer\\Installer::postCreateProject": {
55+
"setPermission": [
56+
{
57+
"runtime": "0777",
58+
"web/assets": "0777",
59+
"yii": "0755"
60+
}
61+
]
62+
},
63+
"yii\\composer\\Installer::postInstall": {
64+
"generateCookieValidationKey": [
65+
"config/web.php"
66+
]
67+
}
68+
},
69+
"repositories": [
70+
{
71+
"type": "composer",
72+
"url": "https://asset-packagist.org"
73+
}
74+
]
75+
}

config/__autocomplete.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/**
4+
* This class only exists here for IDE (PHPStorm/Netbeans/...) autocompletion.
5+
* This file is never included anywhere.
6+
* Adjust this file to match classes configured in your application config, to enable IDE autocompletion for custom components.
7+
* Example: A property phpdoc can be added in `__Application` class as `@property \vendor\package\Rollbar|__Rollbar $rollbar` and adding a class in this file
8+
* ```php
9+
* // @property of \vendor\package\Rollbar goes here
10+
* class __Rollbar {
11+
* }
12+
* ```
13+
*/
14+
class Yii {
15+
/**
16+
* @var \yii\web\Application|\yii\console\Application|__Application
17+
*/
18+
public static $app;
19+
}
20+
21+
/**
22+
* @property yii\rbac\DbManager $authManager
23+
* @property \yii\web\User|__WebUser $user
24+
*
25+
*/
26+
class __Application {
27+
}
28+
29+
/**
30+
* @property app\models\User $identity
31+
*/
32+
class __WebUser {
33+
}

0 commit comments

Comments
 (0)