Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. Yii 2 Composer Installer
  2. ========================
  3. This is the composer installer for [Yii framework 2.0](http://www.yiiframework.com) extensions.
  4. It implements a new composer package type named `yii2-extension`,
  5. which should be used by all Yii 2 extensions if they are distributed as composer packages.
  6. For license information check the [LICENSE](LICENSE.md)-file.
  7. [![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-composer/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-composer)
  8. [![Total Downloads](https://poser.pugx.org/yiisoft/yii2-composer/downloads.png)](https://packagist.org/packages/yiisoft/yii2-composer)
  9. Usage
  10. -----
  11. The Yii 2 Composer Installer is automatically installed with when installing the framework via Composer.
  12. To use Yii 2 composer installer, simply set the package `type` to be `yii2-extension` in your `composer.json`,
  13. like the following:
  14. ```json
  15. {
  16. "type": "yii2-extension",
  17. "require": {
  18. "yiisoft/yii2": "~2.0.0"
  19. },
  20. ...
  21. }
  22. ```
  23. You may specify a bootstrapping class in the `extra` section. The `init()` method of the class will be executed each time
  24. the Yii 2 application is responding to a request. For example,
  25. ```json
  26. {
  27. "type": "yii2-extension",
  28. ...,
  29. "extra": {
  30. "bootstrap": "yii\\jui\\Extension"
  31. }
  32. }
  33. ```
  34. The `Installer` class also implements a static method `postCreateProject()` that can be called after
  35. a Yii 2 project is created, through the `post-create-project-cmd` composer script.
  36. A similar method exists for running tasks after each `composer install` call, which sis `postInstall()`.
  37. These methods allow to run other `Installer` class methods like `setPermission()` or `generateCookieValidationKey()`,
  38. depending on the corresponding parameters set in the `extra` section of the `composer.json` file.
  39. For example,
  40. ```json
  41. {
  42. "name": "yiisoft/yii2-app-basic",
  43. "type": "project",
  44. ...
  45. "scripts": {
  46. "post-create-project-cmd": [
  47. "yii\\composer\\Installer::postCreateProject"
  48. ],
  49. "post-install-cmd": [
  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. "copyFiles": [
  65. {
  66. "config/templates/console-local.php": "config/console-local.php",
  67. "config/templates/web-local.php": "config/web-local.php",
  68. "config/templates/db-local.php": "config/db-local.php",
  69. "config/templates/cache.json": ["runtime/cache.json", true]
  70. }
  71. ],
  72. "generateCookieValidationKey": [
  73. "config/web-local.php"
  74. ]
  75. }
  76. }
  77. }
  78. ```