Skip to content

Instantly share code, notes, and snippets.


Ilya ilya-dev

  • Russia
View GitHub Profile
ilya-dev / x0_taste.php
Created Apr 28, 2014
What x0 might look like
View x0_taste.php
* @name facade:resolve
* @desc Show underlying classes and the corresponding IoC bindings
* @sign {query:optional:"The query string":"*"}
class SomeCommand {
public function go($input, $output)
ilya-dev / project_x0.php
Last active Aug 29, 2015
Something I am working on...
View project_x0.php
// command-name {name:required} {age:optional:"Jack"}
// command-name {--name} {--age:required} {--country:optional:USA}
// facade:resolve "Show underlying classes and the corresponding IoC bindings" {query:optional:"Query string":"*"}
listen("say-hello")->act(function($input, $output) {
$output("Hello, world!");
ilya-dev / runner.php
Last active Aug 29, 2015
Laravel Task Runner - how that might look like
View runner.php
// in app/tasks.php
// the second argument contains the array of "dependencies"
task("default", ["minify_css", "minify_js", "concatenate"]);
// smart enough to analyze the arguments
// and "inject" required components
task("minify_css", function($minifyCss)
ilya-dev / app_self_update.php
Last active Mar 1, 2016
Raw prototype of an application updater
View app_self_update.php
<?php namespace Acme;
use Illuminate\Filesystem\Filesystem;
class Updater {
* The Filesystem instance
* @var Illuminate\Filesystem\Filesystem
ilya-dev / tips1.php
Created Apr 2, 2014
To prevent an accidental assignment when comparing two variables, wrap the first one within parentheses.
View tips1.php
$foo = 10; $bar = 9;
var_dump($foo = $bar); // whoops, accidental assignment! but no message will be displayed
var_dump(($foo) = $bar); // again, but this is a syntax error b/c an expression can't have a value assigned to it!
ilya-dev /
Created Mar 29, 2014
Some very useful Laravel aliases to have in your .bashrc or .zshrc file
alias art="php artisan"
alias art_set_env="sed -i 's/your-machine-name/`hostname`/g' bootstrap/start.php"
ilya-dev / declared_classes.php
Last active Aug 29, 2015
Getting all classes declared in a PHP file - various solutions.
View declared_classes.php
function get_declared_class($file)
require_once $file;
$classes = get_declared_classes();
return end($classes);
View namespaces_and_exceptions.php
class Bar extends \Exception {}
namespace Foo {
// do something
ilya-dev / laravel_artisan_call.php
Last active Aug 29, 2015
[Laravel specific] Works perfectly if you need to execute an Artisan command AND get the output as a string.
View laravel_artisan_call.php
if ( ! \function_exists('artisan_call'))
function artisan_call($command, array $parameters = array())
$buffer = new \Symfony\Component\Console\Output\BufferedOutput();
\Artisan::call($command, $parameters, $buffer);
You can’t perform that action at this time.