Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Victor knust victorknust

🏠
Working from home
View GitHub Profile
View App.php
<?php
namespace App;
class App
{
public function __construct()
{
$controller = new Controller\Example;
}
View Model.php
<?php
//
$view = new View();
$view->addGlobal('global', 'Hello!, I\'m a Global var.');
// in the method
echo $view->render('controller.method.phtml', ['var' => 'Hello World!']);
View View.php
<?php
class View
{
public function render( $view, array $data = [] )
{
ob_start() and extract($data, EXTR_SKIP);
try {
View getWeekDays.php
<?php
function getWeekDays() {
$time = strtotime( 'monday this week' );
$days = [];
for($i = 0; $i<7; $i++){
$d = new DateTime();
$d->setTimestamp(strtotime("+$i day",$time));
$days[] = $d->format("Y-m-d");
}
View ResolveCallable.php
<?php
namespace Slim;
use Pimple\Container;
trait ResolveCallable
{
protected $container;
View days_of_this_week.php
<?php
function days_of_this_week()
{
$data = strtotime(date('Y-m-d'));
$ano = date('o', $data);
$semana = date('W', $data);
for($i = 1; $i <= 7; $i++) {
$dias[] = date("m/d/Y l", strtotime($ano . 'W' . $semana . $i));
}
@victorknust
victorknust / readme.md
Created Jan 18, 2017 — forked from Xeoncross/readme.md
140 byte PHP routing framework (well, it's just a function actually)
View readme.md

140 byte PHP routing system.

This is a very simply routing system that makes it easy to test requests to different paths. This is very limited so do not use for your applications - it's just for fun.

require('route.php');

// A user profile
route('/(\w+)/profile', function($path, $user)
{
	print "Hello " . $user;
View Router.php
<?php
class Router
{
public $routes = array();
public function route( $method, $pattern, $callback )
{
$pattern = '/^' . str_replace( array('/', ':id'), array('\/', '([0-9]+)'), $pattern ) . '$/';
$this->routes[$method][$pattern] = $callback;
@victorknust
victorknust / .htaccess
Created Oct 27, 2016 — forked from dhrrgn/.htaccess
NPSR - PSRs? We don't need to stinkin' PSRs.
View .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?_uri=$1 [L]
View bottom-cache.php
<?php
// Cache the contents to a file
$cached = fopen($cachefile, 'w');
fwrite($cached, ob_get_contents());
fclose($cached);
ob_end_flush(); // Send the output to the browser
You can’t perform that action at this time.