ipunkt/laravel-package-manager 问题修复 & 功能扩展

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

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

ipunkt/laravel-package-manager

Composer 安装命令:

composer require ipunkt/laravel-package-manager

包简介

Package Manager for laravel packages

README 文档

README

Total Downloads Latest Stable Version Latest Unstable Version License

Introduction

Package Manager helps reducing the package creation time. Therefore it supports some basic providers for laravel packages.

This package plays nicely with the laravel plugin seeder package.

Just create a new plugin with composer create-package ipunkt/laravel-package YOUR-PACKAGE-NAME and you are able to start with all the package manager supports out of the box.

Installation

Add this package as dependency by using composer require ipunkt/laravel-package-manager:^1.0

Usage

We suggest using a Package Service Provider extending the Illuminate\Support\AggregateServiceProvider and register all your package related providers as attribute like so:

<?php

namespace MyPackage\Providers;

use Illuminate\Support\AggregateServiceProvider;

class MyPackageServiceProvider extends AggregateServiceProvider
{
	/**
	 * The provider class names.
	 *
	 * @var array
	 */
	protected $providers = [
		ConfigProvider::class,
		BindingsProvider::class,
		ArtisanProvider::class,
		MigrationsProvider::class,
		TranslationsProvider::class,
		BladeProvider::class,
		RoutesProvider::class,
		ViewProvider::class,
		EventsProvider::class,
	];
}

And in your composer.json simply auto-register only your aggregate service provider like so:

{
	"extra": {
        "laravel": {
            "providers": [
                "MyPackage\\Providers\\MyPackageServiceProvider"
            ]
        }
    }
}

Base Service Providers included

We include various service providers for the most common package needs. So you can simply use / extend them and at it to your package service provider.

Package Configuration

If you want to register package configuration you have to extend the ConfigurationServiceProvider.

First of all, please add a protected $packagePath to your extended service provider class and give it a value for the package root folder like so: protected $packagePath = __DIR__ . '/../../';. This is necessary to mark your files relative to the package root.

You have to add your configuration files in attribute $configurationFiles. File by file as array item. If you want to give an alias for config you have to set is array key. For example:

Within your package you have a config/config.php and you want to have it published and merged as my-package you have to set it like so

'my-package' => 'config/config.php'

Then you can get config values by using config('my-package.).

Routes

For providing routes you have to extend the RouteServiceProvider.

First of all, please add a protected $packagePath to your extended service provider class and give it a value for the package root folder like so: protected $packagePath = __DIR__ . '/../../';. This is necessary to mark your files relative to the package root.

Just set $routesNamespace, $routesMiddleware and $routesFile to your needs and you are ready to go. For registering various routes you should have one provider for each type of routes file (api, web, ...).

Views / Templates

We provide the ViewServiceProvider for extension.

First of all, please add a protected $packagePath to your extended service provider class and give it a value for the package root folder like so: protected $packagePath = __DIR__ . '/../../';. This is necessary to mark your files relative to the package root.

You have to set the $namespace to your package based identifier. The $templatesFolder is set to the resources/views by default, you can override it.

Database Migrations

We provide the MigrationServiceProvider to provide database migration files from package.

First of all, please add a protected $packagePath to your extended service provider class and give it a value for the package root folder like so: protected $packagePath = __DIR__ . '/../../';. This is necessary to mark your files relative to the package root.

You have to set the $migrationsFolder to your package migrations.

Translations

We provide the TranslationServiceProvider for extension.

First of all, please add a protected $packagePath to your extended service provider class and give it a value for the package root folder like so: protected $packagePath = __DIR__ . '/../../';. This is necessary to mark your files relative to the package root.

You have to set the $namespace to your package based identifier. The $translationsFolder is set to the resources/lang by default, you can override it.

For the new implemented way for json files we also support the $useJson flag. When true the given files have to be json format.

Artisan Commands

For registering artisan console command we provide the ArtisanServiceProvider.

You have to fill the $commands array with your commands. If you provide a key this key will be the key for registration within the IoC container of laravel. The value should be the command class name like SuperCommand::class or a string e.g. SuperCommand which gets resolved to lookup a method registerSuperCommand within the service provider (protected at least to get called). So you can register more complex commands by using a separate method.

By default artisan commands will registered only on console runs. If you want to change that behaviour you can overwrite the value of $registerOnlyForConsole to make that happen.

Aliases

We provide an AliasServiceProvider to register all aliases by hand. But you should provide aliases by the new package discovery:

{
	"extra": {
		"laravel": {
			"providers": [
				"YourProvider"
			],
			"aliases": {
				"Alias": "Path\\To\\Facade"
			}
		}
	},
}

Common Resolutions

Namespace for views, config, translations, ...

Your aggregated package provider should provide a constant namespace identifier for your package. So you can re-use the same value in all your single package providers consistently.

License

Package Manager is open-sourced software licensed under the MIT license

ipunkt/laravel-package-manager 适用场景与选型建议

ipunkt/laravel-package-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.73k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2016 年 12 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「package」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 ipunkt/laravel-package-manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ipunkt/laravel-package-manager 我们能提供哪些服务?
定制开发 / 二次开发

基于 ipunkt/laravel-package-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-12-06