Skip to content

Instantly share code, notes, and snippets.

View ahonymous's full-sized avatar
💭
I may be slow to respond.

Oleksandr Moshta ahonymous

💭
I may be slow to respond.
  • Ukraine, Cherkasy
View GitHub Profile
@ahonymous
ahonymous / Event Dispatcher
Last active January 13, 2017 19:53
HW 13 Event Dispatcher, Security
1. All tags for services: http://symfony.com/doc/current/reference/dic_tags.html
2. Base documentation: http://symfony.com/doc/current/event_dispatcher.html , http://symfony.com/doc/current/components/event_dispatcher.html
3. Request/Responce before-after filters: http://symfony.com/doc/current/event_dispatcher/before_after_filters.html
4. Doctrine Listeners: http://symfony.com/doc/current/doctrine/event_listeners_subscribers.html
5. Doctrine Events: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html
<?php
namespace AppBundle\Controller;
use AppBundle\Entity\Author;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class DefaultController extends Controller
{
@ahonymous
ahonymous / mysql.conf
Created November 24, 2016 07:55
fdsf
default-character-set = utf8mb4
collation-server = utf8mb4_unicode_ci # Replaces utf8_general_ci
character-set-server = utf8mb4 # Replaces utf8
bind-address = 0.0.0.0
@ahonymous
ahonymous / AppTestCase.php
Created August 4, 2016 20:40
bootstrap file for test
<?php
namespace Tests\AppBundle;
...
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Filesystem\Filesystem;
@ahonymous
ahonymous / TestFixturesCommand.php
Last active August 4, 2016 20:34
Command for making the test DB from fixtures and save her with snapshot path
<?php
namespace AppBundle\Command;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\BufferedOutput;
@ahonymous
ahonymous / config_test.yml
Last active August 4, 2016 20:16 — forked from Etheriq/config_test.yml
example config_test.yml for using alternative db
parameters:
test_db_path: "%kernel.cache_dir%/db.sqlite" //the real path of DB for the test
default_db_path: "%kernel.cache_dir%/Resources/private/tests/snapshot.sqlite" //is the real path of DB for snapshot
doctrine:
dbal:
default_connection: default
connections:
default:
driver: pdo_sqlite
@ahonymous
ahonymous / ApiOrderTypeTest.php
Last active January 14, 2016 11:01
Tests for form with entity type
<?php
namespace AppBundle\Tests\Form;
use AppBundle\Entity\EOrder;
use AppBundle\Entity\User;
use AppBundle\Form\ApiOrderType;
use AppBundle\Tests\AppTypeTestCase;
class ApiOrderTypeTest extends AppTypeTestCase
<?php
class ImageHelper
{
public function cropImage($content, $width, $height)
{
$image = new \Imagick();
$image->readImageBlob($content);
$image->setImageFormat('jpeg');
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Article
*
* @ORM\Table(name="article")
{
"name": "ahonymous/hw4",
"description": "Geekhub AdvancedPHP 2015 HW#4",
"license": "MIT",
"authors": [
{
"name": "Alex Moshta",
"email": "[email protected]"
}
],