maybeworks/yii2-app.bootstrap

This package is abandoned and no longer maintained. No replacement package was suggested.

Application runner for Yii PHP framework 2.0

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

This package is not auto-updated.

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


README

Application runner for Yii PHP framework 2.0

Installation

The preferred way to install this extension is through composer.

Either run

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

or add

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

to the require section of your application's composer.json file.

Usage

Alternative project structure

.
├── 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

Local config example - 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'
        ]
    ],
];

Index file for main web point - 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 for cmd

#!/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
Nothing is impossible, limit exists only in the minds of...
maybe.works