There are quite a few casing systems out there. Camel case, snake case pascal case, kebab case and etc. Let’s explore their use case scenarios!

Image for post
Image for post
Photo by Sebastian Laube on Unsplash

Developers love to use conventions! They help us to organise our code and improve maintainability.

When it comes to naming variables and data structure in our code we use casing conventions to differentiate variable types and symbols.

The followings are the common usage for each casing convention.

Camel Case 🐫

camelCase is for variables, function names, arguments and other generic uses.

Snake Case 🐍

snake_case is similar to camelCase but we usually choose either one and stick to it for the…

Image for post
Image for post
Photo by darlene on Unsplash

Setting request query parameter can be very useful, especially in testing. We can set the request query parameter on runtime using the $request->merge() function. Here’s how:

/** @var $request \Illuminate\Http\Request */
$request = app()['request'];

'page' => '3'
dump($request->page); // expect: '3'

In Testing Classes, we should access the app instance via $this->app :

// TestClass extending TestCase/** @var $request \Illuminate\Http\Request */
$request = $this->app['request'];

'page' => '3'

The merge function will modify the current request in-place. If you want to clone the request, you can use the \Illuminate\Support\Facades\Request::createFrom() function

For example:

$request = app()['request'];// cloning the request so we don't modify the source

$newRequest = \Illuminate\Support\Facades\Request::createFrom($request);
'body' => 'heyy'
]);dump($request->body); // expect null

That’s it! Happy coding.

API (Application Programming Interface) sounds complicated, but it just means “function”!

Image for post
Image for post
Photo by Caspar Camille Rubin on Unsplash

An Analogy

When we are interacting with a computer, we don’t need to care about the inner working of a computer, i.e.

  • how does a computer chip work?
  • how do the computer parts talk to each other?
  • how does programming work?

All we care about is how to use a keyboard and a mouse. In other words, keyboard and mouse are the interfaces for us human to use the computer. This applies to other objects as well. …

Sometimes we just want to run composer command directly in our PHP code. But there seems to be no other easy solution other than exec() or shell_exec() … or is there?

Image for post
Image for post
Photo by Isaac Ibbott on Unsplash

It turns out there is a built-in Composer helper class in Laravel’s ecosystem! Yes, that’s right, it lives under the Illuminate\Support namespace. However, it doesn’t have a method to run arbitrary composer commands out of the box.

Let’s tweak it and add some new flavour! 😎

Let’s begin

We will create a new Composer class that inherits \Illuminate\Support\Composer.


Programatically install a package:

app()->make(\App\Composer::class)->run(['require', 'some-package']);

Updating packages:



If you see…

In general, it is a good idea to use HTTPS at all times. Why? It increases your visitors’ confidence on your brand, improves security / privacy and makes the internet a better place. You wouldn’t want your customer to see the “This site is not secure” warning right? That would scare your users away! 😱

Image for post
Image for post
Even if your webpage is 100% legitimate, this warning message will certainly scare your customers away!


Certificate Authority (CA) — An organisation that issue SSL certificates.

Domain — This is the address to your website. Eg.

Secure Socket Layer (SSL) — A way to transfer data securely to another machine. Imagine SSL as a secure tunnel. The data is encrypted…

Watch this tutorial on Youtube:

The “Search everything” box in the navigation bar is a very common feature in modern web app. I like it a lot, but implementing it in our own web app could be challenge. Here’s my solution to tackle this problem.

Image for post
Image for post
Implementing site wide full text search is not as straight forward as you may think. Photo by Markus Winkler on Unsplash


  1. Laravel Scout (I’m using TNTSearch driver here)
  2. Intermediate knowledge of Laravel

Note: I’m using Laravel 8 at the time of writing this article.

Full source code for this tutorial is available here. I will only cover the core implementation in this article. …


Please refer to my previous Docker tutorial if you have no idea what Docker is.

Image for post
Image for post
Photo by CHUTTERSNAP on Unsplash

In the previous tutorial we explored the basics of Docker by running a simple PHP website in a container that has a built-in web server. But what if we want to set up a database?

Well we can simply install a database engine (eg MySQL) to our image and recreate the container, right?

Technically, you can do that, but it defeats the purpose of Docker. Docker is different to virtual machines and it is designed to be highly scalable and isolable.

The Docker way to…

Image for post
Image for post
Image from Stencil

Sometimes we need to fetch static resources (PDF files, images, videos etc)from a server via a HTTP client in the browser, eg. AJAX, Fetch or Axios. So we try this in JavaScript:


But we see our good old friend CORS error :)

Resource from origin '' has been blocked from loading by Cross-Origin Resource Sharing policy: No Access-Control-Allow-Origin header is present on the requested resource.

But you’ve already added Laravel CORS config? All the other API routes work perfectly fine except for static resources?


Well it turns out when we request static resources, the web server will serve them…

Image for post
Image for post
Photo by Lee Campbell on Unsplash

Sometimes we want to parse the URL variables of a given route, ie getting the word user from /api/users/{user}. However there isn’t any helper method in Laravel that does this for us out of the box. The PHP built-in function parse_url is not smart enough to understand the URL variables.

If we have:


We get the following, which is not what we want unfortunately:

Clicking on the ‘Login with Google’ button does a lot of things behind the scene. It is a complex topic but I will simplify it for you 😎

Image for post
Image for post
Choosing a sign in option can be colourful :)

So what is Oauth?

In short, Oauth is a way to login to an app through a 3rd party service. See those fancy sign in with Google sign in with Facebook buttons? Clicking on these buttons will allow you to login to a website via Oauth!

Oauth allows us to do much more than authentication. We can perform operations on behalf of a user. Remember of those app that could post on your Facebook wall on…

Sam Ngu

Web Development. Follow me on Youtube:

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store