Skip to content

Instantly share code, notes, and snippets.

Nemanja Milosavljevic NemanyaM

Block or report user

Report or block NemanyaM

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
NemanyaM /
Created Oct 13, 2017 — forked from davejamesmiller/
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).

Accessing the Container

NemanyaM / FizzBuzz.php
Created Dec 14, 2016
FizzBuzz solution in PHP
View FizzBuzz.php
for ($i = 1; $i <= 100; $i++)
if($i % 3 == 0 && $i % 5 ==0){
echo "FizzBuzz<br />";
else if($i % 3 == 0){
echo "Fizz<br />";
else if($i % 5 == 0){
echo "Buzz<br />";
View Collection-Iterator-Aggregate.php
class Collection implements IteratorAggregate
* The collection contents.
* @var array
protected $items;
NemanyaM / artisan.php
Created Sep 1, 2016 — forked from vkbansal/artisan.php
Tying to use artisan migrate commands outside laravel
View artisan.php
require_once "vendor/autoload.php";
use Symfony\Component\Console\Application;
use Illuminate\Database\Console\Migrations;
use Pimple\Container;
$container = new Container();
$container['migration-table'] = 'migration';
You can’t perform that action at this time.