Skip to content

Commit 5993633

Browse files
author
Fahmi Auliya Tsani
committed
Initial Commit
0 parents  commit 5993633

Some content is hidden

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

70 files changed

+6384
-0
lines changed

.bowerrc

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

.gitignore

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
# Mac DS_Store Files
22+
.DS_Store
23+
24+
# phpunit itself is not needed
25+
phpunit.phar
26+
# local phpunit config
27+
/phpunit.xml
28+
29+
tests/_output/*
30+
tests/_support/_generated
31+
32+
#vagrant folder
33+
/.vagrant

LICENSE.md

+29
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

+233
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
<p align="center">
2+
<a href="https://github.com/yiisoft" target="_blank">
3+
<img src="https://avatars0.githubusercontent.com/u/993323" height="100px">
4+
</a>
5+
<h1 align="center">Yii 2 Basic Project Template</h1>
6+
<br>
7+
</p>
8+
9+
Yii 2 Basic Project Template is a skeleton [Yii 2](http://www.yiiframework.com/) application best for
10+
rapidly creating small projects.
11+
12+
The template contains the basic features including user login/logout and a contact page.
13+
It includes all commonly used configurations that would allow you to focus on adding new
14+
features to your application.
15+
16+
[![Latest Stable Version](https://img.shields.io/packagist/v/yiisoft/yii2-app-basic.svg)](https://packagist.org/packages/yiisoft/yii2-app-basic)
17+
[![Total Downloads](https://img.shields.io/packagist/dt/yiisoft/yii2-app-basic.svg)](https://packagist.org/packages/yiisoft/yii2-app-basic)
18+
[![Build Status](https://travis-ci.org/yiisoft/yii2-app-basic.svg?branch=master)](https://travis-ci.org/yiisoft/yii2-app-basic)
19+
20+
DIRECTORY STRUCTURE
21+
-------------------
22+
23+
assets/ contains assets definition
24+
commands/ contains console commands (controllers)
25+
config/ contains application configurations
26+
controllers/ contains Web controller classes
27+
mail/ contains view files for e-mails
28+
models/ contains model classes
29+
runtime/ contains files generated during runtime
30+
tests/ contains various tests for the basic application
31+
vendor/ contains dependent 3rd-party packages
32+
views/ contains view files for the Web application
33+
web/ contains the entry script and Web resources
34+
35+
36+
37+
REQUIREMENTS
38+
------------
39+
40+
The minimum requirement by this project template that your Web server supports PHP 5.4.0.
41+
42+
43+
INSTALLATION
44+
------------
45+
46+
### Install via Composer
47+
48+
If you do not have [Composer](http://getcomposer.org/), you may install it by following the instructions
49+
at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix).
50+
51+
You can then install this project template using the following command:
52+
53+
~~~
54+
composer create-project --prefer-dist yiisoft/yii2-app-basic basic
55+
~~~
56+
57+
Now you should be able to access the application through the following URL, assuming `basic` is the directory
58+
directly under the Web root.
59+
60+
~~~
61+
http://localhost/basic/web/
62+
~~~
63+
64+
### Install from an Archive File
65+
66+
Extract the archive file downloaded from [yiiframework.com](http://www.yiiframework.com/download/) to
67+
a directory named `basic` that is directly under the Web root.
68+
69+
Set cookie validation key in `config/web.php` file to some random secret string:
70+
71+
```php
72+
'request' => [
73+
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
74+
'cookieValidationKey' => '<secret random string goes here>',
75+
],
76+
```
77+
78+
You can then access the application through the following URL:
79+
80+
~~~
81+
http://localhost/basic/web/
82+
~~~
83+
84+
85+
### Install with Docker
86+
87+
Update your vendor packages
88+
89+
docker-compose run --rm php composer update --prefer-dist
90+
91+
Run the installation triggers (creating cookie validation code)
92+
93+
docker-compose run --rm php composer install
94+
95+
Start the container
96+
97+
docker-compose up -d
98+
99+
You can then access the application through the following URL:
100+
101+
http://127.0.0.1:8000
102+
103+
**NOTES:**
104+
- Minimum required Docker engine version `17.04` for development (see [Performance tuning for volume mounts](https://docs.docker.com/docker-for-mac/osxfs-caching/))
105+
- The default configuration uses a host-volume in your home directory `.docker-composer` for composer caches
106+
107+
108+
CONFIGURATION
109+
-------------
110+
111+
### Database
112+
113+
Edit the file `config/db.php` with real data, for example:
114+
115+
```php
116+
return [
117+
'class' => 'yii\db\Connection',
118+
'dsn' => 'mysql:host=localhost;dbname=yii2basic',
119+
'username' => 'root',
120+
'password' => '1234',
121+
'charset' => 'utf8',
122+
];
123+
```
124+
125+
**NOTES:**
126+
- Yii won't create the database for you, this has to be done manually before you can access it.
127+
- Check and edit the other files in the `config/` directory to customize your application as required.
128+
- Refer to the README in the `tests` directory for information specific to basic application tests.
129+
130+
131+
TESTING
132+
-------
133+
134+
Tests are located in `tests` directory. They are developed with [Codeception PHP Testing Framework](http://codeception.com/).
135+
By default there are 3 test suites:
136+
137+
- `unit`
138+
- `functional`
139+
- `acceptance`
140+
141+
Tests can be executed by running
142+
143+
```
144+
vendor/bin/codecept run
145+
```
146+
147+
The command above will execute unit and functional tests. Unit tests are testing the system components, while functional
148+
tests are for testing user interaction. Acceptance tests are disabled by default as they require additional setup since
149+
they perform testing in real browser.
150+
151+
152+
### Running acceptance tests
153+
154+
To execute acceptance tests do the following:
155+
156+
1. Rename `tests/acceptance.suite.yml.example` to `tests/acceptance.suite.yml` to enable suite configuration
157+
158+
2. Replace `codeception/base` package in `composer.json` with `codeception/codeception` to install full featured
159+
version of Codeception
160+
161+
3. Update dependencies with Composer
162+
163+
```
164+
composer update
165+
```
166+
167+
4. Download [Selenium Server](http://www.seleniumhq.org/download/) and launch it:
168+
169+
```
170+
java -jar ~/selenium-server-standalone-x.xx.x.jar
171+
```
172+
173+
In case of using Selenium Server 3.0 with Firefox browser since v48 or Google Chrome since v53 you must download [GeckoDriver](https://github.com/mozilla/geckodriver/releases) or [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/downloads) and launch Selenium with it:
174+
175+
```
176+
# for Firefox
177+
java -jar -Dwebdriver.gecko.driver=~/geckodriver ~/selenium-server-standalone-3.xx.x.jar
178+
179+
# for Google Chrome
180+
java -jar -Dwebdriver.chrome.driver=~/chromedriver ~/selenium-server-standalone-3.xx.x.jar
181+
```
182+
183+
As an alternative way you can use already configured Docker container with older versions of Selenium and Firefox:
184+
185+
```
186+
docker run --net=host selenium/standalone-firefox:2.53.0
187+
```
188+
189+
5. (Optional) Create `yii2_basic_tests` database and update it by applying migrations if you have them.
190+
191+
```
192+
tests/bin/yii migrate
193+
```
194+
195+
The database configuration can be found at `config/test_db.php`.
196+
197+
198+
6. Start web server:
199+
200+
```
201+
tests/bin/yii serve
202+
```
203+
204+
7. Now you can run all available tests
205+
206+
```
207+
# run all available tests
208+
vendor/bin/codecept run
209+
210+
# run acceptance tests
211+
vendor/bin/codecept run acceptance
212+
213+
# run only unit and functional tests
214+
vendor/bin/codecept run unit,functional
215+
```
216+
217+
### Code coverage support
218+
219+
By default, code coverage is disabled in `codeception.yml` configuration file, you should uncomment needed rows to be able
220+
to collect code coverage. You can run your tests and collect coverage with the following command:
221+
222+
```
223+
#collect coverage for all tests
224+
vendor/bin/codecept run -- --coverage-html --coverage-xml
225+
226+
#collect coverage only for unit tests
227+
vendor/bin/codecept run unit -- --coverage-html --coverage-xml
228+
229+
#collect coverage for unit and functional tests
230+
vendor/bin/codecept run functional,unit -- --coverage-html --coverage-xml
231+
```
232+
233+
You can see code coverage output under the `tests/_output` directory.

Vagrantfile

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

0 commit comments

Comments
 (0)