maybeworks/yii2-app.bootstrap

此包已被废弃,不再维护。未建议替代包。

Yii PHP框架2.0的应用程序运行器

安装: 134

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

公开问题: 0

类型:yii2-extension

dev-master 2016-02-25 14:28 UTC

This package is not auto-updated.

Last update: 2023-01-30 10:22:31 UTC


README

Yii PHP框架2.0的应用程序运行器

安装

通过 composer 安装此扩展是首选方法。

运行以下命令:

php composer.phar require "maybeworks/yii2-app.bootstrap" "*"

或将以下内容添加到应用程序的 composer.json 文件的 require 部分:

"maybeworks/yii2-app.bootstrap" : "*"

使用方法

替代项目结构

.
├── apps
│   ├── backend
│   │    └── ...
│   ├── console
│   │    └── ...
│   └── frontend
│         └── ...
├── common
│   └── ...
├── config
│   ├── backend.php
│   ├── bootstrap.php
│   ├── common.php
│   ├── console.php
│   ├── frontend.php
│   ├── local-example.php
│   └── local.php
├── db
│   ├── fixtures
│   │   └── ...
│   └── migrations
│        └── ...
├── runtime
│   └── ...
├── vendor
│   └── ...
├── web
│   ├── backend
│   │   ├── favicon.ico
│   │   └── index.php
│   ├── frontend
│   │   ├── favicon.ico
│   │   └── index.php
│   └── static
│       └── assets
│           └── ...
└── yii

本地配置示例 - config/local.php

<?php
/**
 * @var $this AppBootstrap
 */
return [
    'common' => [
        'components' => [
            'db' => [
                'dsn' => 'mysql:host=localhost;dbname=yii2-app',
                'username' => 'root',
                'password' => '',
            ],
            'mailer' => [
                'useFileTransport' => true,
            ],
        ],
    ],
    'backend' => [],
    'frontend' => [],
    'bootstrap' => [
        'debug' => true,
        'env' => $this::ENV_DEV,
        'aliases' => [
            'web_frontend' => 'http://site.local',
            'web_backend' => 'http://admin.site.local',
            'web_static' => 'http://static.site.local'
        ]
    ],
];

主网站点的索引文件 - web/frontend/index.php

<?php
require dirname(dirname(__DIR__)) . '/vendor/maybeworks/yii2-app.bootstrap/AppBootstrap.php';

(new AppBootstrap(
    [
        'name' => 'frontend',
        'type' => AppBootstrap::APP_WEB,
        'baseDir' => dirname(dirname(__DIR__)),
        'vendorDir' => dirname(dirname(__DIR__)) . '/vendor',
        'bootConfig' => dirname(dirname(__DIR__)) . '/config/bootstrap.php'
    ]
))->run();

命令行下的yii.php

#!/usr/bin/env php
<?php
require __DIR__ . '/vendor/maybeworks/yii2-app.bootstrap/AppBootstrap.php';

exit(
    (new AppBootstrap(
        [
            'name' => 'console',
            'type' => AppBootstrap::APP_CONSOLE,
            'baseDir' => __DIR__,
            'vendorDir' => __DIR__ . '/vendor',
            'bootConfig' => __DIR__ . '/config/bootstrap.php'
        ]
    ))->run()
);

MaybeWorks
没有什么是不可能的,限制只存在于人的心中...
maybe.works