Skip to content

Instantly share code, notes, and snippets.

@wowo
wowo / PHPUnit way to mock Doctrine2 Entity Manager.php
Created November 1, 2011 20:22
PHPUnit's way to mock Doctrine2 Entity Manager
<?php
class AbstractManagerBase extends \PHPUnit_Framework_TestCase
{
protected function getEmMock()
{
$emMock = $this->getMock('\Doctrine\ORM\EntityManager',
array('getRepository', 'getClassMetadata', 'persist', 'flush'), array(), '', false);
$emMock->expects($this->any())
->method('getRepository')
@ziadoz
ziadoz / awesome-php.md
Last active July 13, 2024 05:29
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
@danvbe
danvbe / 1-Explanations.md
Last active November 14, 2024 02:13
A way to integrate FosUserBundle and HWIOAuthBundle

I have managed to install this… and make it work. I implemented it for Facebook and Google, but you can extend it. My solution it is mostly as described in #116, with a bit of more code presented. The key aspects that lack in the #116 presentation (IMO) are:

  • the registration as service of your custom FOSUBUserProvider (with the necessary parameters)
  • set the service for oauth_user_provider in the security.yml with your custom created service

Here are the steps:

  1. Routing. In routing.yml I have added all the routes for both bundles.
  2. Configuration. I have set the config.yml mostly as it is presented in the HWIOAuthBundle.
  3. Security. I have set the security.yml mostly as it is presented in the HWIOAuthBundle (though my routes are using /login pattern, not /connect). Also, the oauth_user_provider is set for my custom service.
@lbdremy
lbdremy / click-reference-affiliate-networks.md
Last active December 4, 2023 16:14
click reference parameter in a bunch of affiliate networks. Feel free to contribute, add and remove errors.

- Affiliate network name - &parameter=value_of_the_click_reference_here_CLICKREF

  • Advortis - &xref1=CLICKREF
  • Affiliate Future - &tracking=CLICKREF
  • Affiliate Window - &clickref=CLICKREF
  • Affilinet - &subid=CLICKREF
  • Aflite - &aref=CLICKREF
  • Brand Conversions - &subid=CLICKREF
  • Buyat - &LID=CLICKREF
  • Carpet Right Affiliates - &link_ref=CLICKREF
  • ClixGalore - &OID=CLICKREF
@ogrrd
ogrrd / Mac Dev Setup.md
Last active November 12, 2020 22:16
Installing nginx, PHP and MySQL on OS X Mavericks

Installing a Web Developer setup on OS X Mavericks

Install Command Line Tools

This is a requirement for brew in the next step. You can install XCode and then install Command Line Tools through the XCode preferences, or you can install just the Command Line Tools.

Install Command Line Tools

$ xcode-select --install
@ogrrd
ogrrd / Cake Composer.md
Last active July 15, 2024 22:03
Install Cake 2.x with Composer

Install CakePHP 2.x with Composer

Remove the main CakePHP lib directory

$ cd /path/to/your/website
$ rm -Rf ./lib

Add the following composer.json file

@plentz
plentz / nginx.conf
Last active November 16, 2024 14:10
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
<?php
namespace NoxLogic\DemoBundle\Form\Type;
use Doctrine\ORM\EntityManager;
use NoxLogic\DemoBundle\Entity\Province;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
@hubgit
hubgit / Attachment.php
Last active January 11, 2018 00:00
Symfony service to subscribe to VichUploaderBundle's POST_UPLOAD event. Saves file details as new entity fields. Note: untested since pasting and editing, may not work as-is.
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
@harlanhaskins
harlanhaskins / Parser.swift
Last active July 18, 2021 02:47
Building a Compiler in Swift with LLVM, Part 2: AST and the Parser
#if os(macOS)
import Darwin
#elseif os(Linux)
import Glibc
#endif
// MARK: Tokens
enum BinaryOperator: Character {
case plus = "+"