Skip to content

Instantly share code, notes, and snippets.

View heavensloop's full-sized avatar
🏠
Working from home

Popsana Barida heavensloop

🏠
Working from home
View GitHub Profile
@heavensloop
heavensloop / PHP-Interface-Design-Patterns.md
Last active October 18, 2024 22:41
PHP-Interface-Design-Patterns

PHP-Interface-Design-Patterns

Introduction

I recently started using a package called prophecy which is a mocking library for PHP. I was intrigued by the way the library was designed and how it was able to return the same object but with a different interface. This made me think about how I could use this in my own code. I decided to create a simple example of how this could be done.

Problem

I wanted to create an object that could be modified and then returned as a readonly object.

@heavensloop
heavensloop / setup-brew-on-multi-user.md
Created April 22, 2024 13:36
Setup brew on multi-user account

Setup multi user

Method one - Use one brew installation for all accounts (buggy)

echo $(brew --prefix)
echo $(groups $(whoami))
sudo dseditgroup -o edit -a $(whoami) -t user admin
sudo chgrp -R admin $(brew --prefix) 
sudo chmod -R g+rwX $(brew --prefix)
ls -lah $(brew --prefix)
@heavensloop
heavensloop / Symfony_Upgrade_Route_Method_Annotations.md
Last active June 13, 2020 20:52
Symfony: Update Deprecate Route/Method annotations for Symfony 5.2

Upgrading Symfony Route/Method Annotations for Symfony 5.x.

In the feat to update Route annotations from the deprecated Sensio\Bundle\FrameworkExtraBundle\Configuration\Method and Sensio\Bundle\FrameworkExtraBundle\Configuration\Method to use Symfony\Component\Routing\Annotation\Route.

First of all I fixed the routes cos I realized I had some routes that ended with double closing bracket: ")".

The Fix:

Replace:

@heavensloop
heavensloop / return_early.php
Last active May 13, 2022 15:04
Returning a http response while continuing a process after closing the connection
<?php
public function sendEarlyResponseHeaders($res)
{
// Buffer all upcoming output...
ob_start();
// Send your response.
echo json_encode($res);