承接 nikolaposa/phoundation 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nikolaposa/phoundation

Composer 安装命令:

composer require nikolaposa/phoundation

包简介

Facilitates the routine step of bootstrapping PHP applications.

README 文档

README

Build Status Code Quality Code Coverage Latest Version PDS Skeleton

Phoundation (pronounced the same way as "foundation") facilitates the routine step of bootstrapping PHP applications.

Installation

The preferred method of installation is via Composer. Run the following command to install the latest version of a package and add it to your project's composer.json:

composer require nikolaposa/phoundation

Purpose

Bootstrapping of today's PHP applications typically comes down to:

  1. Configuration loading
  2. Dependency Injection Container initialization

Phoundation aims to reduce the amount of repetitive code needed for the application startup logic by abstracting bootstrapping process.

Usage

Given the configuration files:

config/global.php

return [
    'db' => [
        'driver' => 'pdo_mysql',
        'host' => 'localhost',
        'user' => 'root',
        'password' => 'secret',
        'dbname' => 'test',
    ],
    'dependencies' => [
        'factories' => [
            \PDO::class => function () {
                return new \PDO('sqlite::memory:');
            },
            'My\\Web\\Application' => My\Web\ApplicationFactory::class,
        ]
    ],
];

config/local.php

return [
    'db' => [
        'user' => 'admin',
        'password' => '1234',
    ],
];

Create bootstrap script which typically lives in src/bootstrap.php:

use Phoundation\Bootstrap;
use Phoundation\Config\FileConfigLoader;
use Phoundation\DependencyInjection\LaminasServiceManagerFactory;

$bootstrap = new Bootstrap(
    new FileConfigLoader(glob(sprintf('config/{{,*.}global,{,*.}%s}.php', getenv('APP_ENV') ?: 'local'), GLOB_BRACE)),
    new LaminasServiceManagerFactory()
);

return $bootstrap();

Load bootstrap in your web application root (for example public/index.php):

/* @var \Psr\Container\ContainerInterface $diContainer */
$diContainer = require  __DIR__ . '/../src/bootstrap.php';

$diContainer->get('My\\Web\\Application')->run();

Credits

License

Released under MIT License - see the License File for details.

统计信息

  • 总下载量: 9.03k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 17
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 17
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-02-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固