BootstrapInterface.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * @link http://www.yiiframework.com/
  4. * @copyright Copyright (c) 2008 Yii Software LLC
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. namespace yii\base;
  8. /**
  9. * BootstrapInterface is the interface that should be implemented by classes who want to participate in the application bootstrap process.
  10. *
  11. * The main method [[bootstrap()]] will be invoked by an application at the beginning of its `init()` method.
  12. *
  13. * Bootstrapping classes can be registered in two approaches.
  14. *
  15. * The first approach is mainly used by extensions and is managed by the Composer installation process.
  16. * You mainly need to list the bootstrapping class of your extension in the `composer.json` file like following,
  17. *
  18. * ```json
  19. * {
  20. * // ...
  21. * "extra": {
  22. * "bootstrap": "path\\to\\MyBootstrapClass"
  23. * }
  24. * }
  25. * ```
  26. *
  27. * If the extension is installed, the bootstrap information will be saved in [[Application::extensions]].
  28. *
  29. * The second approach is used by application code which needs to register some code to be run during
  30. * the bootstrap process. This is done by configuring the [[Application::bootstrap]] property:
  31. *
  32. * ```php
  33. * return [
  34. * // ...
  35. * 'bootstrap' => [
  36. * "path\\to\\MyBootstrapClass1",
  37. * [
  38. * 'class' => "path\\to\\MyBootstrapClass2",
  39. * 'prop1' => 'value1',
  40. * 'prop2' => 'value2',
  41. * ],
  42. * ],
  43. * ];
  44. * ```
  45. *
  46. * As you can see, you can register a bootstrapping class in terms of either a class name or a configuration class.
  47. *
  48. * For more details and usage information on BootstrapInterface, see the [guide article on bootstrapping applications](guide:structure-applications).
  49. *
  50. * @author Qiang Xue <qiang.xue@gmail.com>
  51. * @since 2.0
  52. */
  53. interface BootstrapInterface
  54. {
  55. /**
  56. * Bootstrap method to be called during application bootstrap stage.
  57. * @param Application $app the application currently running
  58. */
  59. public function bootstrap($app);
  60. }