Skip to content

Instantly share code, notes, and snippets.

View devosc's full-sized avatar

devosc

View GitHub Profile
@devosc
devosc / Config.php
Last active March 25, 2018 18:42
multiple has get
<?php
/**
*
*/
namespace Mvc5\Config;
trait Config
{
/**
<?php
trait base_trait
{
protected $prop = [];
function __construct()
{
var_dump($this->prop);
}
@devosc
devosc / middleware_args.php
Last active August 20, 2017 16:28
Middleware Args
<?php
/**
*
*/
namespace Mvc5\Service;
use Mvc5\Arg;
use Mvc5\Signal;
@devosc
devosc / context.php
Created August 19, 2017 16:52
Context
<?php
/**
*
*/
include __DIR__ . '/../init.php';
use Mvc5\App;
use Mvc5\Arg;
use Mvc5\Http\Request;
use Mvc5\Http\Response;
@devosc
devosc / ManageService.php
Last active October 29, 2015 22:36
Module Service Access
public function create($config, array $args = [], callable $callback = null)
{
if (!$config) {
return $config;
}
if (is_string($config)) {
$name = explode(Args::SERVICE_SEPARATOR, $config);
$config = array_shift($name);
<?php
$plugin = $this->plugin($plugin, function($plugin) use($args, $callback) {
if (!is_callable($plugin)) {
return $this->call('service:event', [$plugin]);
}
return $plugin;
});
@devosc
devosc / ViewModel.php
Created July 20, 2015 06:35
ViewModel Controller
<?php
namespace Home;
use Mvc5\View\Model\Base;
use Mvc5\View\Model\Plugin;
use Mvc5\View\Model\ViewModel;
use Mvc5\View\ViewPlugin;
class Model
@devosc
devosc / Service.php
Created March 23, 2015 14:56
ArrayAccess Container Support
<?php
/**
*
*/
namespace Framework\Service\Container;
use Framework\Config\ArrayAccess;
use Framework\Config\Configuration;
@devosc
devosc / hydrate-scoped-callback.php
Created March 23, 2015 14:54
Scoped Hydration Callbacks
protected function hydrate(Config $config, $service)
{
foreach($config->calls() as $method => $value) {
if (is_string($method)) {
if (Args::PROPERTY == $method[0]) {
$service->{substr($method, 1)} = $this->resolve($value);
continue;
}
$service->$method($this->resolve($value));
@devosc
devosc / raw.php
Last active August 29, 2015 14:15
array values instead of container
$config = [
'alias' => [],
'events' => ['Mvc' => [function($route, $request) { var_dump($route, $request); }]],
'services' => [
'Response' => new Response\HttpResponse,
'Route' => new RouteConfig([
'hostname' => 'localhost',
'method' => 'GET',
'path' => '/',
'scheme' => 'http'