Skip to content

Instantly share code, notes, and snippets.

View duythien's full-sized avatar
🏠
Working from home

Thien Tran duythien

🏠
Working from home
View GitHub Profile
@alexander-torosh
alexander-torosh / QueryBuilderQuery.php
Last active December 14, 2016 05:11
Example of using Phalcon Query Builder and Columns method
<?php
$qb = $this->modelsManager->createBuilder()
->columns(['e.*', 'i.*'])
->addFrom('Backend\Models\Event', 'e')
->innerJoin('Backend\Models\Image', 'e.id = i.event_id', 'i')
->where('e.id = :id:', ['id' => $some_id]);
$entries = $qb->getQuery()->execute();
@mindplay-dk
mindplay-dk / session-life-cycle.md
Last active March 28, 2024 19:52
Complete overview of the PHP SessionHandler life-cycle

This page provides a full overview of PHP's SessionHandler life-cycle - this was generated by a set of test-scripts, in order to provide an exact overview of when and what you can expect will be called in your custom SessionHandler implementation.

Each example is a separate script being run by a client with cookies enabled.

To the left, you can see the function being called in your script, and to the right, you can see the resulting calls being made to a custom session-handler registed using session_set_save_handler().

@sgolemon
sgolemon / lambda.php
Created January 10, 2015 01:18
Short Lambda Syntax
<?php
$names = ['Alice', 'Bob'];
// PHP Closures
$greetings = array_map(
function($x) {
return "Hello $x";
}, $names);
@ryanj
ryanj / php_parks.md
Last active December 25, 2015 17:59
Spatial mapping with PHP, Silex, MongoDB, Leaflet, and Open Street Maps.

Open Source Mapping with PHP and MongoDB

In response to Steve's call for a shift toward civic-focused applications that are a better suited for adoption and maintenance by PHP-friendly IT departments, I've momentarily set aside OpenShift's shiny new nodejs-0.10 cartridge in order to show you how easy it is to write a basic single-page mapping application in PHP.

Those of you who are familiar with Steve's mapping quickstarts may recognize this application as a port of his own MongoDB-Python-Flask example which uses MongoDB's spatial features to perform a classic bounding-box query.

*Project source: [https://github.com/openshift-quickstart/silex-mongodb-pa