Skip to content

Instantly share code, notes, and snippets.

@kejyun
kejyun / cloudSettings
Last active March 24, 2020 03:32
kj-vscode-php-setting
{"lastUpload":"2020-03-24T03:32:23.893Z","extensionVersion":"v3.4.3"}
<?php
// A nice simple route to show a pokemons name if we can find it using our Service
// 一個簡單的路由去顯示 pokemon 名稱,我們可以發現它使用我們的服務去取得 pokemon 資料
Route::any('/pokemon/{pokemon}', function($pokemon) {
return Pokemon::getPokemon($pokemon);
});
<?php
// A nice simple route to show a pokemons name if we can find it using our Service
Route::any('/pokemon/{pokemon}', function($pokemon) {
return Pokemon::getPokemon($pokemon);
});
<?php
// app/database/migrations/2015_01_25_085024_create_pokemon_table.php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePokemonTable extends Migration {
/**
* Run the migrations.
<?php
// app/config/app.php
// ....
'aliases' => array(
'Pokemon' => 'Services\Pokemon\PokemonFacade',
),
<?php
// app/config/app.php
// ....
'providers' => array(
'Repositories\Pokemon\PokemonRepositoryServiceProvider',
'Services\Pokemon\PokemonServiceServiceProvider',
),
"autoload": {
"classmap": [
"app/models/entities",
"app/models/repositories",
"app/models/repositories/pokemon",
"app/models/services",
"app/models/services/pokemon",
]
},
<?php namespace Services\Pokemon;
// model/Services/Pokemon/PokemonFacade.php
use \Illuminate\Support\Facades\Facade;
/**
* Facade class to be called whenever the class PokemonService is called
* Facade 類別當 PokemonService 被呼叫時呼叫
*/
class PokemonFacade extends Facade {
<?php namespace Services\Pokemon;
// model/Services/Pokemon/PokemonService.php
use Repositories\Pokemon\PokemonInterface;
/**
* Our PokemonService, containing all useful methods for business logic around Pokemon
* 我們的 PokemonService 服務,包含所有在 Pokemon 的商業邏輯中有用的方法
*/
class PokemonService
<?php namespace Services\Pokemon;
// model/Services/Pokemon/PokemonServiceServiceProvider.php
use Illuminate\Support\ServiceProvider;
/**
* Register our pokemon service with Laravel
* 註冊我們的 pokemon 服務到 Laravel
*/
class PokemonServiceServiceProvider extends ServiceProvider