Skip to content

Instantly share code, notes, and snippets.

View dlsniper's full-sized avatar

Florin Pățan dlsniper

View GitHub Profile
@dlsniper
dlsniper / appDevDebugProjectContainer.php
Created March 8, 2012 21:46
Configuration caching issue
/**
* Gets the 'doctrine.orm.default_entity_manager' service.
*
* This service is shared.
* This method always returns the same instance of the service.
*
* @return Doctrine\ORM\EntityManager A Doctrine\ORM\EntityManager instance.
*/
protected function getDoctrine_Orm_DefaultEntityManagerService()
@dlsniper
dlsniper / config.yml
Created March 18, 2012 21:15
Sample Doctrine2 cache in Symfony2
# Doctrine Configuration
doctrine:
dbal:
default_connection: connection1
connections:
connection1:
dbname: database1
connection2:
dbname: database2
connection3:
@dlsniper
dlsniper / benchmark.php
Created January 13, 2013 20:49
isset, array_key_exists and isset || array_key_exists speed test
<?php
$demo = array(
'kernel.root_dir' => '/var/www/personal/symfony/app',
'kernel.environment' => 'prod',
'kernel.debug' => false,
'kernel.name' => 'app',
'kernel.cache_dir' => '/var/www/personal/symfony/app/cache/prod',
'kernel.logs_dir' => '/var/www/personal/symfony/app/logs',
'kernel.bundles' => array(

Awesome PHP Libraries

A list of amazingly awesome PHP libraries that you should consider using (and some other shiny extras).

@dlsniper
dlsniper / README.md
Last active December 12, 2015 03:28
Simple benchmark for Symfony2

You should download each of the three versions of Symfony2 in /var/www/benchmark/sf2<X> where <X> is the minor version. Then

chmod +x benchmark.sh
sudo ./benchmark.sh
@dlsniper
dlsniper / embed.html.twig
Created February 6, 2013 21:35
Translation update demo Use AcmeDemoBundle Put embed.html.twig in Acme/DemoBundle/Resources/views/ Change Acme/DemoBundle/Resources/views/Welcome/index.html.twig accordingly Output is output.yml
{% block msg %}
<p>Congratulations! You have successfully installed a new Symfony application.</p>
{{ 'embed'|trans }}
{% endblock %}
@dlsniper
dlsniper / loaded classes
Last active December 13, 2015 18:08
SF2.2 RC2 patch
Symfony\Component\ClassLoader\ClassCollectionLoader
Symfony\Bundle\FrameworkBundle\FrameworkBundle
Symfony\Bundle\SecurityBundle\SecurityBundle
Symfony\Bundle\TwigBundle\TwigBundle
Symfony\Bundle\MonologBundle\MonologBundle
Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle
Symfony\Bundle\AsseticBundle\AsseticBundle
Doctrine\Bundle\DoctrineBundle\DoctrineBundle
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle
JMS\AopBundle\JMSAopBundle

A. Caching systems in general:

  • there are many caching systems out there, with totally different APIs, levels of complexity, implementations and use-cases, so a minimum common API should provide some level of portability.
  • caching systems can work synchronously or asynchronously
  • usually caching systems store items for a limited amount of time (expiration, time-to-live, etc.)
  • some caching systems expose the expiration information in their API, others don't
  • those caching systems who use expiration may chose to use a predefined value, a system imposed value, or let the API consumer specify a value
  • the most basic operations are the storing and retrieval of things from the cache
@dlsniper
dlsniper / array_from_apc.php
Created March 8, 2013 22:49
Demom for classes loading speed-up To test run either against full_array.php or array_from_apc.php (after you run pushToApc.php that is)
<?php
$array = apc_fetch('classes');
@dlsniper
dlsniper / return-hinting-rfc.md
Last active December 18, 2015 23:39
PHP RFC for function / method return typing

Request for Comments: Method Return Typing

  • Version: 0.1
  • Date: 2013-06-26
  • Author: Florin Patan
  • Status: In draft
  • Patch included: NO

Introduction