Skip to content

Instantly share code, notes, and snippets.

<?php
class Category extends Phalcon\Mvc\Model
{
public $id;
public $lft;
public $rgt;
<?php
class RobotsController extends Phalcon\Mvc\Controller
{
public function index()
{
echo "Hello Index";
}
public function show($id)
<?php
$c = new Phalcon\Mvc\View\Engine\Volt\Compiler();
echo htmlentities($c->compileString('{{ a._id }}'));
<?php
set_exception_handler(function($e) use ($di) {
file_put_contents(APP_PATH . '/app/logs/error-log' . uniqid("", true) . '.txt' ,
$e->getMessage() . PHP_EOL .
print_r($e->getTrace(), true) . PHP_EOL .
print_r($_POST, true) . PHP_EOL .
print_r($_GET, true) . PHP_EOL .
print_r($_SERVER, true)
<?php
use Phalcon\Events\Event,
Phalcon\Mvc\User\Plugin,
Phalcon\Mvc\Dispatcher,
Phalcon\Acl;
/**
* Security
*
<memory-grow>
if some-condition {
<here-we-need-the-memory-grow>
}
<restore-stack>
<?php
class MyDialect extends \Phalcon\Db\Dialect\Mysql
{
/**
* Gets the column name in MySQL
*
* @param Phalcon\Db\ColumnInterface $column
* @return string
*/
#!/bin/bash
# Check best compilation flags for GCC
export CC="gcc"
export CFLAGS="-march=native -mtune=native -O2 -fno-delete-null-pointer-checks -finline-functions -fomit-frame-pointer -fno-builtin-memcmp"
echo "int main() {}" > t.c
gcc $CFLAGS t.c -o t 2> t.t
if [ $? != 0 ]; then
chmod +x gcccpuopt
BFLAGS=`./gcccpuopt`
@phalcon
phalcon / volt2.php
Last active December 20, 2015 19:09
<?php
$volt = new Phalcon\Mvc\View\Engine\Volt\Compiler();
file_put_contents('x.php', $volt->compileString('{%- macro error_messages(message, field, type) %}
<div>
<span class="error-type">{{ type }}</span>
<span class="error-field">{{ field }}</span>
<span class="error-message">{{ message }}</span>
</div>
PHP_ARG_ENABLE(test, whether to enable test, [ --enable-test Enable test framework])
if test "$PHP_TEST" = "yes"; then
AC_DEFINE(HAVE_TEST, 1, [Whether you have Test])
test_sources="test.c kernel/main.c kernel/memory.c kernel/exception.c kernel/hash.c kernel/debug.c kernel/backtrace.c kernel/object.c kernel/array.c kernel/string.c kernel/fcall.c kernel/alternative/fcall.c kernel/operators.c arithmetic.c flow.c nativearray.c assign.c fibonnaci.c"
PHP_NEW_EXTENSION(test, $test_sources, $ext_shared)
fi