Skip to content

Instantly share code, notes, and snippets.

@vhood
vhood / example.md
Last active February 17, 2025 15:12
PHP constructor overloading concept

RFC: constructor overloading syntax sugar

If an object needs to have different ways of being created, we use static functions or more objects.

Static functions look awful and break the object's API.

I offer a way to write less code, but keep the code elegant.

class Decision
@vhood
vhood / docker-compose.yml
Last active September 9, 2024 15:27
vscode-docker-php-xdebug
services:
php:
extra_hosts:
- "host.docker.internal:host-gateway"
.DEFAULT_GOAL := help
help:
@make --help
# git
remove-branches:
git fetch -p; LANG=en_US git branch -v | grep "\[gone\]" | cut -d ' ' -f3 | xargs git branch -d
@vhood
vhood / 1.README.md
Last active May 31, 2023 10:38
Yii2 without SearchModel example

Yii2 without SearchModel

This is an architecture example how to create Yii2 a typical page with widgets and a DataProvider.

Popular solution

An action should handle query params, provide a DataProvider and a SerachModel dependent on those params, and return a page.

A typical solition is creating a SearchModel with properties, validation rules and the search() method

@vhood
vhood / json-api-open-api.yml
Last active April 5, 2024 19:09
JSON:API swagger (OpenAPI) example
openapi: 3.0.3
info:
title: JSON:API
version: 1.1.0
description: |
This is an example of [JSON:API](https://jsonapi.org) specification
according to OpenAPI documentation
paths:
/posts:
get: