Paul Klimov
11 years ago
72 changed files with 939 additions and 166 deletions
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
@ -1,4 +1,54 @@ |
|||||||
Extending Yii |
Extending Yii |
||||||
============= |
============= |
||||||
|
|
||||||
TDB |
Code style |
||||||
|
---------- |
||||||
|
|
||||||
|
- Extension code style should be similar to [core framework code style](https://github.com/yiisoft/yii2/wiki/Core-framework-code-style). |
||||||
|
- In case of using getter and setter for defining a property it's preferred to use method in extension code rather than property. |
||||||
|
- All classes, methods and properties should be documented using phpdoc. Note that you can use markdown and link to properties and methods |
||||||
|
using the following syntax: e.g. `[[name()]]`, `[[name\space\MyClass::name()]]`. |
||||||
|
- If you're displaying errors to developers do not translate these (i.e. do not use `\Yii::t()`). Errors should be |
||||||
|
translated only if they're displayed to end users. |
||||||
|
|
||||||
|
### Namespace and package names |
||||||
|
|
||||||
|
- Extension MUST use the type `yii2-extension` in `composer.json` file. |
||||||
|
- Extension MUST NOT use `yii` or `yii2` in the composer package name or in the namespaces used in the package. |
||||||
|
- Extension SHOULD use namespaces in this format `vendor-name\package` (all lowercase). |
||||||
|
- Extension MAY use a `yii2-` prefix in the composer vendor name (URL). |
||||||
|
- Extension MAY use a `yii2-` prefix in the repository name (URL). |
||||||
|
|
||||||
|
Distribution |
||||||
|
------------ |
||||||
|
|
||||||
|
- There should be a `readme.md` file clearly describing what extension does in English, its requirements, how to install |
||||||
|
and use it. It should be written using markdown. If you want to provide translated readme, name it as `readme_ru.md` |
||||||
|
where `ru` is your language code. If extension provides a widget it is a good idea to include some screenshots. |
||||||
|
- TBD: composer.json |
||||||
|
- It is recommended to host your extensions at github.com. |
||||||
|
|
||||||
|
Working with database |
||||||
|
--------------------- |
||||||
|
|
||||||
|
- If extension creates or modifies database schema always use Yii migrations instead of SQL files or custom scripts. |
||||||
|
|
||||||
|
Assets |
||||||
|
------ |
||||||
|
|
||||||
|
TBD |
||||||
|
|
||||||
|
Events |
||||||
|
------ |
||||||
|
|
||||||
|
TBD |
||||||
|
|
||||||
|
i18n |
||||||
|
---- |
||||||
|
|
||||||
|
TBD |
||||||
|
|
||||||
|
Testing your extension |
||||||
|
---------------------- |
||||||
|
|
||||||
|
TBD |
After Width: | Height: | Size: 69 KiB |
After Width: | Height: | Size: 41 KiB |
@ -1,5 +1,90 @@ |
|||||||
Logging |
Logging |
||||||
======= |
======= |
||||||
|
|
||||||
|
Yii provides flexible and extensible logger that is able to handle messages according to serverity level or their type. |
||||||
|
You may filter messages by multiple criteria and forward them to files, email, debugger etc. |
||||||
|
|
||||||
|
Logging basics |
||||||
|
-------------- |
||||||
|
|
||||||
|
Basic logging is as simple as calling one method: |
||||||
|
|
||||||
|
```php |
||||||
|
\Yii::info('Hello, I am a test log message'); |
||||||
|
``` |
||||||
|
|
||||||
|
### Message category |
||||||
|
|
||||||
|
Additionally to the message itself message category could be specified in order to allow filtering such messages and |
||||||
|
handing these differently. Message category is passed as a second argument of logging methods and is `application` by |
||||||
|
default. |
||||||
|
|
||||||
|
### Severity levels |
||||||
|
|
||||||
|
There are multiple severity levels and corresponding methods available: |
||||||
|
|
||||||
|
- `\Yii::trace` used maily for development purpose to indicate workflow of some code. Note that it only works in |
||||||
|
development mode when `YII_DEBUG` is set to `true`. |
||||||
|
- `\Yii::error` used when there's unrecoverable error. |
||||||
|
- `\Yii::warning` used when an error occured but execution can be continued. |
||||||
|
- `\Yii::info` used to keep record of important events such as administrator logins. |
||||||
|
|
||||||
|
Log targets |
||||||
|
----------- |
||||||
|
|
||||||
|
When one of the logging methods is called, message is passed to `\yii\log\Logger` component also accessible as |
||||||
|
`Yii::$app->log`. Logger accumulates messages in memory and then when there are enough messages or when current |
||||||
|
request finishes, sends them to different log targets, such as file or email. |
||||||
|
|
||||||
|
You may configure the targets in application configuration, like the following: |
||||||
|
|
||||||
|
```php |
||||||
|
[ |
||||||
|
'components' => [ |
||||||
|
'log' => [ |
||||||
|
'targets' => [ |
||||||
|
'file' => [ |
||||||
|
'class' => 'yii\log\FileTarget', |
||||||
|
'levels' => ['trace', 'info'], |
||||||
|
'categories' => ['yii\*'], |
||||||
|
], |
||||||
|
'email' => [ |
||||||
|
'class' => 'yii\log\EmailTarget', |
||||||
|
'levels' => ['error', 'warning'], |
||||||
|
'message' => [ |
||||||
|
'to' => ['admin@example.com', 'developer@example.com'], |
||||||
|
'subject' => 'New example.com log message', |
||||||
|
], |
||||||
|
], |
||||||
|
], |
||||||
|
], |
||||||
|
], |
||||||
|
] |
||||||
|
``` |
||||||
|
|
||||||
|
In the config above we are defining two log targets: [[\yii\log\FileTarget|file]] and [[\yii\log\EmailTarget|email]]. |
||||||
|
In both cases we are filtering messages handles by these targets by severity. In case of file target we're |
||||||
|
additionally filter by category. `yii\*` means all categories starting with `yii\`. |
||||||
|
|
||||||
|
Each log target can have a name and can be referenced via the [[targets]] property as follows: |
||||||
|
|
||||||
|
```php |
||||||
|
Yii::$app->log->targets['file']->enabled = false; |
||||||
|
``` |
||||||
|
|
||||||
|
When the application ends or [[flushInterval]] is reached, Logger will call [[flush()]] to send logged messages to |
||||||
|
different log targets, such as file, email, Web. |
||||||
|
|
||||||
|
|
||||||
|
Configuring context information |
||||||
|
------------------------------- |
||||||
|
|
||||||
|
Profiling |
||||||
|
--------- |
||||||
|
|
||||||
|
TBD |
||||||
|
|
||||||
|
- [[Yii::beginProfile()]] |
||||||
|
- [[Yii::endProfile()]] |
||||||
|
|
||||||
|
|
||||||
TDB |
|
@ -0,0 +1,25 @@ |
|||||||
|
Getting started with Yii2 development |
||||||
|
===================================== |
||||||
|
|
||||||
|
The best way to have a locally runnable webapp that uses codebase cloned from main repository is to use `yii2-dev` |
||||||
|
Composer package. Here's how to do it: |
||||||
|
|
||||||
|
1. `git clone git@github.com:yiisoft/yii2-app-basic.git`. |
||||||
|
2. Remove `.git` directory from cloned directory. |
||||||
|
3. Change `composer.json`. Instead of all stable requirements add just one `"yiisoft/yii2-dev": "*"`. |
||||||
|
4. Execute `composer install`. |
||||||
|
5. Now you have working playground that uses latest code. |
||||||
|
|
||||||
|
If you're core developer there's no extra step needed. You can change framework code under |
||||||
|
`vendor/yiisoft/yii2-dev` and push it to main repository. |
||||||
|
|
||||||
|
If you're not core developer or want to use your own fork for pull requests: |
||||||
|
|
||||||
|
1. Fork `https://github.com/yiisoft/yii2` and get your own repository address such as |
||||||
|
`git://github.com/username/yii2.git`. |
||||||
|
2. Edit `vendor/yiisoft/yii2-dev/.git/config`. Change remote `origin` url to your own: |
||||||
|
|
||||||
|
``` |
||||||
|
[remote "origin"] |
||||||
|
url = git://github.com/username/yii2.git |
||||||
|
``` |
@ -0,0 +1,175 @@ |
|||||||
|
Git workflow for Yii 2 contributors |
||||||
|
=================================== |
||||||
|
|
||||||
|
So you want to contribute to Yii? Great! But to increase the chances of your changes being accepted quickly, please |
||||||
|
follow the following steps (the first 2 steps only need to be done the first time you contribute). If you are new to git |
||||||
|
and github, you might want to first check out [github help](http://help.github.com/), [learn git](http://gitref.org/) |
||||||
|
or learn something about [git internal data model](http://nfarina.com/post/9868516270/git-is-simpler). |
||||||
|
|
||||||
|
### 1. [Fork](http://help.github.com/fork-a-repo/) the Yii repository on github and clone your fork to your development |
||||||
|
environment |
||||||
|
|
||||||
|
``` |
||||||
|
git clone git@github.com:YOUR-GITHUB-USERNAME/yii2.git |
||||||
|
``` |
||||||
|
|
||||||
|
If you have trouble setting up GIT with GitHub in Linux, or are getting errors like "Permission Denied (publickey)", |
||||||
|
then you must [setup your GIT installation to work with GitHub](http://help.github.com/linux-set-up-git/) |
||||||
|
|
||||||
|
### 2. Add the main Yii repository as an additional git remote called "upstream" |
||||||
|
|
||||||
|
Change to the directory where you cloned Yii, normally, "yii". Then enter the following command: |
||||||
|
|
||||||
|
``` |
||||||
|
git remote add upstream git://github.com/yiisoft/yii.git |
||||||
|
``` |
||||||
|
|
||||||
|
### 3. Make sure there is an issue created for the thing you are working on. |
||||||
|
|
||||||
|
All new features and bug fixes should have an associated issue to provide a single point of reference for discussion |
||||||
|
and documentation. Take a few minutes to look through the existing issue list for one that matches the contribution you |
||||||
|
intend to make. If you find one already on the issue list, then please leave a comment on that issue indicating you |
||||||
|
intend to work on that item. If you do not find an existing issue matching what you intend to work on, please open a |
||||||
|
new issue for your item. This will allow the team to review your suggestion, and provide appropriate feedback along |
||||||
|
the way. |
||||||
|
|
||||||
|
> For small changes or documentation issues, you don't need to create an issue, a pull request is enough in this case. |
||||||
|
|
||||||
|
### 4. Fetch the latest code from the main Yii branch |
||||||
|
|
||||||
|
``` |
||||||
|
git fetch upstream |
||||||
|
``` |
||||||
|
|
||||||
|
You should start at this point for every new contribution to make sure you are working on the latest code. |
||||||
|
|
||||||
|
### 5. Create a new branch for your feature based on the current Yii master branch |
||||||
|
|
||||||
|
> That's very important since you will not be able to submit more than one pull request from your account if you'll |
||||||
|
use master. |
||||||
|
|
||||||
|
Each separate bug fix or change should go in its own branch. Branch names should be descriptive and start with |
||||||
|
the number of the issue that your code relates to. If you aren't fixing any particular issue, just skip number. |
||||||
|
For example: |
||||||
|
|
||||||
|
``` |
||||||
|
git checkout upstream/master |
||||||
|
git checkout -b 999-name-of-your-branch-goes-here |
||||||
|
``` |
||||||
|
|
||||||
|
### 6. Do your magic, write your code |
||||||
|
|
||||||
|
Make sure it works :) |
||||||
|
|
||||||
|
Unit tests are always welcome. Tested and well covered code greatly simplifies the task of checking your contributions. |
||||||
|
Failing unit tests as issue description are also accepted. |
||||||
|
|
||||||
|
### 7. Update the CHANGELOG |
||||||
|
|
||||||
|
Edit the CHANGELOG file to include your change, you should insert this at the top of the file under the |
||||||
|
"Work in progress" heading, the line in the change log should look like one of the following: |
||||||
|
|
||||||
|
``` |
||||||
|
Bug #999: a description of the bug fix (Your Name) |
||||||
|
Enh #999: a description of the enhancement (Your Name) |
||||||
|
``` |
||||||
|
|
||||||
|
`#999` is the issue number that the `Bug` or `Enh` is referring to. |
||||||
|
The changelog should be grouped by type (`Bug`,`Enh`) and ordered by issue number. |
||||||
|
|
||||||
|
For very small fixes, e.g. typos and documentation changes, there is no need to update the CHANGELOG. |
||||||
|
|
||||||
|
### 8. Commit your changes |
||||||
|
|
||||||
|
add the files/changes you want to commit to the [staging area](http://gitref.org/basic/#add) with |
||||||
|
|
||||||
|
``` |
||||||
|
git add path/to/my/file.php |
||||||
|
``` |
||||||
|
|
||||||
|
You can use the `-p` option to select the changes you want to have in your commit. |
||||||
|
|
||||||
|
Commit your changes with a descriptive commit message. Make sure to mention the ticket number with `#XXX` so github will |
||||||
|
automatically link your commit with the ticket: |
||||||
|
|
||||||
|
``` |
||||||
|
git commit -m "A brief description of this change which fixes #42 goes here" |
||||||
|
``` |
||||||
|
|
||||||
|
### 9. Pull the latest Yii code from upstream into your branch |
||||||
|
|
||||||
|
``` |
||||||
|
git pull upstream master |
||||||
|
``` |
||||||
|
|
||||||
|
This ensures you have the latest code in your branch before you open your pull request. If there are any merge conflicts, |
||||||
|
you should fix them now and commit the changes again. This ensures that it's easy for the Yii team to merge your changes |
||||||
|
with one click. |
||||||
|
|
||||||
|
### 10. Having resolved any conflicts, push your code to github |
||||||
|
|
||||||
|
``` |
||||||
|
git push -u origin 999-name-of-your-branch-goes-here |
||||||
|
``` |
||||||
|
|
||||||
|
The `-u` parameter ensures that your branch will now automatically push and pull from the github branch. That means |
||||||
|
if you type `git push` the next time it will know where to push to. |
||||||
|
|
||||||
|
### 11. Open a [pull request](http://help.github.com/send-pull-requests/) against upstream. |
||||||
|
|
||||||
|
Go to your repository on github and click "Pull Request", choose your branch on the right and enter some more details |
||||||
|
in the comment box. To link the pull request to the issue put anywhere in the pull comment `#999` where 999 is the |
||||||
|
issue number. |
||||||
|
|
||||||
|
> Note that each pull-request should fix a single change. |
||||||
|
|
||||||
|
### 12. Someone will review your code |
||||||
|
|
||||||
|
Someone will review your code, and you might be asked to make some changes, if so go to step #6 (you don't need to open |
||||||
|
another pull request if your current one is still open). If your code is accepted it will be merged into the main branch |
||||||
|
and become part of the next Yii release. If not, don't be disheartened, different people need different features and Yii |
||||||
|
can't be everything to everyone, your code will still be available on github as a reference for people who need it. |
||||||
|
|
||||||
|
### 13. Cleaning it up |
||||||
|
|
||||||
|
After your code was either accepted or declined you can delete branches you've worked with from your local repository |
||||||
|
and `origin`. |
||||||
|
|
||||||
|
``` |
||||||
|
git checkout master |
||||||
|
git branch -D 999-name-of-your-branch-goes-here |
||||||
|
git push origin --delete 999-name-of-your-branch-goes-here |
||||||
|
``` |
||||||
|
|
||||||
|
### Note: |
||||||
|
|
||||||
|
To detect regressions early every merge to the Yii codebase on github will be picked up by |
||||||
|
[Travis CI](http://travis-ci.org) for an automated testrun. As core team doesn't wish to overtax this service, |
||||||
|
[`[ci skip]`](http://about.travis-ci.org/docs/user/how-to-skip-a-build/) will be included to the merge description if |
||||||
|
the pull request: |
||||||
|
|
||||||
|
* affect javascript, css or image files only, |
||||||
|
* updates the documentation, |
||||||
|
* modify fixed strings only (e.g. translation updates) |
||||||
|
|
||||||
|
Doing so will save travis from commencing testruns on changes that are not covered by tests in the first place. |
||||||
|
|
||||||
|
### Command overview (for advanced contributors) |
||||||
|
|
||||||
|
``` |
||||||
|
git clone git@github.com:YOUR-GITHUB-USERNAME/yii.git |
||||||
|
git remote add upstream git://github.com/yiisoft/yii.github |
||||||
|
``` |
||||||
|
|
||||||
|
``` |
||||||
|
git fetch upstream |
||||||
|
git checkout upstream/master |
||||||
|
git checkout -b 999-name-of-your-branch-goes-here |
||||||
|
|
||||||
|
/* do your magic, update changelog if needed */ |
||||||
|
|
||||||
|
git add path/to/my/file.php |
||||||
|
git commit -m "A brief description of this change which fixes #42 goes here" |
||||||
|
git pull upstream master |
||||||
|
git push -u origin 999-name-of-your-branch-goes-here |
||||||
|
``` |
@ -1,13 +0,0 @@ |
|||||||
Git branches and tags |
|
||||||
===================== |
|
||||||
|
|
||||||
Tags |
|
||||||
---- |
|
||||||
|
|
||||||
Each release should be tagged with v2.X.X and message "Yii 2.X.X release". |
|
||||||
|
|
||||||
Branches |
|
||||||
-------- |
|
||||||
|
|
||||||
What should be in master branch? |
|
||||||
Do we need another branches? |
|
@ -0,0 +1,12 @@ |
|||||||
|
Yii Framework 2 bootstrap extension Change Log |
||||||
|
============================================== |
||||||
|
|
||||||
|
2.0.0 beta under development |
||||||
|
---------------------------- |
||||||
|
|
||||||
|
- no changes in this release. |
||||||
|
|
||||||
|
2.0.0 alpha, December 1, 2013 |
||||||
|
----------------------------- |
||||||
|
|
||||||
|
- Initial release. |
@ -0,0 +1,13 @@ |
|||||||
|
Yii Framework 2 composer extension Change Log |
||||||
|
============================================= |
||||||
|
|
||||||
|
2.0.0 beta under development |
||||||
|
---------------------------- |
||||||
|
|
||||||
|
- Bug #1480: Fixed issue with creating extensions.php when php opcache is enabled (cebe) |
||||||
|
|
||||||
|
|
||||||
|
2.0.0 alpha, December 1, 2013 |
||||||
|
----------------------------- |
||||||
|
|
||||||
|
- Initial release. |
@ -0,0 +1,12 @@ |
|||||||
|
Yii Framework 2 debug extension Change Log |
||||||
|
========================================== |
||||||
|
|
||||||
|
2.0.0 beta under development |
||||||
|
---------------------------- |
||||||
|
|
||||||
|
- no changes in this release. |
||||||
|
|
||||||
|
2.0.0 alpha, December 1, 2013 |
||||||
|
----------------------------- |
||||||
|
|
||||||
|
- Initial release. |
@ -0,0 +1,12 @@ |
|||||||
|
Yii Framework 2 elasticsearch extension Change Log |
||||||
|
================================================== |
||||||
|
|
||||||
|
2.0.0 beta under development |
||||||
|
---------------------------- |
||||||
|
|
||||||
|
- Enh #1382: Added a debug toolbar panel for elasticsearch (cebe) |
||||||
|
|
||||||
|
2.0.0 alpha, December 1, 2013 |
||||||
|
----------------------------- |
||||||
|
|
||||||
|
- Initial release. |
@ -0,0 +1,12 @@ |
|||||||
|
Yii Framework 2 gii extension Change Log |
||||||
|
======================================== |
||||||
|
|
||||||
|
2.0.0 beta under development |
||||||
|
---------------------------- |
||||||
|
|
||||||
|
- Bug #1405: fixed disambiguation of relation names generated by gii (qiangxue) |
||||||
|
|
||||||
|
2.0.0 alpha, December 1, 2013 |
||||||
|
----------------------------- |
||||||
|
|
||||||
|
- Initial release. |
@ -0,0 +1,12 @@ |
|||||||
|
Yii Framework 2 jui extension Change Log |
||||||
|
======================================== |
||||||
|
|
||||||
|
2.0.0 beta under development |
||||||
|
---------------------------- |
||||||
|
|
||||||
|
- no changes in this release. |
||||||
|
|
||||||
|
2.0.0 alpha, December 1, 2013 |
||||||
|
----------------------------- |
||||||
|
|
||||||
|
- Initial release. |
@ -0,0 +1,7 @@ |
|||||||
|
Yii Framework 2 mongodb extension Change Log |
||||||
|
============================================ |
||||||
|
|
||||||
|
2.0.0 beta under development |
||||||
|
---------------------------- |
||||||
|
|
||||||
|
- Initial release. |
@ -0,0 +1,12 @@ |
|||||||
|
Yii Framework 2 redis extension Change Log |
||||||
|
========================================== |
||||||
|
|
||||||
|
2.0.0 beta under development |
||||||
|
---------------------------- |
||||||
|
|
||||||
|
- no changes in this release. |
||||||
|
|
||||||
|
2.0.0 alpha, December 1, 2013 |
||||||
|
----------------------------- |
||||||
|
|
||||||
|
- Initial release. |
@ -0,0 +1,12 @@ |
|||||||
|
Yii Framework 2 smarty extension Change Log |
||||||
|
=========================================== |
||||||
|
|
||||||
|
2.0.0 beta under development |
||||||
|
---------------------------- |
||||||
|
|
||||||
|
- no changes in this release. |
||||||
|
|
||||||
|
2.0.0 alpha, December 1, 2013 |
||||||
|
----------------------------- |
||||||
|
|
||||||
|
- Initial release. |
@ -0,0 +1,12 @@ |
|||||||
|
Yii Framework 2 sphinx extension Change Log |
||||||
|
=========================================== |
||||||
|
|
||||||
|
2.0.0 beta under development |
||||||
|
---------------------------- |
||||||
|
|
||||||
|
- Enh #1398: Refactor ActiveRecord to use BaseActiveRecord class of the framework (klimov-paul) |
||||||
|
|
||||||
|
2.0.0 alpha, December 1, 2013 |
||||||
|
----------------------------- |
||||||
|
|
||||||
|
- Initial release. |
@ -0,0 +1,12 @@ |
|||||||
|
Yii Framework 2 swiftmailer extension Change Log |
||||||
|
================================================ |
||||||
|
|
||||||
|
2.0.0 beta under development |
||||||
|
---------------------------- |
||||||
|
|
||||||
|
- no changes in this release. |
||||||
|
|
||||||
|
2.0.0 alpha, December 1, 2013 |
||||||
|
----------------------------- |
||||||
|
|
||||||
|
- Initial release. |
@ -0,0 +1,12 @@ |
|||||||
|
Yii Framework 2 twig extension Change Log |
||||||
|
========================================= |
||||||
|
|
||||||
|
2.0.0 beta under development |
||||||
|
---------------------------- |
||||||
|
|
||||||
|
- no changes in this release. |
||||||
|
|
||||||
|
2.0.0 alpha, December 1, 2013 |
||||||
|
----------------------------- |
||||||
|
|
||||||
|
- Initial release. |
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue