Skip to content

Instantly share code, notes, and snippets.

View anvodev's full-sized avatar

An Vo anvodev

View GitHub Profile
git init
git add .
git commit -m "First commit"
echo "<?php \n echo 'Hello World';" > index.php
mkdir my_project && cd my_project
provider "aws" {
region = "ap-southeast-1"
}
resource "aws_instance" "poc" {
ami = "ami-0123b531fc646552f"
instance_type = "t2.micro"
}
provider "aws" {
region = "ap-southeast-1"
}
resource "aws_instance" "poc" {
ami = "ami-0123b531fc646552f"
instance_type = "t2.micro"
tags = {
Name = "poc"
}
provider "aws" {
region = "ap-southeast-1"
}
resource "aws_security_group" "instance" {
name = "poc-instance"
ingress {
from_port = 8080
to_port = 8080
@anvodev
anvodev / symfonyflow_index.php
Last active May 3, 2020 08:42
Symfony index.php
<?php
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
@anvodev
anvodev / HttpKernel.php
Last active May 3, 2020 13:35
The main part of handle function in HttpKernel.php in Symfony 5
<?php
public function handle(Request $request, int $type = HttpKernelInterface::MASTER_REQUEST, bool $catch = true)
{
try {
return $this->handleRaw($request, $type);
} catch (\Exception $e) {
return $this->handleThrowable($e, $request, $type);
}
}
@anvodev
anvodev / RouterListener.php
Created May 3, 2020 11:05
RouterListener::onKernelRequest
<?php
//vendor/symfony/http-kernel/EventListener/RouterListener.php
public function onKernelRequest(RequestEvent $event)
{
$request = $event->getRequest();
// add attributes based on the request (routing)
try {
$parameters = $this->matcher->matchRequest($request);
$request->attributes->add($parameters);
unset($parameters['_route'], $parameters['_controller']);
@anvodev
anvodev / HomeController.php
Last active May 3, 2020 11:11
Basic Controller with index action
<?php
class HomeController extends AbstractController
{
/**
* @Route("/", name="home")
*/
public function index()
{
return $this->render('home/index.html.twig', [
'controller_name' => 'HomeController',