Giter Site home page Giter Site logo

package-fx-platform's Introduction

多平台解决方案

基本思路: 通过 路由参数 来分辨不同的平台, 通过平台的不同, 实例化不同的 Repository 来实现数据的不同调用; 本项目的作用是简化这个过程

命令列表

  • php artisan platform:make {name} : 创建一组 Repository

  • php artisan platform:init : 初始化

安装说明

  • Composer
composer require fx/platform
  • 初始化
php artisan platform:init

使用

  • 路由
// routes/web.php
use Fx\Platform\Facades\Platform;

// others ...

// 多平台路由组
Platform::route(function () {
	Route::get('test', 'HomeController@test');
});
  • 绑定
// App\Providers\AppServiceProvider

use Fx\Platform\Facades\Platform;
use App\Repositories\Contacts\UserRepository;
use App\Repositories\Admin\UserRepository as DefaultUserRepository;

public function register() 
{
	// others ...

	// UserRepository
	Platform::register(UserRepository::class, DefaultUserRepository::class);
	// Or
	// Platform::registerGroup([UserRepository::class => DefaultUserRepository::class]);
}
  • 使用
// App\Http\Controllers\HomeController
use App\Repositories\Contacts\UserRepository;

public function test(UserRepository $user)
{
	// do somethings with $user
	// eg: $users = $user->get();
}

package-fx-platform's People

Contributors

nfangxu avatar

Stargazers

zhanglingling avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.