Host unreachable inside Docker container

I know it is an old question but for anybody coming here, the solution, at least on Linux, is to allow incoming network packets to host from docker bridge network by modifying the iptables of the host as following: sudo iptables -I INPUT -i docker0 -j ACCEPT It translates to […]

Restrict Internet Access — Docker Container

Network creation for access internet docker network create —subnet=172.19.0.0/16 internet Network creation for block internet access docker network create —internal —subnet 10.1.1.0/24 no-internet If you want to connect docker container into internet docker network connect internet container-name If you want to block internet access docker network connect no-internet container-name

Call all classes that implement an interface in Symfony

The best way is to implement CompilerPass. Here is an example . So, create a registry class (TransportChain class in that example), interface, and all classes that implements that interface, define them as services and give them tag name. After that, you can call that registry service in your action, […]

Disable csrf in laravel for specific route

Since version 5.1 Laravel‘s VerifyCsrfToken middleware allows to specify routes, that are excluded from CSRF validation. In order to achieve that, you need to add the routes to $except array in your App\Http\Middleware\VerifyCsrfToken.php class: <?php namespace App\Http\Middleware; use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier; class VerifyCsrfToken extends BaseVerifier { protected $except = [ […]

How to access GIT repo with my private key from Dockerfile

The error message Host key verification failed. is not complaining about your private key, but rather the host key for github.com. You can do this to add the github hostkey: ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts Perhaps you have your reasons, but in general cloning the git repo in to […]

How to prevent Model events from firing using phpunit

ooking into Laravel Api Model::flushEventListeners() should «Remove all of the event listeners for the model.» You can write a custom method base on this one: public static function flushEventListeners() { if (! isset(static::$dispatcher)) { return; } $instance = new static; foreach ($instance->getObservableEvents() as $event) { static::$dispatcher->forget(«eloquent.{$event}: «.get_called_class()); } } Something […]

How to parse html table to array with symfony dom crawler

table = $crawler->filter(‘table’)->filter(‘tr’)->each(function ($tr, $i) { return $tr->filter(‘td’)->each(function ($td, $i) { return trim($td->text()); }); }); print_r($table); The above example will give you a multidimensional array where the first layer are the table lines «tr» and the second layer are the table columns «td». If you got nested tables, this code […]