Skip to content

Instantly share code, notes, and snippets.

# Composer Windows
Se der erro ao instalar pacotes (PHP unable to load php_curl.dll extension), adicionar php no path do Windows:
The right way to do it is to add the PHP path to the Windows Path variable. In Control Panel -> System click on Advanced System Settings and use the button Environment Variables. Under System Variables you will find the Path variable. Edit it and append ;C:\PHP to it - or whatever the path to your PHP folder is. Then fully stop Apache and start it again (a simple restart might not be enough).
# Composer Phalcon
Para usar composer no Phalcon carregue autoload em config/loader.php:
1. In your AWS Management Console, go to the EC2 Tab.
2. Check the instance you want to change (from micro to large, for example)
3. Put the instance in a 'Stopped' state.
4. Click the 'Instance Actions' menu, and choose 'Change Instance Type'
5. Choose the level you want the instance to run at (small, medium, large)
6. Click 'Yes, Change'.
7. Restart the instance in question.
Note: JUST MAKE SURE YOU HAVE YOUR ELASTIC IP SET UP AND ALLOCATED TO THE INSTANCE. INSTANCE'S IP WILL CHANGE RANDOMLY WHEN YOU RESTART YOUR INSTANCE.
## Nova instância do zero com Phalcon
Com servidor pronto (PHP instalado e rodando), uma típica configuração irá precisar de:
1. Adicionar extensão phalconphp
2. Adicionar extensão mongodb
3.
db.getCollection("schools").find({
geometry:
{ $near:
{
$geometry: { type: "Point", coordinates: [ -3.729858, 40.227383 ] },
$minDistance: 1000,
$maxDistance: 5000000
}
}
})
// https://stackoverflow.com/questions/20348093/mongodb-aggregation-how-to-get-total-records-count
// Pre 3.4
$result = $collection->aggregate(array(
array('$match' => $document),
array('$group' => array('_id' => '$book_id', 'date' => array('$max' => '$book_viewed'), 'views' => array('$sum' => 1))),
array('$sort' => $sort),
// get total, AND preserve the results
array('$group' => array('_id' => null, 'total' => array( '$sum' => 1 ), 'results' => array( '$push' => '$$ROOT' ) ),
// Requires official MongoShell 3.6+
use webapp;
db.getCollection("schools").aggregate(
[
{
"$match" : {
"status" : "active",
"country" : "Reino Unido",
"city" : "Londres"
}
<?php
$filter = ['_id' => ['$in' => $idsObjArray]];
cursor = $myCollection->find($filter, [])->toArray();
ccApp.checkRecaptcha = function($form) {
res = $form.find('.g-recaptcha-response').val();
if (res == "" || res == undefined || res.length == 0)
return false;
else
return true;
}
$(document).on('submit', '.ajax-form', function(event) {
$user = $collection->findOneAndUpdate(['_id' => $post['_id']], ['$set' => $post], ['returnDocument' => \MongoDB\Operation\FindOneAndUpdate::RETURN_DOCUMENT_AFTER]);
insertArr = [
[
'_id' => new \MongoDB\BSON\ObjectId(),
'name' => 'teste
]
];
$collection = $this->mongo->webapp->hosting;
$collection->updateOne(
['_id' =>new \MongoDB\BSON\ObjectId($hostingId), 'rooms._id' => new \MongoDB\BSON\ObjectId($roomId)],