Skip to content

Instantly share code, notes, and snippets.

View romaricdrigon's full-sized avatar

Romaric Drigon romaricdrigon

  • Lausanne, Switzerland
View GitHub Profile
@K-Phoen
K-Phoen / config.yml
Created December 18, 2012 11:22
Storing Symfony2 sessions in memcached
imports:
# ....
- { resource: services/session.yml }
framework:
# ....
session:
handler_id: session.handler.memcached
@liuggio
liuggio / software-team-manifesto.md
Last active December 9, 2015 22:39
In the chaos of the implict, the tvision team creates this document with few concepts in order to unify the coding and some basic knowledge. If you are a developer and you are in the 2013 I think that you are already proficient with this notions. Please help me to improve this document forking the gist.
@typeofgraphic
typeofgraphic / mapD3JsonGeocode.html
Created January 4, 2013 23:47
Adaptation of Google Maps + D3.js Data file looks like this: [ {"country": "eth", "city": "adis abeba", "time": "2012-12-04T04:00:00", "count": 5}, {"country": "deu", "city": "munich", "time": "2012-12-04T19:00:00", "count":21}, {"country": "chn", "city": "wuhan", "time": "2012-12-04T18:00:00", "count": 1}, {"country": "usa", "city": "winthrop",…
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.29.1"></script>
<style type="text/css">
html, body, #map {
width: 100%;
@nikic
nikic / objects_arrays.md
Last active April 24, 2025 06:50
Post explaining why objects often use less memory than arrays (in PHP)

Why objects (usually) use less memory than arrays in PHP

This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)

The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array part of it away. So how does that work?

The key here is that objects usually have a predefined set of keys, whereas arrays don't:

@nfabre
nfabre / Symfony Live Paris.markdown
Last active October 7, 2020 12:27
Slides Symfony Live 2013
@romaricdrigon
romaricdrigon / formController.js
Created August 21, 2013 07:46
Using AngularJS on Symfony2 forms
// An example controller binded to the form
function FormCntl($scope, $compile) {
// Consider using FosJsRouting bundle, if you want to use a Symfony2 route
$scope.formUrl = "http://url-to-fetch-my-form";
// Data from the form will be binded here
$scope.data = {};
// Method called when submitting the form
$scope.submit = function() {
@bavington
bavington / eu_cookie_banner.js
Last active May 17, 2022 06:22
Simple EU Cookie Law Banner JavaScript
@romaricdrigon
romaricdrigon / minified.js
Created November 5, 2013 11:55
Symfony2 DebugToolbar Bookmarklet
javascript:(function(){var e=window.location.href.match(/.+\/app_dev\.php/);if(e){var t=new XMLHttpRequest;t.open("GET",document.location,false);t.send(null);var n=t.getResponseHeader("X-Debug-Token");var r=e[0]+"/_profiler/"+n;window.location.href=r}})()

Domain Model

How It Works

Putting a Domain Model in an application involves inserting a whole layer of objects that model the business area you're working in. You'll find objects that mimic the data in the business and objects that capture the rules the business uses. Mostly the data and process are combined to cluster the processes close to the data they work with.

An OO domain model will often look similar to a database model, yet it will still have a lot of differences. A Domain Model mingles data and process, has multivalued attributes and a complex web of associations, and uses inheritance.

<?php
namespace Acme\DemoBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
class DoctrineEntityListenerPass implements CompilerPassInterface
{