Nasrul Hazim Bin Mohamad

Laravel: Minify HTML


Assalamualiakum / Hi,

Just a quick blog post this time.

As part of optimisation, it’s important to minify your JavaScript & CSS – this can be done with Laravel Mix.

But how about HTML?

Seen this?

Ugly HTML Codes

So that’s how it’s look like our generated HTML codes.

And how we going to change into this?

Minified HTML Codes

A simple middleware will do to minify our HTML.

Then register the middleware and you are good to go!

Just grab this the Laravel Page Speed, then you’re done!


Laravel: Custom Accept API Header


Assalamualaikum / Hi,

It’s been a while since I stumble upon an API, which have custom Accept header.

For a past few days, I have a chance to implement custom header on one of my client project.

Here is how I did – create a middleware to filter the coming request.

As you can see above, my approach is using a middleware to check out every request come in. You just need to register this middleware in api middleware.

Now you’re ready with your custom Accept header.

You also can use the custom Accept header to have version control of your API.

Thanks! Happy Coding!

Laravel: Activation Account by E-mail – Part 2


Continue from previous post, next we going to setup the middleware in order to check either the user already activate the account or not.

If user already activate the account, allow to enter our application, else redirect to request for another activation e-mail.