Skip to content

Instantly share code, notes, and snippets.

@mrneatly
mrneatly / BaseController.php
Last active July 16, 2018 12:45
A flexible method for Yii2-based applications for loading models inside controller actions
<?php
use yii\db\ActiveRecord;
use yii\db\QueryInterface;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
class BaseController extends \yii\web\Controller {
/**
* Method to find any model that can be used in any controller.
@mrneatly
mrneatly / Language.php
Last active August 31, 2018 01:49
A middleware for Slim 3 framework to enable locale in URL
<?php
namespace middleware\multilanguage;
class Language {
protected $language;
public function __construct($default) {
if (!is_string($default)) {
throw new \Exception('Not a string.');
@mrneatly
mrneatly / Model.php
Last active March 13, 2017 23:35
A simple model-styled wrapper for MySQLi Database Class - https://github.com/joshcam/PHP-MySQLi-Database-Class
<?php
use MysqliDb;
/**
* A simple model-styled wrapper for [MySQLi Database Class](https://github.com/joshcam/PHP-MySQLi-Database-Class)
*
* TODO: - Implement method that returns all data as an array;
* - Store joined data in model;
*