Skip to content

Instantly share code, notes, and snippets.

@ralphschindler
ralphschindler / example.php
Created October 24, 2012 23:18
Zend\Db\Sql\Select example usage
<?php
use Zend\Db\Sql\Select;
// basic table
$select0 = new Select;
$select0->from('foo');
// 'SELECT "foo".* FROM "foo"';
<?php
$slugConstraints = '[\w_-]+';
$pagenumberChild = array(
'type' => 'segment',
'options' => array(
'route' => '/page/:page',
'constraints' => array(
'page' => '\d+'
@ericmagnuson
ericmagnuson / .htaccess
Last active March 29, 2021 01:00
Compiling and serving LESS on-the-fly with PHP & Apache
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule (.*\.min.css) less.php?min=yes&path=$1
RewriteRule (.*\.css) less.php?min=no&path=$1
</IfModule>
@fideloper
fideloper / sphinx.conf
Created October 3, 2012 01:15
Install Sphinx and php .so in Ubuntu 12.04
#############################################################################
## data source definitions
#############################################################################
source users
{
# data source type. mandatory, no default value
# known types are mysql, pgsql, mssql, xmlpipe, xmlpipe2, odbc
type = mysql
@cgmartin
cgmartin / FileUploadForm.php
Created September 28, 2012 04:51
ZF2 File Upload PR Examples
<?php
namespace Application\Form;
use Zend\Form\Form;
use Zend\Form\Element;
class FileUploadForm extends Form
{
public function __construct($name = null, $options = array())
@samsonasik
samsonasik / formselectinzf2
Created September 20, 2012 04:29
Form Select in ZF2
namespace SampleModule\Form;
use Zend\Form\Form;
class SampleForm extends Form
{
public function __construct($name = null)
{
parent::__construct('Sample Form');
@GeeH
GeeH / f.php
Created September 18, 2012 09:28
validator array zf2
public function create($data = null) {
$json = "{ \"artist\":\"ergsern\", \"title\":\"enruy7u\" }";
$array = \Zend\Json\Decoder::decode($json);
$artist = new Input('artist');
$artist->getValidatorChain()->addValidator(new Validator\StringLength(array('min' => '5', 'max' => '20')));
$title = new Input('title');
$title->getValidatorChain()->addValidator(new Validator\StringLength(array('min' => '5', 'max' => '20')));
$inputFilter = new InputFilter();
<?php
// module/Album/src/Album/Model/Album.php:
namespace Album\Model;
use Zend\Form\Annotation as Form;
class Album{
/**
* @Form\Required(false)
* @Form\Attributes({"type":"hidden"})
@weierophinney
weierophinney / listener.php
Created August 29, 2012 19:54
Example of triggering another dispatch event in ZF2
<?php
use Zend\Mvc\Router\RouteMatch;
// Listener on dispatch.error event
$listener = function ($e) {
$app = $e->getTarget();
$events = $app->getEventManager();
$event = clone $e;
$matches = new RouteMatch(array('controller' => 'Some\Controller\Alias'));
$event->setRouteMatch($matches);
@santouras
santouras / Unique.php
Created August 29, 2012 14:13
Failing ZF2 validator requiring Service Locator
<?php
namespace My\Validator;
use Zend\Validator\AbstractValidator;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
class Unique extends AbstractValidator