yiisoft / yii-runner
Yii application runner
Requires
- php: 8.0 - 8.5
- psr/container: ^1.0 || ^2.0
- yiisoft/config: ^1.1
- yiisoft/definitions: ^1.0 || ^2.0 || ^3.0
- yiisoft/di: ^1.0
- yiisoft/yii-event: ^2.0
Requires (Dev)
- maglnet/composer-require-checker: ^4.4
- phpunit/phpunit: ^9.6.22
- rector/rector: ^2.0.11
- roave/infection-static-analysis-plugin: ^1.25
- spatie/phpunit-watcher: ^1.23.6
- vimeo/psalm: ^4.30 || ^5.26.1 || ^6.10
- yiisoft/test-support: ^3.0.2
Suggests
- yiisoft/yii-runner-console: Allows to run console application
- yiisoft/yii-runner-http: Allows to run HTTP application
- yiisoft/yii-runner-roadrunner: Allows to run HTTP application for RoadRunner
Provides
None
Conflicts
None
Replaces
None
README
Yii Application Runner
The package defines Yii Application Runner. A runner hides application initialization details making configuration process easier.
Requirements
- PHP 8.0 - 8.5.
Installation
The package could be installed with Composer:
composer require yiisoft/yii-runner
General usage
Install one of the adapters:
Instantiate and run it in an entry script:
use Yiisoft\Yii\Runner\Http\HttpApplicationRunner; require_once __DIR__ . '/autoload.php'; (new HttpApplicationRunner( rootPath: __DIR__, debug: $_ENV['YII_DEBUG'], environment: $_ENV['YII_ENV'] ))->run();
Configuration
To configure your application, follow the Yii configuration guide. It explains where to put configuration files, register services, and set application parameters.
Choose the configuration environment with the runner's environment constructor argument, as shown in the entry
script above. For example, use dev or prod if you have defined those environments in your application.
See Yii Config environments for how to define them.
For an HTTP application, configure services in these groups:
di-web: define services and their dependencies.di-providers-web: register service providers.di-delegates-web: register additional containers to look up services in.di-tags-web: assign tags to services.
See Yii DI for configuring services, providers, delegates, and tags, and
Yii Definitions for supported service definition formats.
If your application uses different group names, pass them through the runner's diGroup, diProvidersGroup,
diDelegatesGroup, and diTagsGroup constructor arguments. See Yii Config groups
for how to map group names to configuration files.
To use an existing configuration instance, assign $runner = $runner->withConfig($config) before calling run().
To use your own PSR-11 container, assign $runner = $runner->withContainer($container) before calling run().
Both methods return a new runner instance, so use the returned value for subsequent calls.
Documentation
If you need help or have a question, the Yii Forum is a good place for that. You may also check out other Yii Community Resources.
License
The Yii Application Runner is free software. It is released under the terms of the BSD License.
Please see LICENSE for more information.
Maintained by Yii Software.