spescina/pkg-support 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

spescina/pkg-support

Composer 安装命令:

composer require spescina/pkg-support

包简介

Support config and language classes for creating laravel packages

README 文档

README

Build Status Coverage Status

Package Development Support

Support config and language classes for creating laravel packages

Install && Usage

Add in the target package composer.json

"require": {
    "spescina/pkg-support": "1.x"
}

Let the main package class implements the Spescina\PkgSupport\PackageInterface.
In the same class import the Spescina\PkgSupport\PkgTrait trait. Now the constructor has to respect the interface definition.

public function __construct(ServiceInterface $config, ServiceInterface $lang)
{
        $this->config = $config;
        $this->lang = $lang;
}

Then you should take care of these dependencies when instantiating the object, usually in the package service provider.

$this->app['mypackage'] = $this->app->share(function($app) {
        return new MyPackage(new Config('mypackage'), new Lang('mypackage'));
});

This constructor force the creation of a config and a lang object keeping the registration key for your package. With them, it will be possible to use Laravel Config and Lang facades from the package classes without having to specify the package prefix every time.
Assuming your class has a facade, you can now make these calls

  • MyPackage::conf() equal to Config::get('mypackage::mypackage')
  • MyPackage::conf('key') equal to Config::get('mypackage::mypackage.key')
  • MyPackage::conf('key', 'section') equal to Config::get('mypackage::section.key')
  • MyPackage::lang('key') equal to Lang::get('mypackage::mypackage.key')
  • MyPackage::lang('key', 'section') equal to Lang::get('mypackage::section.key')

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-04-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固