承接 dmt-software/app-skeleton 相关项目开发

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

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

dmt-software/app-skeleton

Composer 安装命令:

composer create-project dmt-software/app-skeleton

包简介

Create a new application based on Slim framework

README 文档

README

build

Installation

Replace [path] in the command below to create a new application in that location.

composer create-project dmt-software/app-skeleton [path] --stability dev

Dependency injection

Dependency is handled by Service Providers which are included within the App::initServices method. Within this method you can add more providers that list their dependencies within the Dependency Container.

see dmt-software/di-plug for container implementations that are supported.

Container

By default, the application uses Pimple container to hold the dependency injection. This can be changed to another container implementation.

PHP-DI container

composer remove pimple/pimple
composer require php-di/php-di

The container will be auto-discovered, but to ensure the chosen container implementation is used, it can be configured manually.

use DMT\Apps\App;
use DMT\DependencyInjection\ContainerFactory;
use DI\Container;
use Slim\Factory\AppFactory;

$app = new App(
    responseFactory: AppFactory::determineResponseFactory(),
    container: (new ContainerFactory())->createContainer(new Container())
);

Configuration

Get/Set

Configuration options within the configuration can easily be accessed by a dotted-slug.

$config->get(); // will return all the options as array
$config->get(option: 'option.slug'); // will return the value stored in Config::options['option']['slug'] if set
$config->get(option: 'not.set.option', default: 'value'); // will return the default when it is not set

Setting new options will use the same dotted-slug as option identifier.

// all will store the same value in the config
$config->set(value: ['option' => ['slug' => 'value']]);
$config->set(option: 'option', value: ['slug' => 'value']);
$config->set(option: 'option.slug', value: 'value');

Setting options within the configuration will use the array_replace strategy.

Loading configuration

The configuration can be loaded from a file. By default, this is a php file that returns an array or a Closure that returns an array containing the configuration options.

// file: config/application.php
return static function () {
    return [
        // settings
    ];
};

// within the application or service provider
$config->load('config/application.php');

Yaml configuration

composer require symfony/yaml

Use the ChainLoader to enable both file include and yaml config files.

use DMT\Config\Loaders\FileLoader;
use DMT\Config\Loaders\FileLoaderInterface;
use DMT\Config\Loaders\LoaderChain;
use Symfony\Component\Yaml\Yaml;

$container->set(
    id: FileLoaderInterface::class, 
    value: fn() => new LoaderChain(loaders: [
        new FileLoader(),
        new FileLoader('yaml', Yaml::parseFile(...))
    ])
);

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-03-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固