Skip to content

Instantly share code, notes, and snippets.

View hallboav's full-sized avatar
🌴
Learning PHP core

Hallison Boaventura hallboav

🌴
Learning PHP core
  • Amsterdam, The Netherlands
View GitHub Profile
@hallboav
hallboav / hex-arch.php
Created November 26, 2019 04:11
Hexagonal Architecture example
<?php
// Vendor
namespace VeryNiceLib {
class StdoutLogger
{
private $stream;
public function __construct()
{
@hallboav
hallboav / InMemoryStorage.php
Created July 3, 2019 19:22
Zend Authentication
<?php
use Zend\Authentication\Storage\StorageInterface;
class InMemoryStorage implements StorageInterface
{
private $contents = null;
public function isEmpty()
{
@hallboav
hallboav / CadastroEntity.php
Last active July 3, 2019 02:41
symfony/workflow
<?php
class CadastroEntity
{
private $estadoAtual;
private $nome;
public function __construct(string $nome, string $estadoAtual)
{
$this->nome = $nome;
@hallboav
hallboav / 1.php
Last active May 23, 2019 02:06
State machine
<?php
interface PortaInterface
{
public function abrir();
public function fechar();
}
abstract class AbstractPorta implements PortaInterface
{
@hallboav
hallboav / Dockerfile
Last active February 23, 2019 15:44
Passando variáveis de ambiente para o container do zend-server
FROM php-zendserver:2018.0
# Valor padrão (usuado quando --env não for passado no docker run)
ENV APPLICATION_ENV local
# Patch
# Encontrei dois grandes problemas:
# 1. A imagem inicia um processo chamado /usr/local/zs-init/init.php que faz uma série de passos. Um desses passos é
# iniciar o zend-server através do systemd (via service). Isso é considerado uma má prática, visto que não devemos
# ter mais do que um processo por container. Além disso, o systemd isola variáveis de ambiente.
@hallboav
hallboav / composer.json
Last active February 3, 2019 00:30
Look for Brazilians certified by SensioLabs.
{
"require": {
"fabpot/goutte": "^3.2",
"symfony/console": "^4.2"
}
}
@hallboav
hallboav / composer.json
Created January 27, 2019 18:04
Sandman
{
"require": {
"ext-openssl": "*",
"fabpot/goutte": "^3.2",
"symfony/console": "^4.2"
}
}
@hallboav
hallboav / help-sept22.sql
Last active September 29, 2017 16:20
Desenvolvedores podem saber N linguagens de programação; como buscar os desenvolvedores pelo nome ou pela linguagem?
CREATE DATABASE sept22;
USE sept22;
CREATE TABLE developers (
id INT AUTO_INCREMENT NOT NULL,
name VARCHAR(255) NOT NULL,
PRIMARY KEY(id)
) ENGINE = InnoDB;
CREATE TABLE languages (
@hallboav
hallboav / fw0fw1.php
Created July 23, 2017 05:40
The user must authenticate to two consecutive firewalls to reach the resource.
<?php
// composer require silex/silex symfony/security && php -S localhost:8888 -t $(pwd)
require 'vendor/autoload.php';
use Silex\Application;
use Silex\Provider\SessionServiceProvider;
use Silex\Provider\SecurityServiceProvider;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
<!DOCTYPE html>
<html ng-app="app">
<head>
<meta charset="utf-8">
<title>input-output-component</title>
</head>
<body>