Skip to content

Instantly share code, notes, and snippets.

View popovserhii's full-sized avatar

Serhii Popov popovserhii

View GitHub Profile
@geerteltink
geerteltink / eventmanager.php
Created November 1, 2016 20:33
ZF3 standalone EventManager with LazyListeners
<?php
use App\Infrastructure\EventManager\Listener\AnotherListener;
use App\Infrastructure\EventManager\Listener\UserLoginListener;
use Zend\EventManager\LazyListenerAggregate;
use Zend\ServiceManager\Factory\InvokableFactory;
use Zend\ServiceManager\ServiceManager;
chdir(dirname(__DIR__));
require __DIR__ . '/vendor/autoload.php';
@hanhpv
hanhpv / magento-1-nginx.md
Created September 15, 2016 07:55
Magento 1 nginx configuration
server { 
	listen 80; 
	root /Users/admin/htdocs/vax-uk;
	index index.php index.html index.htm;
	 
	server_name vax.local; 
	access_log /usr/local/etc/nginx/logs/vax_access.log;
	access_log /usr/local/etc/nginx/logs/vax_error.log;
	 
@settermjd
settermjd / download-file-in-expressive.php
Last active July 25, 2022 01:25
Quick example of how to download/stream a file using Zend Expressive.
<?php
/**
* This is a quick example of how to stream a file to a client, likely a browser,
* using Zend Expressive. There are a lot of factors which it doesn't take in to
* account. But for the purposes of a quick intro, this should suffice.
*/
class ViewDocumentPageAction
{
protected function downloadFile()
{
@vkostyukov
vkostyukov / statuses.md
Last active May 15, 2025 19:29
HTTP status codes used by world-famous APIs
API Status Codes
[Twitter][tw] 200, 304, 400, 401, 403, 404, 406, 410, 420, 422, 429, 500, 502, 503, 504
[Stripe][stripe] 200, 400, 401, 402, 404, 429, 500, 502, 503, 504
[Github][gh] 200, 400, 422, 301, 302, 304, 307, 401, 403
[Pagerduty][pd] 200, 201, 204, 400, 401, 403, 404, 408, 500
[NewRelic Plugins][nr] 200, 400, 403, 404, 405, 413, 500, 502, 503, 503
[Etsy][etsy] 200, 201, 400, 403, 404, 500, 503
[Dropbox][db] 200, 400, 401, 403, 404, 405, 429, 503, 507
@shebin512
shebin512 / observer.php
Last active July 5, 2020 11:29
Magento get current full Action controller name in Observer
<?php
/*
* Get full Action controller name in Observer
*/
$request = Mage::app()->getRequest();
$module = $request->getControllerModule();
$module_controller = $request->getControllerName();
$module_controller_action = $request->getActionName();
$fullActionName = $module."_".$module_controller."_".$module_controller_action;
@chadrien
chadrien / README.md
Last active August 24, 2025 21:28
Debug PHP in Docker with PHPStorm and Xdebug

Debug your PHP in Docker with Intellij/PHPStorm and Xdebug

  1. For your local dev, create a Dockerfile that is based on your production image and simply install xdebug into it. Exemple:
FROM php:5

RUN yes | pecl install xdebug \
&amp;&amp; echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" &gt; /usr/local/etc/php/conf.d/xdebug.ini \
@pfrenssen
pfrenssen / README.md
Last active May 10, 2022 14:00
Git hook to check coding standards using PHP CodeSniffer before pushing

About

This is a git pre-push hook intended to help developers keep their PHP code base clean by performing a scan with PHP CodeSniffer whenever new code is pushed to the repository. When any coding standards violations are present the push is rejected, allowing the developer to fix the code before making it public.

To increase performance only the changed files are checked when new code is

@jwage
jwage / .php_cs
Last active April 14, 2025 19:32
php-cs-fixer git pre commit hook
<?php
return Symfony\CS\Config\Config::create()
->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL)
->fixers([
'short_array_syntax',
'ordered_use',
])
;

What's the difference between cascade="remove" and orphanRemoval=true in Doctrine 2

TLDR: The cascade={"remove"} is like a "software" onDelete="CASCADE", and will remove objects from the database only when an explicit call to $em->remove() occurs. Thus, it could result in more than one object being deleted. orphanRemoval can remove objects from the database even if there was no explicit call to ->remove().

I answered this question a few times to different people so I will try to sum things up in this Gist.

Let's take two entities A and B as an example. I will use a OneToOne relationship in this example but it works exactly the same with OneToMany relationships.

class A
@webdevilopers
webdevilopers / routing.yml
Last active June 20, 2020 09:01
Security Config for FOSUserBundle with SonataUserBundle with SonataAdminBundle
admin:
resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
prefix: /admin
_sonata_admin:
resource: .
type: sonata_admin
prefix: /admin
soanata_user: