This is what I think.
December 18, 2024
How To Implement Torchlight With Laravel(+Fliament Markdown)
I have always wanted to highlight code blocks on my blog post. So I started to search and found out some solutions. The first thing that I found was Prism.js, which is dedicated framework for code highlighting in frontend. I've added prismjs package in my package.json file and implemented using vite and bun. The result was not bad, but I was wondering how can I get something like in Github or Laravel document. Then I saw some comment on blog...
November 23, 2024
How To Use Response Dto With Drizzle And Zod. (Nest.js)
In Nest.js, when using the default TypeORM, you create and use DTOs separately for responses, apart from the Entity. With DrizzleORM, you can use createSelectSchema provided by Drizzle to reference an existing schema, generate types, and use them as DTOs. export const SelectUsersSchema = createSelectSchema(users); export type SelectUserDTO = z.infer<typeof SelectUsersSchema>; You can now specify SelectUserDTO as the response type: @Get(':id') public async findOne(@Param('id') id: string): Promise<CreateExhibitionDTO> { ... } With DrizzleORM's Relational Query, you can also adjust the returned...
November 17, 2024
An Interface For Abstraction & Type-Hinting
An interface in PHP provides a way to define a contract for a class, specifying methods that must be implemented without including any implementation details. It is particularly useful when you want to use type-hinting for parameters, ensuring that the objects passed to a function meet a specific structure. Example <?php // Define the LoggerInterface interface LoggerInterface { public function log(string $message): void; } // Implement the LoggerInterface in a class class FileLogger implements LoggerInterface { private string $filePath; public...
How A Data Trasfer Object(Dto) Works In Php.
A Data Transfer Object (DTO) in PHP is a simple object used to transfer data between different layers or parts of an application. DTOs are especially useful in maintaining clean separation of concerns by encapsulating data without any business logic. Here's a step-by-step guide on how to use DTOs in PHP: 1. Create a DTO Class Define a class with public or private properties to hold the data. Use getters and setters or public properties depending on your preference. class...
August 27, 2024
How To Apply Laravel Scheduler On Azure App Service
As you may know, all the data in app service server will not persist except for /home directory. And every time you deploy something on this server, it will be reset as if it were starting from brand new status. There are convenient way to handle this situation, we can use 'startup.sh' script. This script runs everythime we deploy something on the server. Since PHP service and Nginx are already installed by default, cron is not the case. Therefore, we...
July 07, 2024
How To Deploy Tall Stack App On Azure App Service(Feat. Bun)
Tutorial: Deploy a PHP, MySQL, and Redis app to Azure App Service https://learn.microsoft.com/en-us/azure/app-service/tutorial-php-mysql-app?source=recommendations Based on this article, create App Service and MySQL resource. This will guide you to create github action for deploy your app to App Service. (Step 7) There are a few other steps to complete the deployment properly. Open the GitHub action script and add these steps to build frontend assets before zipping all the code up. - name: Setup bun uses: oven-sh/setup-bun@v2 - name: build frontend...