Skip to content

Instantly share code, notes, and snippets.

@chaungoclong
chaungoclong / .php-cs-fixer.php
Created October 19, 2025 03:29 — forked from laravel-shift/.php-cs-fixer.php
PHP CS Fixer - Laravel Coding Style Ruleset
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$rules = [
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'default' => 'single_space',
@chaungoclong
chaungoclong / objects_arrays.md
Last active January 31, 2025 21:17 — forked from nikic/objects_arrays.md
Post explaining why objects often use less memory than arrays (in PHP)

Why objects (usually) use less memory than arrays in PHP

This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)

The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array part of it away. So how does that work?

The key here is that objects usually have a predefined set of keys, whereas arrays don't:

@chaungoclong
chaungoclong / ABOUT.md
Created October 16, 2024 06:05 — forked from laobubu/ABOUT.md
A very simple HTTP server in C, for Unix, using fork()

Pico HTTP Server in C

This is a very simple HTTP server for Unix, using fork(). It's very easy to use

How to use

  1. include header httpd.h
  2. write your route method, handling requests.
  3. call serve_forever("12913") to start serving on port 12913
@chaungoclong
chaungoclong / PHPExcelStyle.php
Created March 18, 2024 19:17 — forked from Style87/PHPExcelStyle.php
Converts an array of css style attributes to PHPExcel style values.
/**
* Converts an array of css style attributes to PHPExcel style values.
* <p>
* Any array element that is not a valid css attribute will be merged into
* the returned array.
*
* @param $mixed An array of css attributes
* @return Array
*/
public function getPHPExcelStyleArray()

( P1 ) - Bắt đầu dự án PHP - Laravel với Docker, siêu nhanh, siêu dễ dàng

Hoàng cảnh

  • Nhớ lại cái thời mới code PHP, lúc đó mình thường dành cả thanh xuân chỉ để setup môi trường có thể chạy được PHP, nào là tự cài từng thành phần trên mọi trường local, tiến bộ hơn tí thì cài WAMP rồi nhảy qua XAMPP.
  • Sau một thời gian code đã rồi chuyền file lên server mới phát hiện sự khác biết giữa PHP version dưới local khác với môi trường Product. Từ đó mà Bug xuất hiện nhiều vô số kể.
  • Vần đề tưởng đơn giản nhưng lại phát sinh bao việc, System Admin thì đổ thừa do code dỡm, còn mình thì hì hục kiểm tra xem nguyên nhân từ đâu, rồi lại nài nỉ System Admin update server, đỉnh điểm của mâu thuận là mình tự phải server, và hậu quả là giờ mình cũng có khá khá kiến thức về server =)). Người ta nói "Trong cái khó, ló cái khôn" là đúng.

Sự xuất hiện

-Cuối cùng ngày đó cũng đến, Docker được xuất hiện lần đầu tiền vào năm 2013 nhưng mình lại được tiếp xúc với nó vào năm 2017 khá chậm so với thế giớ

@chaungoclong
chaungoclong / nginx-https-local.md
Created January 26, 2024 08:56 — forked from mehmetsefabalik/nginx-https-local.md
Enable https on your local environment with nginx

enable https on your local environment

install mkcert and create certificates

brew install mkcert
mkcert -install
@chaungoclong
chaungoclong / rest-api-response-format.md
Created December 18, 2023 07:22 — forked from igorjs/rest-api-response-format.md
REST API response format based on some of the best practices