如何更快速學習

這邊歸納出我目前學會或認知到的"如何更快速更有效率的學習總結"。 學習路線和方向 一旦學習有了方向跟路線,按部就班的學習和在流程內,那麼學習到的概念就會是務實的。 目標 假如想要找一門程式語言找工作,但不知道學習哪個項目好,不如打開你最想去的公司的技能需求,一但有了明確的目標學習起來就會有方向了。 獨具慧眼 在挑選學習項目時,其實最重要的不是工具的好壞,而是效率跟性價比問題,所以在做選擇時必須衡量過時間成本和投入資源,取得一個適合自己的最佳解。 弱連結 很多時候當下學習的項目看起來沒什麼幫助,但實際上都會是相關聯的,只要是在同個領域必然存在著弱連結,不妨先建立一個 indexing 的概念,日後有應用時就藉由弱連結找到解法。 回想 在快速變化的產業與時代,很多時候面向的是快速與廣度問題,不需要每個東西都牢牢記住,但能夠快速回想曾經有看過,如同上個原則,這個時代講究的是廣度,深度是指你所擅長的事情,而廣度是支持你強大的關鍵。 回饋 徵求良好的回饋和想法,不是每個想法都是好的,但試著去詢問和找尋回饋讓自己變得更好。 筆記 這邊說的筆記不是指要做的多精美和多有規範,相反我提倡快速筆記,跳躍筆記,並且閱讀自己的筆記去做連結學習,注意筆記是輔助理解問題,而不是最終的產品。

April 2, 2022 Â· 1 min Â· Yish

Define the Version in Laravel

This idea is inspiring from laravel codebase, web.php, it’s a useful and simple. // As you can see, it can be used to define the api or code version simplify. if (! defined('DEFAULT_VERSION')) { define('DEFAULT_VERSION', '9.x'); } if (! defined('SHOW_VAPOR')) { define('SHOW_VAPOR', random_int(1, 2) === 1); } // Also you can do something when definition was equaled. if (! defined('SHOW_PROMO')) { $int = random_int(1, 3); if ($int === 1) { define('SHOW_PROMO', 'FORGE'); } elseif ($int === 2) { define('SHOW_PROMO', 'VAPOR'); } elseif ($int === 3) { define('SHOW_PROMO', 'PARTNERS'); } }

April 2, 2022 Â· 1 min Â· Yish

Laravel Assert Middleware

In my case, I would like to assert the middleware what I through, Here is my soulution. // TestCase or what you like to put in. public function assertMiddleware($middleware, $request = null, ...$args) { // To be sure it's implemented handle method. if (! method_exists($middleware, 'handle')) { throw new BadMethodCallException(); } // Does it need to customize request? $request = $request?:new Request(); // instanced and called from handle. $instance = App::make($middleware)->handle($request, function($request) { return new JsonResponse($request); }, ....

March 27, 2022 Â· 1 min Â· Yish

Artisan Exit Code in Laravel

References from laracasts discussion, also I got a other reference. refs code Useful codes: 1 = failing / failed 2 = not ready 0 = success / no error….

March 25, 2022 Â· 1 min Â· Yish

Push middleware into global middleware in laravel

For my situation, I need to append debugbar infomation into APIs response when JSON API respond, here is my solution. You can make other sevice provider for this, but I just want to make a concept for you, so put in AppServiceProvider. What’s position that I want to put on, see in below: class Kernel extends HttpKernel { protected $middleware = [ // Here is prepend position. // \App\Http\Middleware\TrustHosts::class, \App\Http\Middleware\TrustProxies::class, \Illuminate\Http\Middleware\HandleCors::class, \App\Http\Middleware\PreventRequestsDuringMaintenance::class, \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \App\Http\Middleware\TrimStrings::class, \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, // Here is push position....

March 25, 2022 Â· 1 min Â· Yish

Ignoring specific listeners

We can ignore the listeners when we use event() dispatching event, here is how to implement it. The flow is very simple, passing ignore listeners when we called event, and then ignore it. For example, I have a event with listeners: class EventServiceProvider { protected $listen = [ UserCreated::class => [ SentToAdmin::class, SentToManager::class, NotifyUser::class, // we want to ignore it by specify situation. ] ] } class UserController { public function createByAdmin(Request $request) { $user = User::query()->create($request->validated()); event((new UserCreated)->ignoreListeners([ NotifyUser::class // listener ])); ....

March 10, 2022 Â· 1 min Â· Yish