Category Archives: Web Development

Testing Laravel Application


class DeveloperTest extends TestCase {

    public function we_all_should_write_test()


If you don’t know where to start, this is a very good starting point.

Two points to emphasize:

  1. Tests give you confident to change code. (Laracasts)
  2. The value of tests get higher as time goes on.

Usually my workflow is this:

  1. How the feature is reached?
  2. What is expected to come out?

That’s pretty much it. Write test first, not after. It helps me clarify the problem and write a better solution.

Develop with TailwindCSS

TLDR; I just did a project using Tailwind CSS. It’s as good as it advertised.

I came from working with Bootstrap for a long time. It has been my go to HTML/CSS framework. I can quickly build a good business looking website quickly with Bootstrap.

I just had a small project that I needed to work on. It’s not difficult so I got to spend sometimes on it using Tailwind.

At first, since coming from Bootstrap, there’s some initial learning curve needed to overcome with. Once I got it setup and running, I see the benefit of using a Utility First Framework approach to develop the front-end. It’s quick, easy to customize, and importantly, easy to read. (We spend 10 times more to read code than writing code, maybe 20 times more to read HTML/CSS more than writing HTML/CSS code ).

It’s good to have more tools to tackle problems and I think both Bootstrap and Tailwind are good tools to have in the toolbox.

Working with G Suite Admin SDK

On occasion, you want to build an application to interact with G Suite without logging to the console. The G Suite Admin SDK is a tool for the purpose. 

In authentication, there are two ways to do it. 

  1. Using service account and impersonate an account with administrative access. 
  2. Use OAuth to authenticate access through SDK. (Recommended)

The first option is great for automate tasks, such as generating reports, but not recommended for web app with access from anyone.

Let’s look at how to implement option #2 with Laravel

  1. Use composer to download and include the Admin SDK. composer require google/apiclient:2.0
  2. Create a OAuth 2.0 client ID in
  3. Place the client_id and client_secret the same way you when setting up Socialite using Google OAuth. 
  4. In the Socialite login code, set scopes that you want the account with administrative access. The Admin SDK scopes are listed in here. For example to retrieve group, group alias, and member information, uses: j
return Socialite::driver(‘google’)
->scopes([ '',
  • When retrieving user detail after login, store the $user->token somewhere. 

6. Back to using Google client, create a $client as below 

$client = new Google_Client();
$client->setApplicationName('G Suite Directory Demo');
$client->setAccessToken([User Token here]);
$service = new Google_Service_Group($client);
$optParams = array(
'userKey' => '',
'maxResult' => 10
$results = $service->groups->listGroups($optParams);

7. Done