Skip to content

Instantly share code, notes, and snippets.

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

Yan Policarpo h4rd1ideveloper

🏠
Working from home
View GitHub Profile
@h4rd1ideveloper
h4rd1ideveloper / Helpers.php
Last active April 23, 2020 18:12
Context variable pass to view Template File, and return rendered as string
/**
* @param string $templateFileName
* @param bool $ob
* @param array $context
* @see Stream
* @see ob_start
* @return string
* @throws Exception
*/
public static function viewFileAsString(string $templateFileName, bool $ob = false, array $context = []): string
@h4rd1ideveloper
h4rd1ideveloper / index.php
Last active April 28, 2020 19:18
Configure Illuminate\Database and phinx in your app
<?php
use App\lib\Helpers;
use DI\Container;
use Slim\Factory\AppFactory;
require(dirname(__FILE__) . '/vendor/autoload.php');
Helpers::setEnvByFile('.env');
AppFactory::setContainer(new Container);
@h4rd1ideveloper
h4rd1ideveloper / index.php
Last active April 25, 2020 00:51
Use Arrow function as route callable that return a Response
/**
* Arrow function as route callable
*/
$app->get('/functions', fn(Request $request, Response $response, array $args) => $response
->withBody((new StreamFactory)
->createStream(
Bcrypt::hashPassword('1596321758')
)
)