Skip to content

Instantly share code, notes, and snippets.

View avalanche123's full-sized avatar

Bulat Shakirzyanov avalanche123

View GitHub Profile
<?php
//...
$server->post('/login', function ($username, $password) use ($server) {
$auth = $server->getContainder()->getHttpAuthService();
$response = new Symfony\Components\HttpKernel\Response();
$session = $server->getContainder()->getSessionService();
try {
$auth->login($username, $password);
$response->setStatusCode(HTTPStatus::Accepted);
} catch (HttpAuthException $e) {
We couldn’t find that file to show.
<?php
$field = new ChoiceField('name', array(
'multiple' => false,
'expanded' => true,
'choices' => array(
1 => 'Track inventory',
0 => 'Do not track inventory',
)
));
You could specify multiple document managers
doctrine_odm.mongodb:
default_document_manager: default
default_connection: default
document_managers:
default:
connection: default
db: somedatabase
connections:
PASS #1 - SMALL FILE
=============================================
HTMLPurifier Pass #1 - Small File:
----------------------------------------------------
marker time index ex time perct
----------------------------------------------------
Start 1278614890.25844500 - 0.00%
----------------------------------------------------
Stop 1278614893.65603000 3.397585 100.00%
use Documents\Functional\AlsoLoad
, Documents\Functional\EmbeddedTestLevel0
, Documents\Functional\EmbeddedTestLevel1
, Documents\Functional\EmbeddedTestLevel2
, Documents\Functional\FavoritesUser
, Documents\Functional\NotAnnotatedDocument
, Documents\Functional\NotSaved
, Documents\Functional\NullFieldValues
, Documents\Functional\PreUpdateTestProduct
<?php
function fitzify ($input) {
return implode(\PHP_EOL, array_map(function($line) {
return $line . (rand(1, 4) == 1 ? str_repeat("\t", rand(1, 4)) : '');
}, explode(\PHP_EOL, $input)));
}
function fitzify_file($path) {
if ( ! is_file($path)) {
<?php
namespace Application\HelloBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
/** @Service(id="hello_controller") */
class HelloController extends Controller
{
protected $userRepository;
protected $logger;
// http package is used to create http servers
var http = require('http');
// create server that will write string 'Hello World' with a new line on every request to ip 127.0.0.1, port 8124
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(8124, "127.0.0.1");
// Log message after createServer is successfully sent
console.log('Server running at //127.0.0.1:8124/');
<?php
namespace Company\ApplicationBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
class ApplicationBundle extends Bundle {
public function registerExtensions(ContainerBuilder $container) {