分離式客製化開發

接案的架構問題...

業界常見問題

我遇到的問題

System/
Customization/

母類別
子類別

Laravel-Modules

UI

resources/views/vendor/awesome/homepage.blade.php


Modules/Awesome/Resources/views/homepage.blade.php

System/
Customization/

controller 與 routing

Route::group(['middleware' => 'web', 'namespace' => 'Modules\Awesome\Http\Controllers'], function()
{
    Route::get('/shopping/cart', 'ShoppingController@cart');
    // blah blah...
});
Route::get('/shopping/cart', 'ShoppingController@cart');
namespace App\Http\Controllers;

use Modules\Awesome\Http\Controllers\ShoppingController as BaseController;
use Illuminate\Http\Request;

class ShoppingController extends BaseController
{
    function cart(Request $request)
    {
        // 隨你修改商業邏輯 ...

        // 繼續用原有模板與覆蓋機制
        // return view('awesome::shopping.cart');

        // 或是在 resources/views/ 內建一個新的也行
        return view('the-new-cart');
    }
}

System/
Customization/

Domain Model

namespace Modules\Awesome;

use Illuminate\Database\Eloquent\Model;

class Cart extends Model
{
    // blah ...
}
namespace App;

use Modules\Awesome\Cart as BaseCart;

class Cart extends BaseCart
{
    // blah ...
}

System/
Customization/

全新的功能

migration file

System/
Customization/

Sample

https://github.com/howtomakeaturn/nomadic

live coding

Made with Slides.com